Separate Class Command Arguments

Discussion in 'Plugin Development' started by Xemiru, Apr 18, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Xemiru

    Main Class - http://pastebin.com/9n4dQBDt
    dccCmd Class - http://pastebin.com/VSFpPLCQ

    I need a way for me to get a command argument from the dccCmd class.
    The problem is that I don't know how.

    I need it at line #123 in the Main class.
    Argument from line #70 in the dccCmd class.

    Ty.
     
  2. Offline

    bsquidwrd

    Try and declare the String cca1, as that is what I am assuming you want to reference, at the top and make it public. Then when you need it in your main class, just do something like dccCmd.cca1 to reference it. Not sure if that is 100% correct, but I am still learning Java so let me know if that is wrong please.
     
  3. Offline

    Xemiru

    I don't know if it worked..

    I still have this other error I got before that.

    Code:
    Could not load 'plugins\dynChat.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.NoSuchMethodException: xemi.plugins.dyndev.Main.<init>()
     at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:150)
     at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:305)
     at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:230)
     at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:207)
     at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:183)
     at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigurationManager.java:53)
     at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:156)
     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:422)
     at net.minecraft.server.ThreadServerApplication.run(SourceFile:492)
    Caused by: java.lang.NoSuchMethodException: xemi.plugins.dyndev.Main.<init>()
     at java.lang.Class.getConstructor0(Unknown Source)
     at java.lang.Class.getConstructor(Unknown Source)
     at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:142)
     ... 8 more
    
     
  4. Offline

    dillyg10

    here is how i do it...

    Code:java
    1.  
    2. public class baseCommand {
    3. public static String[] args;
    4. public static Sender sender;
    5. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    6. if(cmd.getName().equalsIgnoreCase("base") {
    7. this.sender = sender;
    8. this.args = args;
    9. if (arg.init()) return true;
    10. }
    11. }
    12. }
    13.  
    14. //then in a seperate class..
    15.  
    16. public class arg extends baseCommand{
    17. public boolean init() {
    18. if (args[0].equalsIgnoreCase("arg"){
    19. //do stuff...
    20. return true;
    21. }
    22. return false;
    23. }
    24. }
     
Thread Status:
Not open for further replies.

Share This Page