Confusion

Discussion in 'Plugin Development' started by bonecrusher238, Jun 24, 2014.

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

    bonecrusher238

    Hi, I was having some trouble setting up my commands with my config.

    Ok here is how I set it up. I have two packages one for commands one for the main documents etc. I created the main class file and setup the config when I was trying to link it to a command in the different package / class file the "getConfig().getString("HackingPunishment")" the "getConfig" registerd as a error. Thanks
     
  2. bonecrusher238 getConfig() is a method inherited from JavaPlugin, which is an implementation of Plugin. Call the method from an instance of your main class.
     
  3. Offline

    Traks

    Grab the currently active instance of your main class and call getConfig() on that, possibly? It's a bit vague without code and error message...
     
  4. Offline

    bonecrusher238

    Code:java
    1. package me.bone.staff;
    2.  
    3.  
    4.  
    5. import me.bone.commands.bantimes;
    6.  
    7. import me.bone.commands.link;
    8.  
    9.  
    10.  
    11. import org.bukkit.plugin.java.JavaPlugin;
    12.  
    13.  
    14.  
    15. public class Main extends JavaPlugin {
    16.  
    17.  
    18.  
    19. public void onEnable() {
    20.  
    21. getLogger().info("StaffHelper Enabled!");
    22.  
    23. getConfig().options().copyDefaults(true);
    24.  
    25. saveConfig();
    26.  
    27. getCommand("link").setExecutor(new link());
    28.  
    29. getCommand("bantimes").setExecutor(new bantimes());
    30.  
    31. }
    32.  
    33.  
    34.  
    35. public void onDisable() {
    36.  
    37. getLogger().info("StaffHelper Disabled!");
    38.  
    39. }
    40.  
    41.  
    42.  
    43.  
    44.  
    45. }
    46.  
    47.  

    Here you go Traks
     
Thread Status:
Not open for further replies.

Share This Page