BedWars1058 icon indicating copy to clipboard operation
BedWars1058 copied to clipboard

NumberFormatException when enabling BedWars plugin

Open WitheredWinter opened this issue 1 year ago • 1 comments

Description: When starting up the server with the BedWars plugin installed, I encountered a NumberFormatException related to an invalid input string "0-SNAPSHOT". This error prevents the plugin from being loaded properly.

Steps to Reproduce:

  1. Update the BedWars plugin (to me it's from 23.2.2-BETA4 to 23.12.2(newest)) on a server running PaperSpigot 1.8.8.
  2. Restart the server.
  3. Observe the error in the server logs during startup.

Expected Behavior: The plugin should load every existing map without any errors, allowing for normal operation of its features.

Actual Behavior: The server log displays a NumberFormatException, pointing to an issue with parsing the string "0-SNAPSHOT" as an integer. The error stack trace indicates that the issue occurs in the handleWorldAdapter method of the BedWars plugin. And after that the console shows errors like [Server thread/WARN]: [BedWars1058] There isn't any map called gateway

Error Message:

[22:35:48 WARN]: java.lang.NumberFormatException: For input string: "0-SNAPSHOT"
[22:35:48 WARN]:        at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
[22:35:48 WARN]:        at java.base/java.lang.Integer.parseInt(Integer.java:652)
[22:35:48 WARN]:        at java.base/java.lang.Integer.parseInt(Integer.java:770)
[22:35:48 WARN]:        at com.andrei1058.bedwars.BedWars.handleWorldAdapter(BedWars.java:546)
[22:35:48 WARN]:        at com.andrei1058.bedwars.BedWars.onEnable(BedWars.java:221)
[22:35:48 WARN]:        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321)
[22:35:48 WARN]:        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:332)
[22:35:48 WARN]:        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:454)
[22:35:48 WARN]:        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:393)
[22:35:48 WARN]:        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:352)
[22:35:48 WARN]:        at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:439)
[22:35:48 WARN]:        at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:403)
[22:35:48 WARN]:        at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:358)
[22:35:48 WARN]:        at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:301)
[22:35:48 WARN]:        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:603)
[22:35:48 WARN]:        at net.minecraft.server.v1_8_R3.MinecraftServer.lambda$spin$0(MinecraftServer.java:133)
[22:35:48 WARN]:        at java.base/java.lang.Thread.run(Thread.java:829)

Possible Cause: It appears that the plugin is attempting to parse a configuration value or similar input as an integer, but is receiving a string that cannot be directly converted ("0-SNAPSHOT").

Suggested Fix: It might be necessary to review the plugin code, specifically around the handleWorldAdapter method, to ensure that only valid integers are parsed from the configuration or input sources. Additionally, checking the configuration files for incorrect values that might lead to this error could help.

Environment:

  • BedWars plugin version: 23.12.2
  • Server version: PaperSpigot 1.8.8
  • Java version: Java 11

WitheredWinter avatar Feb 06 '24 15:02 WitheredWinter

This bug starts from version 23.3(23.3 doesn't have this bug)

WitheredWinter avatar Feb 06 '24 16:02 WitheredWinter