Custom TNT Configuration Error

Discussion in 'Spigot Plugin Development' started by GHStudios, May 4, 2017.

  1. Hi, I am making a CustomTNT plugin and im trying to add a config file.

    Basicly im trying to get the GIGANTIC_TNT_RADIUS to be imported from the config and replace those numbers Default 8, The line that is giving me issues is:

    Code (Text):
     for (int z = getConfig().getString("GIGANTIC_TNT_RADIUS").getDouble(8); z <= getConfig().getString("GIGANTIC_TNT_RADIUS").getDouble(8); z++) {

    The section .getDouble is underlined red with the error: The method getDouble(int) is undefined for the type String

    Any help to fix it would be awesome!
    Thx, DuckCraftPVP

    Main class:
    TNT Event Class:
    TNT Class:
  2. WAS


    So why aren't you using
    Code (Java):
    getConfig().getDouble("GIGANTIC_TNT_RADIUS", 8);
  3. Oh did not know i could do that.
  4. that worked in eclipse but now i get this error in console:
    Code (Text):
    [15:09:30 ERROR]: Error occurred while enabling CustomTNT v1.1 (Is it up to date?)
    java.lang.IllegalArgumentException: Plugin already initialized!
            at ~[1.10.jar:git-Spigot-c3e4052-1953f52]
            at<init>( ~[1.10.jar:git-Spigot-c3e4052-1953f52]
            at com.duckcraftpvp.ghstudios.tnt.TNT.<init>( ~[?:?]
            at com.duckcraftpvp.ghstudios.tnt.FunTNT.<init>( ~[?:?]
            at com.duckcraftpvp.ghstudios.CustomTNT.onEnable( ~[?:?]
            at ~[1.10.jar:git-Spigot-c3e4052-1953f52]
            at [1.10.jar:git-Spigot-c3e4052-1953f52]
            at org.bukkit.plugin.SimplePluginManager.enablePlugin( [1.10.jar:git-Spigot-c3e4052-1953f52]
            at org.bukkit.craftbukkit.v1_10_R1.CraftServer.loadPlugin( [1.10.jar:git-Spigot-c3e4052-1953f52]
            at org.bukkit.craftbukkit.v1_10_R1.CraftServer.enablePlugins( [1.10.jar:git-Spigot-c3e4052-1953f52]
            at net.minecraft.server.v1_10_R1.MinecraftServer.t( [1.10.jar:git-Spigot-c3e4052-1953f52]
            at net.minecraft.server.v1_10_R1.MinecraftServer.l( [1.10.jar:git-Spigot-c3e4052-1953f52]
            at net.minecraft.server.v1_10_R1.MinecraftServer.a( [1.10.jar:git-Spigot-c3e4052-1953f52]
            at net.minecraft.server.v1_10_R1.DedicatedServer.init( [1.10.jar:git-Spigot-c3e4052-1953f52]
            at [1.10.jar:git-Spigot-c3e4052-1953f52]
            at Source) [?:1.8.0_131]
    Caused by: java.lang.IllegalStateException: Initial initialization
            at ~[1.10.jar:git-Spigot-c3e4052-1953f52]
            at<init>( ~[1.10.jar:git-Spigot-c3e4052-1953f52]
            at com.duckcraftpvp.ghstudios.CustomTNT.<init>( ~[?:?]
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_131]
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_131]
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_131]
            at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_131]
            at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_131]
            at<init>( ~[1.10.jar:git-Spigot-c3e4052-1953f52]
            at ~[1.10.jar:git-Spigot-c3e4052-1953f52]
            at org.bukkit.plugin.SimplePluginManager.loadPlugin( ~[1.10.jar:git-Spigot-c3e4052-1953f52]
            at org.bukkit.plugin.SimplePluginManager.loadPlugins( ~[1.10.jar:git-Spigot-c3e4052-1953f52]
            at org.bukkit.craftbukkit.v1_10_R1.CraftServer.loadPlugins( ~[1.10.jar:git-Spigot-c3e4052-1953f52]
            at net.minecraft.server.v1_10_R1.DedicatedServer.init( ~[1.10.jar:git-Spigot-c3e4052-1953f52]
            ... 2 more
  5. What's line 34 of your CustomTNT class?
  6. public class CustomTNT extends JavaPlugin implements Listener {
  7. customtnt class is my main class, Its in the desc
  8. Your extending JavaPlugin in two different classes...
  9. I changed to
    public abstract class TNT extends CustomTNT implements Listener
    and it still errors out.
  10. WAS


    It seems you have some misconceptions on how ti handle your classes or are not versed in Java. Id suggest checking out some Java tutorials and Spigot Plugin tutorials afterwards.
  11. Im going to but i still need to get this one peice solved :p I changed the Extending JavaPlugin to Extends CustomTNT so there was not more then 1 Extends JavaPlugin
  12. WAS


    Why do they need to extend anything, or be an abstract of anything? They should just be separate classes unless you are extending the TNT class itself, in which case you are doing it wrong.
  13. Yes im trying to extend the tnt class its self but the customtnt class is the main class errors if i dont extend from JavaPlugin.
  14. If you're going to be using multiple classes you should learn about constructors (and possibly fields). You need to pass the instance of your main class through other classes' constructors instead of extending a random class.
    • Agree Agree x 1
  15. WAS


    Your main class must extend JavaPlugin, but should have nothing to do with the operation and classes of your plugin which in this instance we'll call you "sub-classes".

    You should be listening in on the EntityExplodeEvent and checking if it's PrimedTNT and do your code there, in a Listener Event. I don't see a reason to extend the TNT Class, and won't get you very far as a newcomer dealing with NMS.
    #15 WAS, May 4, 2017
    Last edited: May 4, 2017
  16. There is no nms propertys in that plugin though
  17. WAS


    Nevertheless to accomplish what you are doing, you do not need to extend/abstract/implement any class but implement the Listener class. For instance the Prime event will allow you to change the explosion size.