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: https://hastebin.com/usitegiboz.swift
    TNT Event Class: https://hastebin.com/pimunavafu.java
    TNT Class: https://hastebin.com/uzobogicef.swift
    Config.YML: https://hastebin.com/ufuletohoj.makefile
     
  2. WAS

    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 org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:122) ~[1.10.jar:git-Spigot-c3e4052-1953f52]
            at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:67) ~[1.10.jar:git-Spigot-c3e4052-1953f52]
            at com.duckcraftpvp.ghstudios.tnt.TNT.<init>(TNT.java:58) ~[?:?]
            at com.duckcraftpvp.ghstudios.tnt.FunTNT.<init>(FunTNT.java:17) ~[?:?]
            at com.duckcraftpvp.ghstudios.CustomTNT.onEnable(CustomTNT.java:72) ~[?:?]
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:292) ~[1.10.jar:git-Spigot-c3e4052-1953f52]
            at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [1.10.jar:git-Spigot-c3e4052-1953f52]
            at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [1.10.jar:git-Spigot-c3e4052-1953f52]
            at org.bukkit.craftbukkit.v1_10_R1.CraftServer.loadPlugin(CraftServer.java:362) [1.10.jar:git-Spigot-c3e4052-1953f52]
            at org.bukkit.craftbukkit.v1_10_R1.CraftServer.enablePlugins(CraftServer.java:322) [1.10.jar:git-Spigot-c3e4052-1953f52]
            at net.minecraft.server.v1_10_R1.MinecraftServer.t(MinecraftServer.java:416) [1.10.jar:git-Spigot-c3e4052-1953f52]
            at net.minecraft.server.v1_10_R1.MinecraftServer.l(MinecraftServer.java:381) [1.10.jar:git-Spigot-c3e4052-1953f52]
            at net.minecraft.server.v1_10_R1.MinecraftServer.a(MinecraftServer.java:336) [1.10.jar:git-Spigot-c3e4052-1953f52]
            at net.minecraft.server.v1_10_R1.DedicatedServer.init(DedicatedServer.java:270) [1.10.jar:git-Spigot-c3e4052-1953f52]
            at net.minecraft.server.v1_10_R1.MinecraftServer.run(MinecraftServer.java:539) [1.10.jar:git-Spigot-c3e4052-1953f52]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_131]
    Caused by: java.lang.IllegalStateException: Initial initialization
            at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:125) ~[1.10.jar:git-Spigot-c3e4052-1953f52]
            at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:67) ~[1.10.jar:git-Spigot-c3e4052-1953f52]
            at com.duckcraftpvp.ghstudios.CustomTNT.<init>(CustomTNT.java:34) ~[?:?]
            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 org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:76) ~[1.10.jar:git-Spigot-c3e4052-1953f52]
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:131) ~[1.10.jar:git-Spigot-c3e4052-1953f52]
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[1.10.jar:git-Spigot-c3e4052-1953f52]
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) ~[1.10.jar:git-Spigot-c3e4052-1953f52]
            at org.bukkit.craftbukkit.v1_10_R1.CraftServer.loadPlugins(CraftServer.java:297) ~[1.10.jar:git-Spigot-c3e4052-1953f52]
            at net.minecraft.server.v1_10_R1.DedicatedServer.init(DedicatedServer.java:202) ~[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 tnt.java to
    public abstract class TNT extends CustomTNT implements Listener
    and it still errors out.
     
  10. WAS

    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

    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

    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

    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.