How come my kit pvp plugin doesn't work?

Discussion in 'Plugin Development' started by Matroix7, Jan 15, 2014.

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

    Matroix7

    Here is my code (Don't steal it)
    Code:java
    1. package me.Ivan.Kits;
    2.  
    3. import java.io.File;
    4. import java.io.IOException;
    5.  
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.configuration.file.FileConfiguration;
    10. import org.bukkit.entity.Player;
    11. import org.bukkit.inventory.ItemStack;
    12. import org.bukkit.plugin.java.JavaPlugin;
    13.  
    14. public class Kits extends JavaPlugin{
    15.  
    16. public void onEnable() {
    17. saveConfig();
    18. try {
    19. setupConfig(getConfig());
    20. } catch (IOException e) {
    21. e.printStackTrace();
    22. }
    23. }
    24.  
    25. @SuppressWarnings("deprecation")
    26. public boolean onCommand(CommandSender sender, Command command,
    27. String commandLabel, String[] args) {
    28. if(commandLabel.equalsIgnoreCase("kits")) {
    29. if(sender instanceof Player){
    30. Player player = (Player) sender;
    31. if(args.length == 0) {
    32. String[] classes = getConfig().getString("Kit.Names")
    33. .split(",");
    34. for(String s : classes){
    35. if(s != null) {
    36. player.sendMessage("[" + ChatColor.AQUA + s + ChatColor.WHITE + "] " + ChatColor.GRAY + ": " + ChatColor.DARK_GRAY + "You have gotten the " + s + "Kit! ");
    37. }
    38. }
    39. }else {
    40. for(String s : getConfig().getConfigurationSection("Kits")
    41. .getKeys(false)) {
    42. if(args[0].equalsIgnoreCase("s")) {
    43. player.getInventory().clear();
    44. try {
    45. String items = getConfig().getString(
    46. "Kits." + s + ".Items");
    47. String[] indiItems = items.split(",");
    48.  
    49. for(String s1 : indiItems){
    50. String[] itemAmounts = s1.split("-");
    51. ItemStack item = new ItemStack(
    52. Integer.valueOf(itemAmounts[0]),
    53. Integer.valueOf(itemAmounts[1]));
    54. player.getInventory().addItem(item);
    55. }
    56. player.updateInventory();
    57. } catch(Exception e) {
    58. e.printStackTrace();
    59. }
    60. }
    61. }
    62. }
    63. }
    64. }
    65. return false;
    66. }
    67.  
    68. private void setupConfig(FileConfiguration config) throws IOException {
    69. if(!new File(getDataFolder(), "RESET.FILE").exists()){
    70. config.set("Kits.PvP.Items", "276-1,310-1,311-1,312-1,313-1,314-1,322:1-5");
    71.  
    72. config.set("Kits.Names", "PvP");
    73.  
    74. new File(getDataFolder(), "RESET.FILE").createNewFile();
    75. }
    76. }
    77. }
    78.  
     
  2. Offline

    MrInspector

    You shouldn't worry about people stealing it rather than you posted this in the wrong section. :p

    It's supposed to go into "Plugin Development".
     
  3. Offline

    Necrodoom

    Moo-ved to correct section.
     
    MrInspector likes this.
Thread Status:
Not open for further replies.

Share This Page