Solved loading a world from config error

Discussion in 'Spigot Plugin Development' started by Kaneki1337, Jun 25, 2018.

  1. [​IMG]

    am I doing this correctly? I feel not, because it gives me an error.
     
  2. You know, every thread you've made asking for help has been really vague. You don't provide any details whatsoever.

    You need to get as specific as possible. Explain what you are expecting to happen, explain what is actually happening. Include all errors (complete errors, not just "it errors"). Include all relevant code in [ code ] tags or a pastebin, not a screenshot.

    Remember, you've spent a lot of time looking at that code. You know more about it than anyone else. You can't expect us to jump on the same page as you with just a single line of code and a description of "it errors."

    As of right now there is not enough information given to be able to properly help you. Any attempt to do so would be blind guesses.
     
    • Like Like x 1
    • Agree Agree x 1
  3. To be honest, I am a java coder, never tried bukkit coding, and just got to it recently. The reason why I didn't give enough info, was because oh it's because it was a easy fix and a easy mistake I made, however here are the details.

    my code works perfectly fine when I keep it like this.

    Code (Java):
    World word = Bukkit.getWorld("world");
    Using the code above works perfectly, no errors on my plugin.

    However when I want to a get a world inside of a config, it throws a console error. Information provided below.
    [​IMG][​IMG]
    Code (Text):
    [12:54:48 WARN]: [PyrexMain] Task #2 for PyrexMain v1.0.0 generated an exception
    java.lang.IllegalArgumentException: bound must be positive
            at java.util.Random.nextInt(Unknown Source) ~[?:1.8.0_162]
            at com.faridkamizi.Package.SupplyDrop$1.run(SupplyDrop.java:63) ~[?:?]
            at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:59) ~[spigot.jar:git-PaperSpigot-"8b18730"]
            at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:349) [spigot.jar:git-PaperSpigot-"8b18730"]
            at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:783) [spigot.jar:git-PaperSpigot-"8b18730"]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:378) [spigot.jar:git-PaperSpigot-"8b18730"]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:713) [spigot.jar:git-PaperSpigot-"8b18730"]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:616) [spigot.jar:git-PaperSpigot-"8b18730"]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_162]
     
  4. I don't mean to be rude, but if you were a java coder you would know that the current error has nothing to with the world loading itself. Instead, you are trying to create random number with a negative bound. In order for a random to work you have to provide a positive bound! I would suggest taking a look at SupplyDrop line 63 and take a look at the random number you are trying to generate there!
     
  5. I don't mean to be rude either, but the code is in my hand, and I've ran countless tests, from my tests, when I change my code to this
    Code (Java):
    World world = Bukkit.getWorld((String) getConfig().get("supplydrop.config.world"));
    It gives me the error.
     
  6. Either you are sharing the wrong error here or the wrong code. Because the error doesn't match the code you provided and there is no-way the code you provided throws the error provided, simply no way!

    Code (Text):
    [12:54:48 WARN]: [PyrexMain] Task #2 for PyrexMain v1.0.0 generated an exception
    java.lang.IllegalArgumentException: bound must be positive
            at java.util.Random.nextInt(Unknown Source) ~[?:1.8.0_162]
            at com.faridkamizi.Package.SupplyDrop$1.run(SupplyDrop.java:63) ~[?:?]
            at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:59) ~[spigot.jar:git-PaperSpigot-"8b18730"]
            at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:349) [spigot.jar:git-PaperSpigot-"8b18730"]
            at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:783) [spigot.jar:git-PaperSpigot-"8b18730"]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:378) [spigot.jar:git-PaperSpigot-"8b18730"]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:713) [spigot.jar:git-PaperSpigot-"8b18730"]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:616) [spigot.jar:git-PaperSpigot-"8b18730"]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_162]
    The error says clearly that you are trying to generate a random number with bound <= 0. My guess is that you are using the world to generate a random location for the supply-drop to start? Could you share com.faridkamizi.Package.SupplyDrop$1.run(SupplyDrop.java:63) with us?
     
    • Agree Agree x 1
  7. Share all the code in that class please, that way it will be easy for us to look at the stacktrace and look at the code.
     
    • Agree Agree x 2
  8. Optic_Fusion1

    Resource Staff

    you also don't need (String)

    getConfig().getString("supplydrop.config.world"); works

    as for the error, yea there's no way in hell that line of code matches with the error provided