Null Config (I need this today)

Discussion in 'Plugin Development' started by boss86741, Sep 14, 2013.

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

    boss86741

    Hey,

    My configuration file is giving me the treatment.

    Code:
    13.09 11:13:33 [Server] INFO at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:582)
    13.09 11:13:33 [Server] INFO at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java:391)
    13.09 11:13:33 [Server] INFO at net.minecraft.server.v1_6_R2.DedicatedServer.init(DedicatedServer.java:151)
    13.09 11:13:33 [Server] INFO at net.minecraft.server.v1_6_R2.MinecraftServer.a(MinecraftServer.java:250)
    13.09 11:13:33 [Server] INFO at net.minecraft.server.v1_6_R2.MinecraftServer.f(MinecraftServer.java:290)
    13.09 11:13:33 [Server] INFO at net.minecraft.server.v1_6_R2.MinecraftServer.l(MinecraftServer.java:313)
    13.09 11:13:33 [Server] INFO at org.bukkit.craftbukkit.v1_6_R2.CraftServer.enablePlugins(CraftServer.java:264)
    13.09 11:13:33 [Server] INFO at org.bukkit.craftbukkit.v1_6_R2.CraftServer.loadPlugin(CraftServer.java:282)
    13.09 11:13:33 [Server] INFO at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:381)
    13.09 11:13:33 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:457)
    13.09 11:13:33 [Server] INFO at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217)
    13.09 11:13:33 [Server] INFO at com.boss86741.plugins.gamemodes.Gamemodes.onEnable(Gamemodes.java:25)
    13.09 11:13:33 [Server] INFO at com.boss86741.plugins.gamemodes.Commands.<init>(Commands.java:26)
    13.09 11:13:33 [Server] INFO java.lang.NullPointerException
    13.09 11:13:33 [Server] SEVERE Error occurred while enabling Gamemodes v1.0 (Is it up to date?)
    I know why this error is caused but how to fix it?

    Gamemodes
    Show Spoiler
    Code:
    package com.boss86741.plugins.gamemodes;
     
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import org.bukkit.Color;
    import org.bukkit.Material;
    import org.bukkit.configuration.InvalidConfigurationException;
    import org.bukkit.enchantments.Enchantment;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.EntityEquipment;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.inventory.meta.LeatherArmorMeta;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
     
    public class Gamemodes extends JavaPlugin {
     
    @Override
    public void onEnable() {
    getLogger().info("Enabled.");
     
    Commands c = new Commands(this);
    getCommand("pvp").setExecutor(c);
     
    getServer().getPluginManager().registerEvents(new Events(this), this);
     
    String pluginFolder = this.getDataFolder().getAbsolutePath();
     
    (new File(pluginFolder)).mkdirs();
     
    try {
    getConfig().load("config.yml");
     
    getConfig().addDefault("DN", "");
    getConfig().addDefault("J", "");
    getConfig().addDefault("MS", "");
    getConfig().addDefault("F", "");
    getConfig().addDefault("D", "");
    getConfig().addDefault("FB", "");
    getConfig().addDefault("HJ", "");
    getConfig().addDefault("WW", "");
    getConfig().addDefault("DS", "");
    getConfig().addDefault("S", "");
    getConfig().addDefault("BB", "");
    getConfig().addDefault("SH", "");
     
    getConfig().addDefault("w1", "");
    getConfig().addDefault("w2", "");
    getConfig().addDefault("w3", "");
    getConfig().addDefault("w4", "");
    getConfig().addDefault("w5", "");
     
    getConfig().addDefault("1", "");
    getConfig().addDefault("2", "");
    getConfig().addDefault("3", "");
    getConfig().addDefault("4", "");
    getConfig().addDefault("5", "");
     
    getConfig().addDefault("red", "");
    getConfig().addDefault("blue", "");
     
    saveConfig();
    } catch (FileNotFoundException e) {
     
     
    e.printStackTrace();
    } catch (IOException e) {
    e.printStackTrace();
    } catch (InvalidConfigurationException e) {
    e.printStackTrace();
    }
     
    /* int world1 = plugin.getServer().getWorld("Overhang").getPlayers().size();
    String w1 = Integer.toString(world1);
     
    int world2 = plugin.getServer().getWorld("Polar Bear Club").getPlayers().size();
    String w2 = Integer.toString(world2);
     
    int world3 = plugin.getServer().getWorld("Twisted Fate").getPlayers().size();
    String w3 = Integer.toString(world3);
     
    int world4 = plugin.getServer().getWorld("WisardsRetreat").getPlayers().size();
    String w4 = Integer.toString(world4);
     
    int world5 = plugin.getServer().getWorld("Kaldr").getPlayers().size();
    String w5 = Integer.toString(world5); */
    }
     
    // Below are the kits.
     
    // snip snip
    



    Commands
    Show Spoiler
    Code:
    package com.boss86741.plugins.gamemodes;
     
    import java.util.List;
    import java.util.Random;
     
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.World;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
     
    public class Commands implements CommandExecutor {
     
    private Gamemodes plugin;
     
    public Commands(Gamemodes plugin) {
    this.plugin = plugin;
    }
     
    //public int getPlayerGems(Player p, String pl) {
    //return plugin.getConfig().getInt(pl);
    //}
     
    List<String> red = plugin.getConfig().getStringList("red");
    List<String> blue = plugin.getConfig().getStringList("blue");
     
    public List<String> getRed() {
    return red;
    }
     
    public List<String> getBlue() {
    return blue;
    }
     
    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    Player p = (Player) sender;
    String pl = p.getName();
     
    if (cmd.getName().equalsIgnoreCase("pvp")) {
    if (p.hasPermission("gamemodes.user")) {
    if (args.length == 2) {
    if (args[0].equalsIgnoreCase("join")) { // Blue = team 1 ; Red = team 2
    if (args[1].equalsIgnoreCase("overhang")) {
    if (red.size() > blue.size()){
    blue.add(pl);
    World world = plugin.getServer().getWorld("Overhang");
    new Location(world, -5, 2, 65);
    plugin.getConfig().set(pl, "blue");
    plugin.saveConfig();
    } else if (red.size() < blue.size()){
    red.add(pl);
    World world = plugin.getServer().getWorld("Overhang");
    new Location(world, -44, 4, 40);
    plugin.getConfig().set(pl, "red");
    plugin.saveConfig();
    } else {
    Integer team = new Random().nextInt(2);
    if (team == 1){
    red.add(pl);
    World world = plugin.getServer().getWorld("Overhang");
    new Location(world, -44, 4, 40);
    plugin.getConfig().set(pl, "red");
    plugin.saveConfig();
    } else {
    blue.add(pl);
    World world = plugin.getServer().getWorld("Overhang");
    new Location(world, -5, 2, 65);
    plugin.getConfig().set(pl, "blue");
    plugin.saveConfig();
    }
    }
    } else if (args[1].equalsIgnoreCase("polarbearclub")) {
    if (red.size() > blue.size()){
    blue.add(pl);
    World world = plugin.getServer().getWorld("Polar Bear Club");
    new Location(world, 735, 4, -548);
    plugin.getConfig().set(pl, "blue");
    plugin.saveConfig();
    } else if (red.size() < blue.size()){
    red.add(pl);
    World world = plugin.getServer().getWorld("Polar Bear Club");
    new Location(world, 796, 4, -548);
    plugin.getConfig().set(pl, "red");
    plugin.saveConfig();
    } else {
    Integer team = new Random().nextInt(2);
    if (team == 1){
    red.add(pl);
    World world = plugin.getServer().getWorld("Polar Bear Club");
    new Location(world, 796, 4, -548);
    plugin.getConfig().set(pl, "red");
    plugin.saveConfig();
    } else {
    blue.add(pl);
    World world = plugin.getServer().getWorld("Polar Bear Club");
    new Location(world, 735, 4, -548);
    plugin.getConfig().set(pl, "blue");
    plugin.saveConfig();
    }
    }
    } else if (args[1].equalsIgnoreCase("twistedfate")) {
    if (red.size() > blue.size()){
    blue.add(pl);
    World world = plugin.getServer().getWorld("Twisted Fate");
    new Location(world, -26, 108, 68);
    plugin.getConfig().set(pl, "blue");
    plugin.saveConfig();
    } else if (red.size() < blue.size()){
    red.add(pl);
    World world = plugin.getServer().getWorld("Twisted Fate");
    new Location(world, -30, 80, -19);
    plugin.getConfig().set(pl, "red");
    plugin.saveConfig();
    } else {
    Integer team = new Random().nextInt(2);
    if (team == 1){
    red.add(pl);
    World world = plugin.getServer().getWorld("Twisted Fate");
    new Location(world, -30, 80, -19);
    plugin.getConfig().set(pl, "red");
    plugin.saveConfig();
    } else {
    blue.add(pl);
    World world = plugin.getServer().getWorld("Twisted Fate");
    new Location(world, -26, 108, 68);
    plugin.getConfig().set(pl, "blue");
    plugin.saveConfig();
    }
    }
    } else if (args[1].equalsIgnoreCase("wr")) {
    if (red.size() > blue.size()){
    blue.add(pl);
    World world = plugin.getServer().getWorld("Wizard's Retreat");
    new Location(world, 239, 63, 1359);
    plugin.getConfig().set(pl, "blue");
    plugin.saveConfig();
    } else if (red.size() < blue.size()){
    red.add(pl);
    World world = plugin.getServer().getWorld("Wizard's Retreat");
    new Location(world, 166, 66, 1372);
    plugin.getConfig().set(pl, "red");
    plugin.saveConfig();
    } else {
    Integer team = new Random().nextInt(2);
    if (team == 1){
    red.add(pl);
    World world = plugin.getServer().getWorld("Wizard's Retreat");
    new Location(world, 796, 4, -548);
    plugin.getConfig().set(pl, "red");
    plugin.saveConfig();
    } else {
    blue.add(pl);
    World world = plugin.getServer().getWorld("Wizard's Retreat");
    new Location(world, 735, 4, -548);
    plugin.getConfig().set(pl, "blue");
    plugin.saveConfig();
    }
    }
    } else if (args[1].equalsIgnoreCase("kaldr")) {
    if (red.size() > blue.size()){
    blue.add(pl);
    World world = plugin.getServer().getWorld("Kaldr");
    new Location(world, -1125, 4, 793);
    plugin.getConfig().set(pl, "blue");
    plugin.saveConfig();
    } else if (red.size() < blue.size()){
    red.add(pl);
    World world = plugin.getServer().getWorld("Kaldr");
    new Location(world, -1142, 4, 762);
    plugin.getConfig().set(pl, "red");
    plugin.saveConfig();
    } else {
    Integer team = new Random().nextInt(2);
    if (team == 1){
    red.add(pl);
    World world = plugin.getServer().getWorld("Kaldr");
    new Location(world, -1142, 4, 762);
    plugin.getConfig().set(pl, "red");
    plugin.saveConfig();
    } else {
    blue.add(pl);
    World world = plugin.getServer().getWorld("Kaldr");
    new Location(world, -1125, 4, 793);
    plugin.getConfig().set(pl, "blue");
    plugin.saveConfig();
    }
    }
    } else {
    p.sendMessage(ChatColor.DARK_RED + "That arena doesn't exist!");
    }
    } else if (args[0].equalsIgnoreCase("kit")) {
    if (args[1].equalsIgnoreCase("darkknight")) { /* VIP */
    if (p.hasPermission("gamemodes.vip")) {
    p.getInventory().clear();
    plugin.givePlayerDN(p, pl);
    plugin.getConfig().getStringList("DN").add(pl);
    } else {
    p.sendMessage(ChatColor.DARK_RED + "You don't have permissions. Get VIP on our website!");
    }
    } else if (args[1].equalsIgnoreCase("joker")) {
    p.getInventory().clear();
    plugin.givePlayerJ(p, pl);
    plugin.getConfig().getStringList("J").add(pl);
    plugin.saveConfig();
    } else if (args[1].equalsIgnoreCase("manofsteel")) {
    p.getInventory().clear();
    plugin.givePlayerMS(p, pl);
    plugin.getConfig().getStringList("MS").add(pl);
    plugin.saveConfig();
    } else if (args[1].equalsIgnoreCase("flash")) {
    p.getInventory().clear();
    plugin.givePlayerF(p, pl);
    plugin.getConfig().getStringList("F").add(pl);
    plugin.saveConfig();
    } else if (args[1].equalsIgnoreCase("doomsday")) { /* VIP */
    if (p.hasPermission("gamemodes.vip")) {
    p.getInventory().clear();
    plugin.givePlayerD(p, pl);
    plugin.getConfig().getStringList("D").add(pl);
    plugin.saveConfig();
    } else {
    p.sendMessage(ChatColor.DARK_RED + "You don't have permissions. Get VIP on our website!");
    }
    } else if (args[1].equalsIgnoreCase("firebrand")) {
    p.getInventory().clear();
    plugin.givePlayerFB(p, pl);
    plugin.getConfig().getStringList("FB").add(pl);
    plugin.saveConfig();
    } else if (args[1].equalsIgnoreCase("harveyjones")) { /* VIP */
    if (p.hasPermission("gamemodes.vip")) {
    p.getInventory().clear();
    plugin.givePlayerHJ(p, pl);
    plugin.getConfig().getStringList("HJ").add(pl);
    plugin.saveConfig();
    } else {
    p.sendMessage(ChatColor.DARK_RED + "You don't have permissions. Get VIP on our website!");
    }
    } else if (args[1].equalsIgnoreCase("wonderwoman")) { /* VIP */
    if (p.hasPermission("gamemodes.vip")) {
    p.getInventory().clear();
    plugin.givePlayerWW(p, pl);
    plugin.getConfig().getStringList("WW").add(pl);
    plugin.saveConfig();
    } else {
    p.sendMessage(ChatColor.DARK_RED + "You don't have permissions. Get VIP on our website!");
    }
    } else if (args[1].equalsIgnoreCase("deathstroke")) { /* VIP */
    if (p.hasPermission("gamemodes.vip")) {
    p.getInventory().clear();
    plugin.givePlayerDS(p, pl);
    plugin.getConfig().getStringList("DS").add(pl);
    plugin.saveConfig();
    } else {
    p.sendMessage(ChatColor.DARK_RED + "You don't have permissions. Get VIP on our website!");
    }
    } else if (args[1].equalsIgnoreCase("specter")) {
    p.getInventory().clear();
    plugin.givePlayerS(p, pl);
    plugin.getConfig().getStringList("S").add(pl);
    plugin.saveConfig();
    } else if (args[1].equalsIgnoreCase("beastboy")) {
    p.getInventory().clear();
    plugin.givePlayerBB(p, pl);
    plugin.getConfig().getStringList("BB").add(pl);
    plugin.saveConfig();
    } else if (args[1].equalsIgnoreCase("shazam")) { /* VIP */
    if (p.hasPermission("gamemodes.vip")) {
    p.getInventory().clear();
    plugin.givePlayerSH(p, pl);
    plugin.getConfig().getStringList("SH").add(pl);
    plugin.saveConfig();
    } else {
    p.sendMessage(ChatColor.DARK_RED + "You don't have permissions. Get VIP on our website!");
    }
    } else {
    p.sendMessage(ChatColor.DARK_RED + "That kit doesn't exist! Do /pvp list to see what kits there are.");
    }
    } else {
     
    }
    } else if (args.length == 1) {
    if (args[0].equalsIgnoreCase("list")) {
    String messageHeader = "&b-&a=&b-&a=&b-&a=&e Kits &a=&b-&a=&b-&a=&b-";
    p.sendMessage(messageHeader.replaceAll("(&([a-f0-9]))", "\u00A7$2"));
    p.sendMessage(ChatColor.DARK_RED + "Free:");
    p.sendMessage(ChatColor.RED + "Gems Required:");
    p.sendMessage(ChatColor.LIGHT_PURPLE + "VIP Required:");
    } else if (args[0].equalsIgnoreCase("help")) {
    String message1 = "&b-&a=&b-&a=&b-&a=&eSlave Help&a=&b-&a=&b-&a=&b-";
    String message2 = "&2/class choose <classname> &f- &dChoose your class";
    String message3 = "&3/class list &f- &6List all the classes";
    String message4 = "&a/class kit &f- &cGive's you the kit for your class";
    String message5 = "&4/class help &f- &eShows you this help menu";
    sender.sendMessage(message1.replaceAll("(&([a-f0-9]))", "\u00A7$2"));
    sender.sendMessage(message2.replaceAll("(&([a-f0-9]))", "\u00A7$2"));
    sender.sendMessage(message3.replaceAll("(&([a-f0-9]))", "\u00A7$2"));
    sender.sendMessage(message4.replaceAll("(&([a-f0-9]))", "\u00A7$2"));
    sender.sendMessage(message5.replaceAll("(&([a-f0-9]))", "\u00A7$2"));
    } else if (args[0].equalsIgnoreCase("kit")) {
    } else {
    sender.sendMessage(ChatColor.RED + "Do /pvp help for the help menu.");
    }
    } else {
    sender.sendMessage(ChatColor.RED + "Do /pvp help for the help menu.");
    }
    } else {
    sender.sendMessage(ChatColor.DARK_RED + "You do not have permission!");
    }
    return true;
    }
    return false;
    }
    }
    
     
  2. Offline

    Pizza371

    boss86741 please use java code tags! It helps so much.
     
  3. Offline

    CubieX

    Hm. "plugin" seems to be properly initialized.
    So "getConfig()" could be the problem in your Commands class.

    It seems like the invocation of your config.yml does not work.
    Try to first load the config in your onEnable() and then create your Commands instance.
     
  4. Offline

    boss86741

    CubieX how?
    Pizza371

    Gamemodes

    [spoiler]
    Code:java
    1.  
    Code:java
    1. package com.boss86741.plugins.gamemodes;
    2.  
    3. import java.io.File;
    4. import java.io.FileNotFoundException;
    5. import java.io.IOException;
    6. import org.bukkit.Color;
    7. import org.bukkit.Material;
    8. import org.bukkit.configuration.InvalidConfigurationException;
    9. import org.bukkit.enchantments.Enchantment;
    10. import org.bukkit.entity.Player;
    11. import org.bukkit.inventory.EntityEquipment;
    12. import org.bukkit.inventory.ItemStack;
    13. import org.bukkit.inventory.meta.ItemMeta;
    14. import org.bukkit.inventory.meta.LeatherArmorMeta;
    15. import org.bukkit.plugin.java.JavaPlugin;
    16. import org.bukkit.potion.PotionEffect;
    17. import org.bukkit.potion.PotionEffectType;
    18.  
    19. public class Gamemodes extends JavaPlugin {
    20.  
    21. @Override
    22. public void onEnable() {
    23. getLogger().info("Enabled.");
    24.  
    25. String pluginFolder = this.getDataFolder().getAbsolutePath();
    26.  
    27. (new File(pluginFolder)).mkdirs();
    28.  
    29. try {
    30. getConfig().load(pluginFolder + File.separator + "config.yml");
    31.  
    32. getConfig().addDefault("DN", "");
    33. getConfig().addDefault("J", "");
    34. getConfig().addDefault("MS", "");
    35. getConfig().addDefault("F", "");
    36. getConfig().addDefault("D", "");
    37. getConfig().addDefault("FB", "");
    38. getConfig().addDefault("HJ", "");
    39. getConfig().addDefault("WW", "");
    40. getConfig().addDefault("DS", "");
    41. getConfig().addDefault("S", "");
    42. getConfig().addDefault("BB", "");
    43. getConfig().addDefault("SH", "");
    44.  
    45. getConfig().addDefault("w1", "");
    46. getConfig().addDefault("w2", "");
    47. getConfig().addDefault("w3", "");
    48. getConfig().addDefault("w4", "");
    49. getConfig().addDefault("w5", "");
    50.  
    51. getConfig().addDefault("1", "");
    52. getConfig().addDefault("2", "");
    53. getConfig().addDefault("3", "");
    54. getConfig().addDefault("4", "");
    55. getConfig().addDefault("5", "");
    56.  
    57. getConfig().addDefault("red", "");
    58. getConfig().addDefault("blue", "");
    59.  
    60. saveConfig();
    61. } catch (FileNotFoundException e) {
    62. e.printStackTrace();
    63. } catch (IOException e) {
    64. e.printStackTrace();
    65. } catch (InvalidConfigurationException e) {
    66. e.printStackTrace();
    67. }
    68.  
    69. Commands c = new Commands(this);
    70. getCommand("pvp").setExecutor(c);
    71.  
    72. getServer().getPluginManager().registerEvents(new Events(this), this);
    73.  
    74. /* int world1 = plugin.getServer().getWorld("Overhang").getPlayers().size();
    75. String w1 = Integer.toString(world1);
    76.  
    77. int world2 = plugin.getServer().getWorld("Polar Bear Club").getPlayers().size();
    78. String w2 = Integer.toString(world2);
    79.  
    80. int world3 = plugin.getServer().getWorld("Twisted Fate").getPlayers().size();
    81. String w3 = Integer.toString(world3);
    82.  
    83. int world4 = plugin.getServer().getWorld("WisardsRetreat").getPlayers().size();
    84. String w4 = Integer.toString(world4);
    85.  
    86. int world5 = plugin.getServer().getWorld("Kaldr").getPlayers().size();
    87. String w5 = Integer.toString(world5); */
    88. }
    89.  
    90. // Below are the kits.
    [/spoiler]

    Commands
    Show Spoiler
    Code:java
    1. package com.boss86741.plugins.gamemodes;
    2.  
    3. import java.util.List;
    4. import java.util.Random;
    5.  
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.Location;
    8. import org.bukkit.World;
    9. import org.bukkit.command.Command;
    10. import org.bukkit.command.CommandExecutor;
    11. import org.bukkit.command.CommandSender;
    12. import org.bukkit.entity.Player;
    13.  
    14. public class Commands implements CommandExecutor {
    15.  
    16. private Gamemodes plugin;
    17.  
    18. public Commands(Gamemodes plugin) {
    19. this.plugin = plugin;
    20. }
    21.  
    22. //public int getPlayerGems(Player p, String pl) {
    23. //return plugin.getConfig().getInt(pl);
    24. //}
    25.  
    26. List<String> red = plugin.getConfig().getStringList("red");
    27. List<String> blue = plugin.getConfig().getStringList("blue");
    28.  
    29. public List<String> getRed() {
    30. return red;
    31. }
    32.  
    33. public List<String> getBlue() {
    34. return blue;
    35. }
    36.  
    37. @Override
    38. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    39. Player p = (Player) sender;
    40. String pl = p.getName();
    41.  
    42. if (cmd.getName().equalsIgnoreCase("pvp")) {
    43. if (p.hasPermission("gamemodes.user")) {
    44. if (args.length == 2) {
    45. if (args[0].equalsIgnoreCase("join")) { // Blue = team 1 ; Red = team 2
    46. if (args[1].equalsIgnoreCase("overhang")) {
    47. if (red.size() > blue.size()){
    48. blue.add(pl);
    49. World world = plugin.getServer().getWorld("Overhang");
    50. new Location(world, -5, 2, 65);
    51. plugin.getConfig().set(pl, "blue");
    52. plugin.saveConfig();
    53. } else if (red.size() < blue.size()){
    54. red.add(pl);
    55. World world = plugin.getServer().getWorld("Overhang");
    56. new Location(world, -44, 4, 40);
    57. plugin.getConfig().set(pl, "red");
    58. plugin.saveConfig();
    59. } else {
    60. Integer team = new Random().nextInt(2);
    61. if (team == 1){
    62. red.add(pl);
    63. World world = plugin.getServer().getWorld("Overhang");
    64. new Location(world, -44, 4, 40);
    65. plugin.getConfig().set(pl, "red");
    66. plugin.saveConfig();
    67. } else {
    68. blue.add(pl);
    69. World world = plugin.getServer().getWorld("Overhang");
    70. new Location(world, -5, 2, 65);
    71. plugin.getConfig().set(pl, "blue");
    72. plugin.saveConfig();
    73. }
    74. }
    75. } else if (args[1].equalsIgnoreCase("polarbearclub")) {
    76. if (red.size() > blue.size()){
    77. blue.add(pl);
    78. World world = plugin.getServer().getWorld("Polar Bear Club");
    79. new Location(world, 735, 4, -548);
    80. plugin.getConfig().set(pl, "blue");
    81. plugin.saveConfig();
    82. } else if (red.size() < blue.size()){
    83. red.add(pl);
    84. World world = plugin.getServer().getWorld("Polar Bear Club");
    85. new Location(world, 796, 4, -548);
    86. plugin.getConfig().set(pl, "red");
    87. plugin.saveConfig();
    88. } else {
    89. Integer team = new Random().nextInt(2);
    90. if (team == 1){
    91. red.add(pl);
    92. World world = plugin.getServer().getWorld("Polar Bear Club");
    93. new Location(world, 796, 4, -548);
    94. plugin.getConfig().set(pl, "red");
    95. plugin.saveConfig();
    96. } else {
    97. blue.add(pl);
    98. World world = plugin.getServer().getWorld("Polar Bear Club");
    99. new Location(world, 735, 4, -548);
    100. plugin.getConfig().set(pl, "blue");
    101. plugin.saveConfig();
    102. }
    103. }
    104. } else if (args[1].equalsIgnoreCase("twistedfate")) {
    105. if (red.size() > blue.size()){
    106. blue.add(pl);
    107. World world = plugin.getServer().getWorld("Twisted Fate");
    108. new Location(world, -26, 108, 68);
    109. plugin.getConfig().set(pl, "blue");
    110. plugin.saveConfig();
    111. } else if (red.size() < blue.size()){
    112. red.add(pl);
    113. World world = plugin.getServer().getWorld("Twisted Fate");
    114. new Location(world, -30, 80, -19);
    115. plugin.getConfig().set(pl, "red");
    116. plugin.saveConfig();
    117. } else {
    118. Integer team = new Random().nextInt(2);
    119. if (team == 1){
    120. red.add(pl);
    121. World world = plugin.getServer().getWorld("Twisted Fate");
    122. new Location(world, -30, 80, -19);
    123. plugin.getConfig().set(pl, "red");
    124. plugin.saveConfig();
    125. } else {
    126. blue.add(pl);
    127. World world = plugin.getServer().getWorld("Twisted Fate");
    128. new Location(world, -26, 108, 68);
    129. plugin.getConfig().set(pl, "blue");
    130. plugin.saveConfig();
    131. }
    132. }
    133. } else if (args[1].equalsIgnoreCase("wr")) {
    134. if (red.size() > blue.size()){
    135. blue.add(pl);
    136. World world = plugin.getServer().getWorld("Wizard's Retreat");
    137. new Location(world, 239, 63, 1359);
    138. plugin.getConfig().set(pl, "blue");
    139. plugin.saveConfig();
    140. } else if (red.size() < blue.size()){
    141. red.add(pl);
    142. World world = plugin.getServer().getWorld("Wizard's Retreat");
    143. new Location(world, 166, 66, 1372);
    144. plugin.getConfig().set(pl, "red");
    145. plugin.saveConfig();
    146. } else {
    147. Integer team = new Random().nextInt(2);
    148. if (team == 1){
    149. red.add(pl);
    150. World world = plugin.getServer().getWorld("Wizard's Retreat");
    151. new Location(world, 796, 4, -548);
    152. plugin.getConfig().set(pl, "red");
    153. plugin.saveConfig();
    154. } else {
    155. blue.add(pl);
    156. World world = plugin.getServer().getWorld("Wizard's Retreat");
    157. new Location(world, 735, 4, -548);
    158. plugin.getConfig().set(pl, "blue");
    159. plugin.saveConfig();
    160. }
    161. }
    162. } else if (args[1].equalsIgnoreCase("kaldr")) {
    163. if (red.size() > blue.size()){
    164. blue.add(pl);
    165. World world = plugin.getServer().getWorld("Kaldr");
    166. new Location(world, -1125, 4, 793);
    167. plugin.getConfig().set(pl, "blue");
    168. plugin.saveConfig();
    169. } else if (red.size() < blue.size()){
    170. red.add(pl);
    171. World world = plugin.getServer().getWorld("Kaldr");
    172. new Location(world, -1142, 4, 762);
    173. plugin.getConfig().set(pl, "red");
    174. plugin.saveConfig();
    175. } else {
    176. Integer team = new Random().nextInt(2);
    177. if (team == 1){
    178. red.add(pl);
    179. World world = plugin.getServer().getWorld("Kaldr");
    180. new Location(world, -1142, 4, 762);
    181. plugin.getConfig().set(pl, "red");
    182. plugin.saveConfig();
    183. } else {
    184. blue.add(pl);
    185. World world = plugin.getServer().getWorld("Kaldr");
    186. new Location(world, -1125, 4, 793);
    187. plugin.getConfig().set(pl, "blue");
    188. plugin.saveConfig();
    189. }
    190. }
    191. } else {
    192. p.sendMessage(ChatColor.DARK_RED + "That arena doesn't exist!");
    193. }
    194. } else if (args[0].equalsIgnoreCase("kit")) {
    195. if (args[1].equalsIgnoreCase("darkknight")) { /* VIP */
    196. if (p.hasPermission("gamemodes.vip")) {
    197. p.getInventory().clear();
    198. plugin.givePlayerDN(p, pl);
    199. plugin.getConfig().getStringList("DN").add(pl);
    200. } else {
    201. p.sendMessage(ChatColor.DARK_RED + "You don't have permissions. Get VIP on our website!");
    202. }
    203. } else if (args[1].equalsIgnoreCase("joker")) {
    204. p.getInventory().clear();
    205. plugin.givePlayerJ(p, pl);
    206. plugin.getConfig().getStringList("J").add(pl);
    207. plugin.saveConfig();
    208. } else if (args[1].equalsIgnoreCase("manofsteel")) {
    209. p.getInventory().clear();
    210. plugin.givePlayerMS(p, pl);
    211. plugin.getConfig().getStringList("MS").add(pl);
    212. plugin.saveConfig();
    213. } else if (args[1].equalsIgnoreCase("flash")) {
    214. p.getInventory().clear();
    215. plugin.givePlayerF(p, pl);
    216. plugin.getConfig().getStringList("F").add(pl);
    217. plugin.saveConfig();
    218. } else if (args[1].equalsIgnoreCase("doomsday")) { /* VIP */
    219. if (p.hasPermission("gamemodes.vip")) {
    220. p.getInventory().clear();
    221. plugin.givePlayerD(p, pl);
    222. plugin.getConfig().getStringList("D").add(pl);
    223. plugin.saveConfig();
    224. } else {
    225. p.sendMessage(ChatColor.DARK_RED + "You don't have permissions. Get VIP on our website!");
    226. }
    227. } else if (args[1].equalsIgnoreCase("firebrand")) {
    228. p.getInventory().clear();
    229. plugin.givePlayerFB(p, pl);
    230. plugin.getConfig().getStringList("FB").add(pl);
    231. plugin.saveConfig();
    232. } else if (args[1].equalsIgnoreCase("harveyjones")) { /* VIP */
    233. if (p.hasPermission("gamemodes.vip")) {
    234. p.getInventory().clear();
    235. plugin.givePlayerHJ(p, pl);
    236. plugin.getConfig().getStringList("HJ").add(pl);
    237. plugin.saveConfig();
    238. } else {
    239. p.sendMessage(ChatColor.DARK_RED + "You don't have permissions. Get VIP on our website!");
    240. }
    241. } else if (args[1].equalsIgnoreCase("wonderwoman")) { /* VIP */
    242. if (p.hasPermission("gamemodes.vip")) {
    243. p.getInventory().clear();
    244. plugin.givePlayerWW(p, pl);
    245. plugin.getConfig().getStringList("WW").add(pl);
    246. plugin.saveConfig();
    247. } else {
    248. p.sendMessage(ChatColor.DARK_RED + "You don't have permissions. Get VIP on our website!");
    249. }
    250. } else if (args[1].equalsIgnoreCase("deathstroke")) { /* VIP */
    251. if (p.hasPermission("gamemodes.vip")) {
    252. p.getInventory().clear();
    253. plugin.givePlayerDS(p, pl);
    254. plugin.getConfig().getStringList("DS").add(pl);
    255. plugin.saveConfig();
    256. } else {
    257. p.sendMessage(ChatColor.DARK_RED + "You don't have permissions. Get VIP on our website!");
    258. }
    259. } else if (args[1].equalsIgnoreCase("specter")) {
    260. p.getInventory().clear();
    261. plugin.givePlayerS(p, pl);
    262. plugin.getConfig().getStringList("S").add(pl);
    263. plugin.saveConfig();
    264. } else if (args[1].equalsIgnoreCase("beastboy")) {
    265. p.getInventory().clear();
    266. plugin.givePlayerBB(p, pl);
    267. plugin.getConfig().getStringList("BB").add(pl);
    268. plugin.saveConfig();
    269. } else if (args[1].equalsIgnoreCase("shazam")) { /* VIP */
    270. if (p.hasPermission("gamemodes.vip")) {
    271. p.getInventory().clear();
    272. plugin.givePlayerSH(p, pl);
    273. plugin.getConfig().getStringList("SH").add(pl);
    274. plugin.saveConfig();
    275. } else {
    276. p.sendMessage(ChatColor.DARK_RED + "You don't have permissions. Get VIP on our website!");
    277. }
    278. } else {
    279. p.sendMessage(ChatColor.DARK_RED + "That kit doesn't exist! Do /pvp list to see what kits there are.");
    280. }
    281. } else {
    282.  
    283. }
    284. } else if (args.length == 1) {
    285. if (args[0].equalsIgnoreCase("list")) {
    286. String messageHeader = "&b-&a=&b-&a=&b-&a=&e Kits &a=&b-&a=&b-&a=&b-";
    287. p.sendMessage(messageHeader.replaceAll("(&([a-f0-9]))", "\u00A7$2"));
    288. p.sendMessage(ChatColor.DARK_RED + "Free:");
    289. p.sendMessage(ChatColor.RED + "Gems Required:");
    290. p.sendMessage(ChatColor.LIGHT_PURPLE + "VIP Required:");
    291. } else if (args[0].equalsIgnoreCase("help")) {
    292. String message1 = "&b-&a=&b-&a=&b-&a=&eSlave Help&a=&b-&a=&b-&a=&b-";
    293. String message2 = "&2/class choose <classname> &f- &dChoose your class";
    294. String message3 = "&3/class list &f- &6List all the classes";
    295. String message4 = "&a/class kit &f- &cGive's you the kit for your class";
    296. String message5 = "&4/class help &f- &eShows you this help menu";
    297. sender.sendMessage(message1.replaceAll("(&([a-f0-9]))", "\u00A7$2"));
    298. sender.sendMessage(message2.replaceAll("(&([a-f0-9]))", "\u00A7$2"));
    299. sender.sendMessage(message3.replaceAll("(&([a-f0-9]))", "\u00A7$2"));
    300. sender.sendMessage(message4.replaceAll("(&([a-f0-9]))", "\u00A7$2"));
    301. sender.sendMessage(message5.replaceAll("(&([a-f0-9]))", "\u00A7$2"));
    302. } else if (args[0].equalsIgnoreCase("kit")) {
    303. } else {
    304. sender.sendMessage(ChatColor.RED + "Do /pvp help for the help menu.");
    305. }
    306. } else {
    307. sender.sendMessage(ChatColor.RED + "Do /pvp help for the help menu.");
    308. }
    309. } else {
    310. sender.sendMessage(ChatColor.DARK_RED + "You do not have permission!");
    311. }
    312. return true;
    313. }
    314. return false;
    315. }
    316. }
    317.  
     
  5. You got too do

    before you do saveConfig();
    Cfg.options().copyDefaults(true);
     
  6. Offline

    Bammerbom

    boss86741
    The: "getConfig().load("config.yml");"
    does not good work. Use copyDefaults.
     
  7. Offline

    boss86741

    Jhtzb Now it is complaining about Red and Blue.

    Code:
    13.09 18:34:37 [Server] INFO at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:582)
    13.09 18:34:37 [Server] INFO at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java:391)
    13.09 18:34:37 [Server] INFO at net.minecraft.server.v1_6_R2.DedicatedServer.init(DedicatedServer.java:151)
    13.09 18:34:37 [Server] INFO at net.minecraft.server.v1_6_R2.MinecraftServer.a(MinecraftServer.java:250)
    13.09 18:34:37 [Server] INFO at net.minecraft.server.v1_6_R2.MinecraftServer.f(MinecraftServer.java:290)
    13.09 18:34:37 [Server] INFO at net.minecraft.server.v1_6_R2.MinecraftServer.l(MinecraftServer.java:313)
    13.09 18:34:37 [Server] INFO at org.bukkit.craftbukkit.v1_6_R2.CraftServer.enablePlugins(CraftServer.java:264)
    13.09 18:34:37 [Server] INFO at org.bukkit.craftbukkit.v1_6_R2.CraftServer.loadPlugin(CraftServer.java:282)
    13.09 18:34:37 [Server] INFO at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:381)
    13.09 18:34:37 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:457)
    13.09 18:34:37 [Server] INFO at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217)
    13.09 18:34:37 [Server] INFO at com.boss86741.plugins.gamemodes.Gamemodes.onEnable(Gamemodes.java:53)
    13.09 18:34:37 [Server] INFO at com.boss86741.plugins.gamemodes.Commands.<init>(Commands.java:26)
    13.09 18:34:37 [Server] INFO java.lang.NullPointerException
    13.09 18:34:37 [Server] SEVERE Error occurred while enabling Gamemodes v1.0 (Is it up to date?)
     
  8. Offline

    boss86741

    Please, someone!
     
  9. Offline

    ferrybig

    Ma I get your updated code, the last code your posted haves the config stuff on line 53, and not the creating of the command class. and may I see your command class?
     
  10. Offline

    boss86741

    ferrybig

    Gamemodes.java:
    Show Spoiler

    Code:java
    1. package com.boss86741.plugins.gamemodes;
    2.  
    3. import org.bukkit.Color;
    4. import org.bukkit.Material;
    5. import org.bukkit.enchantments.Enchantment;
    6. import org.bukkit.entity.Player;
    7. import org.bukkit.inventory.EntityEquipment;
    8. import org.bukkit.inventory.ItemStack;
    9. import org.bukkit.inventory.meta.ItemMeta;
    10. import org.bukkit.inventory.meta.LeatherArmorMeta;
    11. import org.bukkit.plugin.java.JavaPlugin;
    12. import org.bukkit.potion.PotionEffect;
    13. import org.bukkit.potion.PotionEffectType;
    14.  
    15. public class Gamemodes extends JavaPlugin {
    16.  
    17. @Override
    18. public void onEnable() {
    19. getLogger().info("Enabled.");
    20.  
    21. getConfig().addDefault("DN", "");
    22. getConfig().addDefault("J", "");
    23. getConfig().addDefault("MS", "");
    24. getConfig().addDefault("F", "");
    25. getConfig().addDefault("D", "");
    26. getConfig().addDefault("FB", "");
    27. getConfig().addDefault("HJ", "");
    28. getConfig().addDefault("WW", "");
    29. getConfig().addDefault("DS", "");
    30. getConfig().addDefault("S", "");
    31. getConfig().addDefault("BB", "");
    32. getConfig().addDefault("SH", "");
    33.  
    34. getConfig().addDefault("w1", "");
    35. getConfig().addDefault("w2", "");
    36. getConfig().addDefault("w3", "");
    37. getConfig().addDefault("w4", "");
    38. getConfig().addDefault("w5", "");
    39.  
    40. getConfig().addDefault("1", "");
    41. getConfig().addDefault("2", "");
    42. getConfig().addDefault("3", "");
    43. getConfig().addDefault("4", "");
    44. getConfig().addDefault("5", "");
    45.  
    46. getConfig().addDefault("red", "");
    47. getConfig().addDefault("blue", "");
    48.  
    49. getConfig().options().copyDefaults(true);
    50.  
    51. saveConfig();
    52.  
    53. Commands c = new Commands(this);
    54. getCommand("pvp").setExecutor(c);
    55.  
    56. getServer().getPluginManager().registerEvents(new Events(this), this);
    57.  
    58. /* int world1 = plugin.getServer().getWorld("Overhang").getPlayers().size();
    59. String w1 = Integer.toString(world1);
    60.  
    61. int world2 = plugin.getServer().getWorld("Polar Bear Club").getPlayers().size();
    62. String w2 = Integer.toString(world2);
    63.  
    64. int world3 = plugin.getServer().getWorld("Twisted Fate").getPlayers().size();
    65. String w3 = Integer.toString(world3);
    66.  
    67. int world4 = plugin.getServer().getWorld("WisardsRetreat").getPlayers().size();
    68. String w4 = Integer.toString(world4);
    69.  
    70. int world5 = plugin.getServer().getWorld("Kaldr").getPlayers().size();
    71. String w5 = Integer.toString(world5); */
    72. }
    73.  
    74. // Below are the kits.
    75.  



    Commands.java:
    Show Spoiler

    Code:java
    1. package com.boss86741.plugins.gamemodes;
    2.  
    3. import java.util.List;
    4. import java.util.Random;
    5.  
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.Location;
    8. import org.bukkit.World;
    9. import org.bukkit.command.Command;
    10. import org.bukkit.command.CommandExecutor;
    11. import org.bukkit.command.CommandSender;
    12. import org.bukkit.entity.Player;
    13.  
    14. public class Commands implements CommandExecutor {
    15.  
    16. private Gamemodes plugin;
    17.  
    18. public Commands(Gamemodes plugin) {
    19. this.plugin = plugin;
    20. }
    21.  
    22. //public int getPlayerGems(Player p, String pl) {
    23. //return plugin.getConfig().getInt(pl);
    24. //}
    25.  
    26. List<String> red = plugin.getConfig().getStringList("red");
    27. List<String> blue = plugin.getConfig().getStringList("blue");
    28.  
    29. public List<String> getRed() {
    30. return red;
    31. }
    32.  
    33. public List<String> getBlue() {
    34. return blue;
    35. }
    36.  
    37. @Override
    38. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    39. Player p = (Player) sender;
    40. String pl = p.getName();
    41.  
    42. if (cmd.getName().equalsIgnoreCase("pvp")) {
    43. if (p.hasPermission("gamemodes.user")) {
    44. if (args.length == 2) {
    45. if (args[0].equalsIgnoreCase("join")) { // Blue = team 1 ; Red = team 2
    46. if (args[1].equalsIgnoreCase("overhang")) {
    47. if (red.size() > blue.size()){
    48. blue.add(pl);
    49. World world = plugin.getServer().getWorld("Overhang");
    50. new Location(world, -5, 2, 65);
    51. plugin.getConfig().set(pl, "blue");
    52. plugin.saveConfig();
    53. } else if (red.size() < blue.size()){
    54. red.add(pl);
    55. World world = plugin.getServer().getWorld("Overhang");
    56. new Location(world, -44, 4, 40);
    57. plugin.getConfig().set(pl, "red");
    58. plugin.saveConfig();
    59. } else {
    60. Integer team = new Random().nextInt(2);
    61. if (team == 1){
    62. red.add(pl);
    63. World world = plugin.getServer().getWorld("Overhang");
    64. new Location(world, -44, 4, 40);
    65. plugin.getConfig().set(pl, "red");
    66. plugin.saveConfig();
    67. } else {
    68. blue.add(pl);
    69. World world = plugin.getServer().getWorld("Overhang");
    70. new Location(world, -5, 2, 65);
    71. plugin.getConfig().set(pl, "blue");
    72. plugin.saveConfig();
    73. }
    74. }
    75. } else if (args[1].equalsIgnoreCase("polarbearclub")) {
    76. if (red.size() > blue.size()){
    77. blue.add(pl);
    78. World world = plugin.getServer().getWorld("Polar Bear Club");
    79. new Location(world, 735, 4, -548);
    80. plugin.getConfig().set(pl, "blue");
    81. plugin.saveConfig();
    82. } else if (red.size() < blue.size()){
    83. red.add(pl);
    84. World world = plugin.getServer().getWorld("Polar Bear Club");
    85. new Location(world, 796, 4, -548);
    86. plugin.getConfig().set(pl, "red");
    87. plugin.saveConfig();
    88. } else {
    89. Integer team = new Random().nextInt(2);
    90. if (team == 1){
    91. red.add(pl);
    92. World world = plugin.getServer().getWorld("Polar Bear Club");
    93. new Location(world, 796, 4, -548);
    94. plugin.getConfig().set(pl, "red");
    95. plugin.saveConfig();
    96. } else {
    97. blue.add(pl);
    98. World world = plugin.getServer().getWorld("Polar Bear Club");
    99. new Location(world, 735, 4, -548);
    100. plugin.getConfig().set(pl, "blue");
    101. plugin.saveConfig();
    102. }
    103. }
    104. } else if (args[1].equalsIgnoreCase("twistedfate")) {
    105. if (red.size() > blue.size()){
    106. blue.add(pl);
    107. World world = plugin.getServer().getWorld("Twisted Fate");
    108. new Location(world, -26, 108, 68);
    109. plugin.getConfig().set(pl, "blue");
    110. plugin.saveConfig();
    111. } else if (red.size() < blue.size()){
    112. red.add(pl);
    113. World world = plugin.getServer().getWorld("Twisted Fate");
    114. new Location(world, -30, 80, -19);
    115. plugin.getConfig().set(pl, "red");
    116. plugin.saveConfig();
    117. } else {
    118. Integer team = new Random().nextInt(2);
    119. if (team == 1){
    120. red.add(pl);
    121. World world = plugin.getServer().getWorld("Twisted Fate");
    122. new Location(world, -30, 80, -19);
    123. plugin.getConfig().set(pl, "red");
    124. plugin.saveConfig();
    125. } else {
    126. blue.add(pl);
    127. World world = plugin.getServer().getWorld("Twisted Fate");
    128. new Location(world, -26, 108, 68);
    129. plugin.getConfig().set(pl, "blue");
    130. plugin.saveConfig();
    131. }
    132. }
    133. } else if (args[1].equalsIgnoreCase("wr")) {
    134. if (red.size() > blue.size()){
    135. blue.add(pl);
    136. World world = plugin.getServer().getWorld("Wizard's Retreat");
    137. new Location(world, 239, 63, 1359);
    138. plugin.getConfig().set(pl, "blue");
    139. plugin.saveConfig();
    140. } else if (red.size() < blue.size()){
    141. red.add(pl);
    142. World world = plugin.getServer().getWorld("Wizard's Retreat");
    143. new Location(world, 166, 66, 1372);
    144. plugin.getConfig().set(pl, "red");
    145. plugin.saveConfig();
    146. } else {
    147. Integer team = new Random().nextInt(2);
    148. if (team == 1){
    149. red.add(pl);
    150. World world = plugin.getServer().getWorld("Wizard's Retreat");
    151. new Location(world, 796, 4, -548);
    152. plugin.getConfig().set(pl, "red");
    153. plugin.saveConfig();
    154. } else {
    155. blue.add(pl);
    156. World world = plugin.getServer().getWorld("Wizard's Retreat");
    157. new Location(world, 735, 4, -548);
    158. plugin.getConfig().set(pl, "blue");
    159. plugin.saveConfig();
    160. }
    161. }
    162. } else if (args[1].equalsIgnoreCase("kaldr")) {
    163. if (red.size() > blue.size()){
    164. blue.add(pl);
    165. World world = plugin.getServer().getWorld("Kaldr");
    166. new Location(world, -1125, 4, 793);
    167. plugin.getConfig().set(pl, "blue");
    168. plugin.saveConfig();
    169. } else if (red.size() < blue.size()){
    170. red.add(pl);
    171. World world = plugin.getServer().getWorld("Kaldr");
    172. new Location(world, -1142, 4, 762);
    173. plugin.getConfig().set(pl, "red");
    174. plugin.saveConfig();
    175. } else {
    176. Integer team = new Random().nextInt(2);
    177. if (team == 1){
    178. red.add(pl);
    179. World world = plugin.getServer().getWorld("Kaldr");
    180. new Location(world, -1142, 4, 762);
    181. plugin.getConfig().set(pl, "red");
    182. plugin.saveConfig();
    183. } else {
    184. blue.add(pl);
    185. World world = plugin.getServer().getWorld("Kaldr");
    186. new Location(world, -1125, 4, 793);
    187. plugin.getConfig().set(pl, "blue");
    188. plugin.saveConfig();
    189. }
    190. }
    191. } else {
    192. p.sendMessage(ChatColor.DARK_RED + "That arena doesn't exist!");
    193. }
    194. } else if (args[0].equalsIgnoreCase("kit")) {
    195. if (args[1].equalsIgnoreCase("darkknight")) { /* VIP */
    196. if (p.hasPermission("gamemodes.vip")) {
    197. p.getInventory().clear();
    198. plugin.givePlayerDN(p, pl);
    199. plugin.getConfig().getStringList("DN").add(pl);
    200. } else {
    201. p.sendMessage(ChatColor.DARK_RED + "You don't have permissions. Get VIP on our website!");
    202. }
    203. } else if (args[1].equalsIgnoreCase("joker")) {
    204. p.getInventory().clear();
    205. plugin.givePlayerJ(p, pl);
    206. plugin.getConfig().getStringList("J").add(pl);
    207. plugin.saveConfig();
    208. } else if (args[1].equalsIgnoreCase("manofsteel")) {
    209. p.getInventory().clear();
    210. plugin.givePlayerMS(p, pl);
    211. plugin.getConfig().getStringList("MS").add(pl);
    212. plugin.saveConfig();
    213. } else if (args[1].equalsIgnoreCase("flash")) {
    214. p.getInventory().clear();
    215. plugin.givePlayerF(p, pl);
    216. plugin.getConfig().getStringList("F").add(pl);
    217. plugin.saveConfig();
    218. } else if (args[1].equalsIgnoreCase("doomsday")) { /* VIP */
    219. if (p.hasPermission("gamemodes.vip")) {
    220. p.getInventory().clear();
    221. plugin.givePlayerD(p, pl);
    222. plugin.getConfig().getStringList("D").add(pl);
    223. plugin.saveConfig();
    224. } else {
    225. p.sendMessage(ChatColor.DARK_RED + "You don't have permissions. Get VIP on our website!");
    226. }
    227. } else if (args[1].equalsIgnoreCase("firebrand")) {
    228. p.getInventory().clear();
    229. plugin.givePlayerFB(p, pl);
    230. plugin.getConfig().getStringList("FB").add(pl);
    231. plugin.saveConfig();
    232. } else if (args[1].equalsIgnoreCase("harveyjones")) { /* VIP */
    233. if (p.hasPermission("gamemodes.vip")) {
    234. p.getInventory().clear();
    235. plugin.givePlayerHJ(p, pl);
    236. plugin.getConfig().getStringList("HJ").add(pl);
    237. plugin.saveConfig();
    238. } else {
    239. p.sendMessage(ChatColor.DARK_RED + "You don't have permissions. Get VIP on our website!");
    240. }
    241. } else if (args[1].equalsIgnoreCase("wonderwoman")) { /* VIP */
    242. if (p.hasPermission("gamemodes.vip")) {
    243. p.getInventory().clear();
    244. plugin.givePlayerWW(p, pl);
    245. plugin.getConfig().getStringList("WW").add(pl);
    246. plugin.saveConfig();
    247. } else {
    248. p.sendMessage(ChatColor.DARK_RED + "You don't have permissions. Get VIP on our website!");
    249. }
    250. } else if (args[1].equalsIgnoreCase("deathstroke")) { /* VIP */
    251. if (p.hasPermission("gamemodes.vip")) {
    252. p.getInventory().clear();
    253. plugin.givePlayerDS(p, pl);
    254. plugin.getConfig().getStringList("DS").add(pl);
    255. plugin.saveConfig();
    256. } else {
    257. p.sendMessage(ChatColor.DARK_RED + "You don't have permissions. Get VIP on our website!");
    258. }
    259. } else if (args[1].equalsIgnoreCase("specter")) {
    260. p.getInventory().clear();
    261. plugin.givePlayerS(p, pl);
    262. plugin.getConfig().getStringList("S").add(pl);
    263. plugin.saveConfig();
    264. } else if (args[1].equalsIgnoreCase("beastboy")) {
    265. p.getInventory().clear();
    266. plugin.givePlayerBB(p, pl);
    267. plugin.getConfig().getStringList("BB").add(pl);
    268. plugin.saveConfig();
    269. } else if (args[1].equalsIgnoreCase("shazam")) { /* VIP */
    270. if (p.hasPermission("gamemodes.vip")) {
    271. p.getInventory().clear();
    272. plugin.givePlayerSH(p, pl);
    273. plugin.getConfig().getStringList("SH").add(pl);
    274. plugin.saveConfig();
    275. } else {
    276. p.sendMessage(ChatColor.DARK_RED + "You don't have permissions. Get VIP on our website!");
    277. }
    278. } else {
    279. p.sendMessage(ChatColor.DARK_RED + "That kit doesn't exist! Do /pvp list to see what kits there are.");
    280. }
    281. } else {
    282.  
    283. }
    284. } else if (args.length == 1) {
    285. if (args[0].equalsIgnoreCase("list")) {
    286. String messageHeader = "&b-&a=&b-&a=&b-&a=&e Kits &a=&b-&a=&b-&a=&b-";
    287. p.sendMessage(messageHeader.replaceAll("(&([a-f0-9]))", "\u00A7$2"));
    288. p.sendMessage(ChatColor.DARK_RED + "Free:");
    289. p.sendMessage(ChatColor.RED + "Gems Required:");
    290. p.sendMessage(ChatColor.LIGHT_PURPLE + "VIP Required:");
    291. } else if (args[0].equalsIgnoreCase("help")) {
    292. String message1 = "&b-&a=&b-&a=&b-&a=&eSlave Help&a=&b-&a=&b-&a=&b-";
    293. String message2 = "&2/class choose <classname> &f- &dChoose your class";
    294. String message3 = "&3/class list &f- &6List all the classes";
    295. String message4 = "&a/class kit &f- &cGive's you the kit for your class";
    296. String message5 = "&4/class help &f- &eShows you this help menu";
    297. sender.sendMessage(message1.replaceAll("(&([a-f0-9]))", "\u00A7$2"));
    298. sender.sendMessage(message2.replaceAll("(&([a-f0-9]))", "\u00A7$2"));
    299. sender.sendMessage(message3.replaceAll("(&([a-f0-9]))", "\u00A7$2"));
    300. sender.sendMessage(message4.replaceAll("(&([a-f0-9]))", "\u00A7$2"));
    301. sender.sendMessage(message5.replaceAll("(&([a-f0-9]))", "\u00A7$2"));
    302. } else if (args[0].equalsIgnoreCase("kit")) {
    303. } else {
    304. sender.sendMessage(ChatColor.RED + "Do /pvp help for the help menu.");
    305. }
    306. } else {
    307. sender.sendMessage(ChatColor.RED + "Do /pvp help for the help menu.");
    308. }
    309. } else {
    310. sender.sendMessage(ChatColor.DARK_RED + "You do not have permission!");
    311. }
    312. return true;
    313. }
    314. return false;
    315. }
    316. }
    317.  

     
  11. Offline

    uyuyuy99

    boss86741 It's because in Commands.java, you're using the "plugin" object before you initialize it, so it throws a NPE. Instead of this:
    Code:java
    1. private Gamemodes plugin;
    2.  
    3. public Commands(Gamemodes plugin) {
    4. this.plugin = plugin;
    5. }
    6.  
    7. List<String> red = plugin.getConfig().getStringList("red");
    8. List<String> blue = plugin.getConfig().getStringList("blue");
    Try this:
    Code:java
    1. private Gamemodes plugin;
    2.  
    3. public Commands(Gamemodes plugin) {
    4. this.plugin = plugin;
    5. red = plugin.getConfig().getStringList("red");
    6. blue = plugin.getConfig().getStringList("blue");
    7. }
    8.  
    9. List<String> red;
    10. List<String> blue;
     
Thread Status:
Not open for further replies.

Share This Page