getConfig.set giving error

Discussion in 'Plugin Development' started by juniorjpdj, Aug 25, 2013.

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

    juniorjpdj

    Hi,
    Its my first plugin.
    Server error log:
    Code:
    00:00:46 [INFO] juniorjpdj issued server command: /parkour set test
    00:00:46 [SEVERE] null
    org.bukkit.command.CommandException: Unhandled exception executing command 'park
    our' in plugin Parkour v0.1
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46)
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:19
    2)
            at org.bukkit.craftbukkit.v1_6_R2.CraftServer.dispatchCommand(CraftServe
    r.java:527)
            at net.minecraft.server.v1_6_R2.PlayerConnection.handleCommand(PlayerCon
    nection.java:979)
            at net.minecraft.server.v1_6_R2.PlayerConnection.chat(PlayerConnection.j
    ava:890)
            at net.minecraft.server.v1_6_R2.PlayerConnection.a(PlayerConnection.java
    :837)
            at net.minecraft.server.v1_6_R2.Packet3Chat.handle(SourceFile:49)
            at org.spigotmc.netty.NettyNetworkManager.b(NettyNetworkManager.java:230
    )
            at net.minecraft.server.v1_6_R2.PlayerConnection.e(PlayerConnection.java
    :116)
            at net.minecraft.server.v1_6_R2.ServerConnection.b(SourceFile:37)
            at org.spigotmc.netty.NettyServerConnection.b(NettyServerConnection.java
    :125)
            at net.minecraft.server.v1_6_R2.MinecraftServer.t(MinecraftServer.java:5
    92)
            at net.minecraft.server.v1_6_R2.DedicatedServer.t(DedicatedServer.java:2
    39)
            at net.minecraft.server.v1_6_R2.MinecraftServer.s(MinecraftServer.java:4
    81)
            at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java
    :413)
            at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:5
    82)
    Caused by: java.lang.IllegalArgumentException: File cannot be null
            at org.apache.commons.lang.Validate.notNull(Validate.java:192)
            at org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(Yam
    lConfiguration.java:170)
            at org.bukkit.plugin.java.JavaPlugin.reloadConfig(JavaPlugin.java:117)
            at org.bukkit.plugin.java.JavaPlugin.getConfig(JavaPlugin.java:111)
            at pl.interia.juniorjpdj.parkour.Komenda.onCommand(Komenda.java:20)
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
            ... 15 more
    >
    Command class:
    Code:java
    1. package pl.interia.juniorjpdj.parkour;
    2.  
    3. import org.bukkit.Location;
    4. import org.bukkit.command.Command;
    5. import org.bukkit.command.CommandExecutor;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.entity.Player;
    8.  
    9. public class Komenda extends Parkour implements CommandExecutor {
    10.  
    11. @Override
    12. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    13. if(cmd.getName().equalsIgnoreCase("parkour")) {
    14. if (sender instanceof Player){
    15. if (args.length == 0){
    16. sender.sendMessage("[Parkour] Napisz jakis argument pajacu!");
    17. } else if((args[0].equals("set")) && (args.length == 2)) {
    18. Player player = (Player) sender;
    19. Location loc = player.getLocation();
    20. getConfig().set("parkour-" + args[1], loc2str(loc));
    21. saveConfig();
    22. sender.sendMessage("[Parkour] Zapisano pozycje teleportu do parkouru " + args[1] + " !");
    23. } else if((args[0].equals("tp")) && (args.length == 2)) {
    24. Player player = (Player) sender;
    25. getConfig().set("player-" + player.getName(), args[1]);
    26. player.teleport(str2loc(getConfig().getString("parkour-" + args[1])));
    27. saveConfig();
    28. sender.sendMessage("[Parkour] Przeteleportowano na parkour " + args[1] + " !");
    29. } else {
    30. sender.sendMessage("[Parkour] Wez naucz sie skladni, nawet komendy napisac nie umiesz...");
    31. }
    32. } else {
    33. sender.sendMessage("[Parkour] Prosze korzystac z tej komendy w grze szanowny adminie na konsoli :D");
    34. }
    35. return true;
    36. } else {
    37. return false;
    38. }
    39. }
    40. }


    Oh, sry.
    I forget Parkour class...
    Code:java
    1. package pl.interia.juniorjpdj.parkour;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5. import org.bukkit.Location;
    6. import org.bukkit.plugin.java.JavaPlugin;
    7.  
    8. public class Parkour extends JavaPlugin {
    9.  
    10. protected static final Logger Log = Logger.getLogger("Minecraft");
    11.  
    12. public void onEnable(){
    13. getServer().getPluginManager().registerEvents(new Detektor(), this);
    14. getCommand("parkour").setExecutor(new Komenda());
    15. saveConfig();
    16. Log.info("[Parkour] Moj pierwszy gowniany plugin zostal zaladowany!");
    17. }
    18.  
    19. public void onDisable(){
    20. Log.info("[Parkour] No juz, juz sie wylaczam...");
    21. }
    22.  
    23. public String loc2str(Location loc){
    24. return loc.getWorld().getName()+":"+loc.getBlockX()+":"+loc.getBlockY()+":"+loc.getBlockZ()+":"+loc.getYaw()+":"+loc.getPitch();
    25. }
    26.  
    27. public Location str2loc(String str){
    28. String tmp[] = str.split("\\:");
    29. Location loc = new Location(getServer().getWorld(tmp[0]),Double.parseDouble(tmp[1]),Double.parseDouble(tmp[2]),Double.parseDouble(tmp[3]),Float.parseFloat(tmp[4]),Float.parseFloat(tmp[5]));
    30. return loc;
    31. }
    32.  
    33. }


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  2. Offline

    MOMOTHEREAL

    Perhaps you used Tabs instead of spaces in the config file?
     
  3. Offline

    aredherring

    Code:java
    1. getConfig().set("parkour-" + args[1], loc2str(loc));

    Your problem occurs at this line, with the exception:
    Code:java
    1. Caused by: java.lang.IllegalArgumentException: File cannot be null

    Are you sure your configuration file exists and can be "seen" by your plugin?
     
  4. Offline

    juniorjpdj

    File exists and plugin made it....
    Its blank, but when i edited it and added some variables its same error :/

    PS. Sry, my english isnt good.
     
  5. Offline

    Rocoty

    Don't extend the main class in your command executor...instead pass the instance of the main class to the executor, and use the reference to get the config.
     
  6. Offline

    juniorjpdj

    Even when i put str2loc and loc2str in command class its no working.
     
  7. Offline

    Rocoty

    Well, it's because those methods are in the main class, luv. Like I said, pass the instance of the main class to the executor. Preferably through a constructor when instantiating the executor.
     
  8. Offline

    juniorjpdj

    ...

    New version - same error :/

    Command class:
    Code:java
    1. package pl.interia.juniorjpdj.parkour;
    2.  
    3. import org.bukkit.Location;
    4. import org.bukkit.command.Command;
    5. import org.bukkit.command.CommandExecutor;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.plugin.java.JavaPlugin;
    9.  
    10. public class Komenda extends JavaPlugin implements CommandExecutor {
    11.  
    12. @Override
    13. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    14. if(cmd.getName().equalsIgnoreCase("parkour")) {
    15. if (sender instanceof Player){
    16. if (args.length == 0){
    17. sender.sendMessage("[Parkour] Napisz jakis argument pajacu!");
    18. } else if((args[0].equals("set")) && (args.length == 2)) {
    19. Player player = (Player) sender;
    20. Location loc = player.getLocation();
    21. //Parkour.parkourloc.put(args[1], new double[] {loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()});
    22. getConfig().set("parkour." + args[1] + ".x", loc.getX());
    23. getConfig().set("parkour." + args[1] + ".y", loc.getY());
    24. getConfig().set("parkour." + args[1] + ".z", loc.getZ());
    25. getConfig().set("parkour." + args[1] + ".yaw", loc.getYaw());
    26. getConfig().set("parkour." + args[1] + ".pitch", loc.getPitch());
    27. saveConfig();
    28. sender.sendMessage("[Parkour] Zapisano pozycje teleportu do parkouru " + args[1] + " !");
    29. } else if((args[0].equals("tp")) && (args.length == 2)) {
    30. Player player = (Player) sender;
    31. Parkour.lastparkour.put(player.getName(), args[1]);
    32. //double tmp[] = Parkour.parkourloc.get(args[1]);
    33. Location tp = new Location(player.getLocation().getWorld(), getConfig().getDouble("parkour." + args[1] + ".x"), getConfig().getDouble("parkour." + args[1] + ".y"), getConfig().getDouble("parkour." + args[1] + ".z"), (float) getConfig().getDouble("parkour." + args[1] + ".yaw"), (float) getConfig().getDouble("parkour." + args[1] + ".pitch"));
    34. player.teleport(tp);
    35. sender.sendMessage("[Parkour] Przeteleportowano na parkour " + args[1] + " !");
    36. } else {
    37. sender.sendMessage("[Parkour] Wez naucz sie skladni, nawet komendy napisac nie umiesz...");
    38. }
    39. } else {
    40. sender.sendMessage("[Parkour] Prosze korzystac z tej komendy w grze szanowny adminie na konsoli :D");
    41. }
    42. return true;
    43. } else {
    44. return false;
    45. }
    46. }
    47. }


    Main class (called Parkour):
    Code:java
    1. package pl.interia.juniorjpdj.parkour;
    2.  
    3. import java.util.HashMap;
    4. import java.util.logging.Logger;
    5.  
    6. import org.bukkit.plugin.java.JavaPlugin;
    7.  
    8. public class Parkour extends JavaPlugin {
    9.  
    10. public static HashMap<String, String> lastparkour = new HashMap<String, String>();
    11. public static HashMap<String, double[]> parkourloc = new HashMap<String, double[]>();
    12.  
    13. protected static final Logger Log = Logger.getLogger("Minecraft");
    14.  
    15. public void onEnable(){
    16. getServer().getPluginManager().registerEvents(new Detektor(), this);
    17. getCommand("parkour").setExecutor(new Komenda());
    18. saveConfig();
    19. Log.info("[Parkour] Moj pierwszy gowniany plugin zostal zaladowany!");
    20. }
    21.  
    22. public void onDisable(){
    23. Log.info("[Parkour] No juz, juz sie wylaczam...");
    24. }
    25. }


    Error log from console:
    Code:
    15:32:51 [INFO] juniorjpdj issued server command: /parkour set lol
    15:32:51 [SEVERE] null
    org.bukkit.command.CommandException: Unhandled exception executing command 'park
    our' in plugin Parkour v0.1
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46)
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:19
    1)
            at org.bukkit.craftbukkit.v1_6_R2.CraftServer.dispatchCommand(CraftServe
    r.java:523)
            at net.minecraft.server.v1_6_R2.PlayerConnection.handleCommand(PlayerCon
    nection.java:962)
            at net.minecraft.server.v1_6_R2.PlayerConnection.chat(PlayerConnection.j
    ava:880)
            at net.minecraft.server.v1_6_R2.PlayerConnection.a(PlayerConnection.java
    :837)
            at net.minecraft.server.v1_6_R2.Packet3Chat.handle(SourceFile:49)
            at net.minecraft.server.v1_6_R2.NetworkManager.b(NetworkManager.java:296
    )
            at net.minecraft.server.v1_6_R2.PlayerConnection.e(PlayerConnection.java
    :116)
            at net.minecraft.server.v1_6_R2.ServerConnection.b(SourceFile:37)
            at net.minecraft.server.v1_6_R2.DedicatedServerConnection.b(SourceFile:3
    0)
            at net.minecraft.server.v1_6_R2.MinecraftServer.t(MinecraftServer.java:5
    90)
            at net.minecraft.server.v1_6_R2.DedicatedServer.t(DedicatedServer.java:2
    26)
            at net.minecraft.server.v1_6_R2.MinecraftServer.s(MinecraftServer.java:4
    86)
            at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java
    :419)
            at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:5
    82)
    Caused by: java.lang.IllegalArgumentException: File cannot be null
            at org.apache.commons.lang.Validate.notNull(Validate.java:203)
            at org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(Yam
    lConfiguration.java:170)
            at org.bukkit.plugin.java.JavaPlugin.reloadConfig(JavaPlugin.java:117)
            at org.bukkit.plugin.java.JavaPlugin.getConfig(JavaPlugin.java:111)
            at pl.interia.juniorjpdj.parkour.Komenda.onCommand(Komenda.java:22)
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
            ... 15 more
    15:33:00 [INFO] juniorjpdj issued server command: /parkour tp lol
    15:33:00 [SEVERE] null
    org.bukkit.command.CommandException: Unhandled exception executing command 'park
    our' in plugin Parkour v0.1
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46)
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:19
    1)
            at org.bukkit.craftbukkit.v1_6_R2.CraftServer.dispatchCommand(CraftServe
    r.java:523)
            at net.minecraft.server.v1_6_R2.PlayerConnection.handleCommand(PlayerCon
    nection.java:962)
            at net.minecraft.server.v1_6_R2.PlayerConnection.chat(PlayerConnection.j
    ava:880)
            at net.minecraft.server.v1_6_R2.PlayerConnection.a(PlayerConnection.java
    :837)
            at net.minecraft.server.v1_6_R2.Packet3Chat.handle(SourceFile:49)
            at net.minecraft.server.v1_6_R2.NetworkManager.b(NetworkManager.java:296
    )
            at net.minecraft.server.v1_6_R2.PlayerConnection.e(PlayerConnection.java
    :116)
            at net.minecraft.server.v1_6_R2.ServerConnection.b(SourceFile:37)
            at net.minecraft.server.v1_6_R2.DedicatedServerConnection.b(SourceFile:3
    0)
            at net.minecraft.server.v1_6_R2.MinecraftServer.t(MinecraftServer.java:5
    90)
            at net.minecraft.server.v1_6_R2.DedicatedServer.t(DedicatedServer.java:2
    26)
            at net.minecraft.server.v1_6_R2.MinecraftServer.s(MinecraftServer.java:4
    86)
            at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java
    :419)
            at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:5
    82)
    Caused by: java.lang.IllegalArgumentException: File cannot be null
            at org.apache.commons.lang.Validate.notNull(Validate.java:203)
            at org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(Yam
    lConfiguration.java:170)
            at org.bukkit.plugin.java.JavaPlugin.reloadConfig(JavaPlugin.java:117)
            at org.bukkit.plugin.java.JavaPlugin.getConfig(JavaPlugin.java:111)
            at pl.interia.juniorjpdj.parkour.Komenda.onCommand(Komenda.java:33)
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
            ... 15 more
    >
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  9. Offline

    Rocoty

    You are trying to access a config which doesn't exist. Access the config from the instance of your main class, and don't extend the main class.
     
  10. Offline

    juniorjpdj

    So what i need to do?
    Can i use Parkour.getConfig??
    Or what else?
     
  11. Offline

    Lucariatias

    Your command class does not need to extend JavaPlugin.
    Replace:
    Code:java
    1. public class Komenda extends JavaPlugin implements CommandExecutor {

    with:
    Code:java
    1. public class Komenda implements CommandExecutor {
    2. private Parkour plugin;
    3. public Komenda(Parkour plugin) {
    4. this.plugin = plugin;
    5. }

    and:
    Code:java
    1. getCommand("parkour").setExecutor(new Komenda());

    with:
    Code:java
    1. getCommand("parkour").setExecutor(new Komenda(this));

    This will allow you to use plugin.getConfig(), or call any other methods using the instance of your plugin.
     
    juniorjpdj likes this.
  12. Offline

    juniorjpdj

    Oh, u r amazing :DD
    It works.
    But ive listener class too, and i need to use getConfig there too :/
    What i need to change?

    Listener class:
    Code:java
    1. package pl.interia.juniorjpdj.parkour;
    2.  
    3. import org.bukkit.Location;
    4. import org.bukkit.World;
    5. import org.bukkit.block.Block;
    6. import org.bukkit.entity.Player;
    7. import org.bukkit.event.EventHandler;
    8. import org.bukkit.event.EventPriority;
    9. import org.bukkit.event.Listener;
    10. import org.bukkit.event.player.PlayerMoveEvent;
    11.  
    12. public class Detektor implements Listener{
    13.  
    14. @EventHandler(priority = EventPriority.LOWEST)
    15. public void spadles(PlayerMoveEvent event){
    16. Player player = event.getPlayer();
    17. Location loc = player.getLocation();
    18. World w = loc.getWorld();
    19. loc.setY(loc.getY() -3);
    20. Block block = w.getBlockAt(loc);
    21. if (Parkour.lastparkour.get(player.getName()) != null){
    22. if (block.getTypeId() == 7){
    23. player.sendMessage("[Parkour] Fraaajer, spadles!");
    24. String tmp = Parkour.lastparkour.get(player.getName());
    25. Location tp = new Location(player.getLocation().getWorld(), getConfig().getDouble("parkour." + tmp + ".x"), getConfig().getDouble("parkour." + tmp + ".y"), getConfig().getDouble("parkour." + tmp + ".z"), (float) getConfig().getDouble("parkour." + tmp + ".yaw"), (float) getConfig().getDouble("parkour." + tmp + ".pitch"));
    26. player.teleport(tp);
    27. }
    28. }
    29. }
    30. }
    31.  


    Ref
    Pls help me!

    ref

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  13. Offline

    juniorjpdj

    OK, i fixed it by myself :D
     
  14. Offline

    mactown21

    Im still confused!, Even tho this post is really old xD,
    I cannot get my string to change in config.yml using commands
    using this, nothing changed!
    Code:
    if(cmd.getName().equalsIgnoreCase("enable"))
    {
    String s = getConfig().getString("enable")
    getConfig().set(s, "true");
    {
     
    
    Ive also tried using
    List<String> enable = getConfig().getString("enable");

    That didnt work, it does not change!, What is im doing wrong!
     
  15. Offline

    iiHeroo

    Probably not saving the config, also you dont need to do "true", simply true itself is fine.
     
  16. Offline

    Azubuso

    mactown21 Why are you taking a string argument in a method asking for true/false? Make it a boolean!
    Code:java
    1. // This in your main class //
    2. private static YourMainClass plugin;
    3.  
    4. // Initialize the above in your onEnable
    5. @Override
    6. public void onEnable() {
    7. plugin = this;
    8. }
    9.  
    10. public static YourMainClass getInstance() {
    11. return plugin;
    12. }
    13.  
    14. // Verious code stuffs //
    15. if (cmd.getName().equalsIgnoreCas("enable")) {
    16. Boolean bool = YourMainClass.getInstance().getConfig().getBoolean("enabled");
    17. if (!bool) {
    18. YourMainClass.getInstance().getConfig().set("enabled", true);
    19. YourMainClass.getInstance().saveConfig();
    20. return true;
    21. }
    22. sender.sendMessage("Already enabled!");
    23. return true;
    24. }
     
  17. Offline

    mactown21

    iiHeroo Azubuso
    I did something like this, I tried different ways
    I got enable: 'true' & 'true': false & true: '[]' something like that, im not for sure..

    Im trying to check a string on config for either true or false, this is something that i created!

    Code:
          if (args[0].equalsIgnoreCase("enable"))
          {
              if(getConfig().getBoolean("enable.barapi"))
              {
                  player.sendMessage(ChatColor.AQUA+""+ChatColor.BOLD+"[MiniSiTool]" + ChatColor.RESET+""+ChatColor.DARK_AQUA+" || " + ChatColor.RESET+""+ChatColor.AQUA+""+ChatColor.BOLD+"BarAPI is already enabled!");
                  return true;
              }else
              {
                  String s = "enable.barapi";
                  getConfig().set("true", s);
                  this.saveConfig();
                  this.reloadConfig();
                  player.sendMessage(ChatColor.AQUA+""+ChatColor.BOLD+"[MiniSiTool]" + ChatColor.RESET+""+ChatColor.DARK_AQUA+" || " + ChatColor.RESET+""+ChatColor.AQUA+""+ChatColor.BOLD+"Plugin Reloded!");
                  return true;
              }
          }
          if (args[0].equalsIgnoreCase("disable"))
          {
              if(getConfig().getBoolean("enable.barapi"))
              {
                  String s = "enable.barapi";
                  getConfig().set("false", s);
                  this.saveConfig();
                  this.reloadConfig();
                  player.sendMessage(ChatColor.AQUA+""+ChatColor.BOLD+"[MiniSiTool]" + ChatColor.RESET+""+ChatColor.DARK_AQUA+" || " + ChatColor.RESET+""+ChatColor.AQUA+""+ChatColor.BOLD+"Plugin Reloaded");
                  return true;
              }else{
                  player.sendMessage(ChatColor.AQUA+""+ChatColor.BOLD+"[MiniSiTool]" + ChatColor.RESET+""+ChatColor.DARK_AQUA+" || " + ChatColor.RESET+""+ChatColor.AQUA+""+ChatColor.BOLD+"BarAPI is already disabled!");
                  return true;
              }
          }
    so mainly this is being changed in config.yml or what im trying to get changed. Ive added a plugin save & reload, and its not working

    enable:
    barapi: true
    ^
     
  18. Offline

    Azubuso

    mactown21
    Look at what you're actually doing here:
    Code:java
    1. String s = "enable.barapi";
    2. getConfig().set("true", s);

    What you're doing here is setting the entry "true" in your config, to "enable.barapi", which I'm guessing is the exact opposite of what you're trying to do here! So just flip around the arguments in "getConfig().set(...);" and you should be getting what you want.
    Code:java
    1. getConfig().set("enable.barapi", true);
    2. // Save it
    3.  
    4. // In another method
    5. Boolean bool = getConfig().getBoolean("enable.barapi");
    6. if (bool) { } else {} ...
    7.  
     
  19. Offline

    mactown21

    Azubuso A little to much, ?. What if i did String s = getConfig().getString("enable.barapi");

    Config:

    enable:
    barapi: true
     
  20. Offline

    Europia79

    mactown21

    That's not correct spacing for YAML format. The yaml node "enable.barapi" means that barapi needs 2 or 4 spaces before it. Why 2 or 4 ? Because I've seen it done both ways. And both ways seem to work (and validate).

    config.yml (open)

    Code:
    enable:
      barapi: true


    Do you need any other help with this ?
     
  21. Offline

    Azubuso

    mactown21 Well yeah, It'd work as well, you'd just need to check if the returned string is equal to either true/false. It's just that it's a bit unconventional to use a getString method when asking for a Boolean.
     
  22. maybe because you forgot this????
    1.
    Code:java
    1. public void onEnable() {
    2. saveDefaultConfig();
    3. }

    and 2. put a config.yml in the same directory as your plugin.yml
     
  23. Just a little tutorial what you can make with config:
    Code:Java
    1.  
    2. //Get values
    3. Boolean bool = getConfig().getBoolean("Path.to.boolean");
    4. String str = getConfig().getString("Path.to.string");
    5. int i = getConfig().getInt("Path.to.int");
    6. List<String> list = getConfig().getStringList("Path.to.stringlist");
    7.  
    8. //Set values
    9. getConfig().set("Path.to.boolean", true);
    10. getConfig().set("Path.to.string", "example");
    11. getConfig().set("Path.to.int", 3);
    12. getConfig().set("Path.to.stringlist", Arrays.asList("example", "another example", "and one more"));
    13.  
    14. //!!SAVE IT AFTER YOU SET THINGS TO THE CONFIG!!
    15. saveConfig();
    16.  
     
  24. Offline

    Wolvereness Bukkit Team Member

    You are using an old version of Bukkit. Please update to the latest 1.7 builds.

    /edit: Ugh, necro...
    Please don't necro posts like this. Also, his problem was that he extended JavaPlugin instead of simply implementing CmmandExecutor.

    On the latest versions, extending JavaPlugin more than once throws an exception itself.
     
  25. Offline

    mactown21

    Azubuso that was just the format that happened on here. Ik its not the correct formatting. I didn't may attention.
     
Thread Status:
Not open for further replies.

Share This Page