[HELP] Kit Plugin

Discussion in 'Plugin Development' started by Famous Guy, Nov 2, 2013.

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

    Famous Guy

    My plugin doesn't seem to work.
    Code:
    Code:java
    1. package me.Famous_Guy2.Kit;
    2.  
    3. import net.minecraft.server.v1_6_R3.PlayerInventory;
    4.  
    5. import org.bukkit.ChatColor;
    6. import org.bukkit.Material;
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.inventory.ItemStack;
    11. import org.bukkit.plugin.java.JavaPlugin;
    12.  
    13. public class Kit extends JavaPlugin {
    14.  
    15. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] arsg) {
    16. if (!(sender instanceof Player)) {
    17. sender.sendMessage(ChatColor.RED + "Only players can get kits!");
    18. return true;
    19. }
    20.  
    21. Player p = (Player) sender;
    22.  
    23. if (cmd.getName().equalsIgnoreCase("pvp")) {
    24. PlayerInventory pi = p.getInventory();
    25. pi.addItem(new ItemStack(Material.IRON_SWORD, 1));
    26. pi.addItem(new ItemStack(Material.BOW, 1));
    27. pi.addItem(new ItemStack(Material.ARROW, 64));
    28. pi.addItem(new ItemStack(Material.GOLDEN_APPLE, 64));
    29. pi.addItem(new ItemStack(Material.IRON_HELMET, 1));
    30. pi.addItem(new ItemStack(Material.IRON_CHESTPLATE, 1));
    31. pi.addItem(new ItemStack(Material.IRON_LEGGINGS, 1));
    32. pi.addItem(new ItemStack(Material.IRON_BOOTS, 1));
    33. }
    34.  
    35. if (cmd.getName().equalsIgnoreCase("Clearme")) {
    36. return true;
    37. }
    38.  
    39. }
    40.  

    Plugin.YML:
    Code:
    name: Kit
    version: 1.0
    main: me.Famous_Guy2.kit.Kit
    description: A very simple kit plugin.
     
    commands:
        pvp:
            usage: /<command>
            aliases: [kit]
            description: Get a pvp kit.
        Clearme:
            usage: /<command>
            aliases: [clearinventory, clearinv]
            description: Empty your inventory.
    Server Error:
    Code:
    02.11 18:02:08 [Server] INFO org.bukkit.plugin.InvalidPluginException: java.lang.ClassNotFoundException: me.Famous_Guy2.kit.Kit
    02.11 18:02:08 [Server] SEVERE Could not load 'plugins/Kit.jar' in folder 'plugins'
     
  2. Offline

    user_90854156

    Fix your plugin.yml
    It's supposed to be
    Code:
    main: me.Famous_Guy2.Kit.Kit
    See what you did wrong? :p
     
  3. Offline

    ChronicNinjaz

    Change your plugin.yml to
    Code:
    me.Famous_Guy2.Kit.Kit
    Lol MrTang Replayed at the same time XD

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

    Goblom

    Famous Guy I believe you are missing your onEnable()
     
  5. Offline

    Tss1410

    The server can not find the main class in your plugin.
    Java is Case-sensetive.
    The package is me.Famous_Guy2.Kit and the main class is Kit.
    Your main class in plugin.yml have to be me.Famous_Guy2.Kit.Kit
    With big "k"
     
  6. Offline

    clutchmasterman

    class:
    Code:java
    1. package [SIZE=12px][FONT=Consolas][COLOR=#f26100]me.Famous_Guy2.Kit[/COLOR][/FONT][/SIZE][SIZE=12px][FONT=Consolas][COLOR=#f26100];[/COLOR][/FONT][/SIZE]
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.Material;
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.inventory.ItemStack;
    9. import org.bukkit.plugin.java.JavaPlugin;
    10.  
    11. public class score extends JavaPlugin {
    12. public void onEnable() {
    13. getLogger().info("Hey Dood");
    14. }
    15.  
    16. public void onDisable() {
    17. getLogger().info("bye");
    18. }
    19.  
    20. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] arsg) {
    21. if (!(sender instanceof Player)) {
    22. sender.sendMessage(ChatColor.RED + "Only players can get kits!");
    23. return true;
    24. }
    25.  
    26. Player p = (Player) sender;
    27.  
    28. if (cmd.getName().equalsIgnoreCase("pvp")) {
    29. org.bukkit.inventory.PlayerInventory pi = p.getInventory();
    30. pi.addItem(new ItemStack(Material.IRON_SWORD, 1));
    31. pi.addItem(new ItemStack(Material.BOW, 1));
    32. pi.addItem(new ItemStack(Material.ARROW, 64));
    33. pi.addItem(new ItemStack(Material.GOLDEN_APPLE, 64));
    34. pi.addItem(new ItemStack(Material.IRON_HELMET, 1));
    35. pi.addItem(new ItemStack(Material.IRON_CHESTPLATE, 1));
    36. pi.addItem(new ItemStack(Material.IRON_LEGGINGS, 1));
    37. pi.addItem(new ItemStack(Material.IRON_BOOTS, 1));
    38. }
    39.  
    40. if (cmd.getName().equalsIgnoreCase("Clearme")) {
    41. return true;
    42. }
    43. return false;
    44. }
    45. }
    46.  


    plugin.yml:
    Code:
    name: Kit
    version: 1.0
    main: me.Famous_Guy2.kit.Kit
    description: A very simple kit plugin.
    commands:
        pvp:
          description:whatever
        Clearme:
     
  7. Offline

    kevinspl2000

    The first kit on the plugin.yml should start with a capital k :)
     
  8. Offline

    Drkmaster83

    You're not gonna like this...
    Code:
    main: me.Famous_Guy2.kit.Kit
    
    The package "me.Famous_Guy2.kit" does not exist, but the package "me.Famous_Guy2.Kit" does.
     
  9. Offline

    Famous Guy

    get this error while doing /PVP http://prntscr.com/21io9f

    ?

    I capitalized the k in the plugin.yml but I keep getting this error while doing the commands (/PVP, /Clearme) http://prntscr.com/21io9f

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

    Goblom

    Famous Guy
    Code:java
    1. public class Main extends JavaPlugin {
    2. public void onEnable() {
    3. //do stuff
    4. }
    5. }


    Famous Guy That image literally does nothing to help us... Post the stack trace of the error... (The random spam that comes up after you run the command)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  11. try this

    ItemStack Diamond_Sword = new ItemStack(Material.DIAMOND_SWORD, 1);
    ItemStack Golden_Appel = new ItemStack(Material.GOLDEN_APPLE, 3);
    ItemStack Bow = new ItemStack(Material.BOW, 1);
    ItemStack Arrow = new ItemStack(Material.ARROW, 280);
    ItemStack DIAMOND_HELMET = new ItemStack(Material.DIAMOND_HELMET, 1);
    ItemStack DIAMOND_CHESTPLATE = new ItemStack(Material.DIAMOND_CHESTPLATE, 1);
    ItemStack DIAMOND_LEGGINGS = new ItemStack(Material.DIAMOND_LEGGINGS, 1);
    ItemStack DIAMOND_BOOTS = new ItemStack(Material.DIAMOND_BOOTS, 1);
    PlayerInventory pi = player.getInventory();
    pi.setItem(0, Diamond_Sword);
    pi.setItem(1, Golden_Appel);
    pi.setItem(2, Bow);
    pi.setItem(3, Arrow);
    pi.setHelmet(DIAMOND_HELMET);
    pi.setBoots(DIAMOND_BOOTS);
    pi.setLeggings(DIAMOND_LEGGINGS);
    pi.setChestplate(DIAMOND_CHESTPLATE);

    that what i have in a plugin and this work for me
     
  12. Offline

    Drkmaster83

    Stack-trace?
     
  13. Offline

    Famous Guy

    Server Error when I do the commands.
    Code:
    2.11 18:56:25 [Server] INFO ... 15 more
    02.11 18:56:25 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
    02.11 18:56:25 [Server] INFO at me.Famous_Guy2.Kit.Kit.onCommand(Kit.java:26)
    02.11 18:56:25 [Server] INFO Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_6_R3.inventory.CraftInventoryPlayer cannot be cast to net.minecraft.server.v1_6_R3.PlayerInventory
    02.11 18:56:25 [Server] INFO at net.minecraft.server.v1_6_R3.ThreadServerApplication.run(SourceFile:583)
    02.11 18:56:25 [Server] INFO at net.minecraft.server.v1_6_R3.MinecraftServer.run(MinecraftServer.java:421)
    02.11 18:56:25 [Server] INFO at net.minecraft.server.v1_6_R3.MinecraftServer.s(MinecraftServer.java:488)
    02.11 18:56:25 [Server] INFO at net.minecraft.server.v1_6_R3.DedicatedServer.t(DedicatedServer.java:227)
    02.11 18:56:25 [Server] INFO at net.minecraft.server.v1_6_R3.MinecraftServer.t(MinecraftServer.java:592)
    02.11 18:56:25 [Server] INFO at net.minecraft.server.v1_6_R3.DedicatedServerConnection.b(SourceFile:30)
    02.11 18:56:25 [Server] INFO at net.minecraft.server.v1_6_R3.ServerConnection.b(SourceFile:37)
    02.11 18:56:25 [Server] INFO at net.minecraft.server.v1_6_R3.PlayerConnection.e(PlayerConnection.java:116)
    02.11 18:56:25 [Server] INFO at net.minecraft.server.v1_6_R3.NetworkManager.b(NetworkManager.java:296)
    02.11 18:56:25 [Server] INFO at net.minecraft.server.v1_6_R3.Packet3Chat.handle(SourceFile:49)
    02.11 18:56:25 [Server] INFO at net.minecraft.server.v1_6_R3.PlayerConnection.a(PlayerConnection.java:837)
    02.11 18:56:25 [Server] INFO at net.minecraft.server.v1_6_R3.PlayerConnection.chat(PlayerConnection.java:886)
    02.11 18:56:25 [Server] INFO at net.minecraft.server.v1_6_R3.PlayerConnection.handleCommand(PlayerConnection.java:968)
    02.11 18:56:25 [Server] INFO at org.bukkit.craftbukkit.v1_6_R3.CraftServer.dispatchCommand(CraftServer.java:528)
    02.11 18:56:25 [Server] INFO at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:192)
    02.11 18:56:25 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46)
    02.11 18:56:25 [Server] INFO org.bukkit.command.CommandException: Unhandled exception executing command 'pvp' in plugin Kit v1.0
    02.11 18:56:25 [Server] SEVERE null
     


  14. em
     
  15. Offline

    Famous Guy

    Tried this, Didn't work :c
     
  16. oke

    commands:
    pvp:
    usage: /<command>
    aliases: [kit]
    description: Get a pvp kit.

    try remove usage ?
    i can not read error's
    whether I should write about your plugin here and watch?

    i have copy you plugin and chance it and i have no error's

    name: evenhelpem
    version: 1.0
    main: me.dylanz21.helpen.help
    description: A very simple kit plugin.

    commands:
    pvp:
    description: Get a pvp kit.
    Clearme:
    description: Empty your inventory.

    package me.dylanz21.helpen;



    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.java.JavaPlugin;

    public class help extends JavaPlugin {

    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] arsg) {
    if (!(sender instanceof Player)) {
    sender.sendMessage(ChatColor.RED + "Only players can get kits!");
    return true;
    }

    Player p = (Player) sender;

    if (commandLabel.equalsIgnoreCase("pvp")) {
    org.bukkit.inventory.PlayerInventory pi = p.getInventory();
    pi.addItem(new ItemStack(Material.IRON_SWORD, 1));
    pi.addItem(new ItemStack(Material.BOW, 1));
    pi.addItem(new ItemStack(Material.ARROW, 64));
    pi.addItem(new ItemStack(Material.GOLDEN_APPLE, 64));
    pi.addItem(new ItemStack(Material.IRON_HELMET, 1));
    pi.addItem(new ItemStack(Material.IRON_CHESTPLATE, 1));
    pi.addItem(new ItemStack(Material.IRON_LEGGINGS, 1));
    pi.addItem(new ItemStack(Material.IRON_BOOTS, 1));

    return false;
    }

    if (commandLabel.equalsIgnoreCase("Clearme")) {

    }
    return true;
    }

    }

    that the code and it work by me

    have you skype than add i you

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

    Famous Guy

    Famous_Guy2
     
  18. Offline

    Goblom

    Famous Guy Here is your problem

    Code:
    02.11 18:56:25 [Server] INFO Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_6_R3.inventory.CraftInventoryPlayer cannot be cast to net.minecraft.server.v1_6_R3.PlayerInventory
     
  19. Offline

    Famous Guy

  20. i have change the plugin.yml and the commandLabel

    and this org.bukkit.inventory.PlayerInventory pi = p.getInventory();

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
Thread Status:
Not open for further replies.

Share This Page