"outdated" plugin error

Discussion in 'Plugin Development' started by joshua_coolteen, Sep 16, 2019.

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

    joshua_coolteen

    getting this error: Server thread/ERROR Error occurred while enabling EasyEnchant v1.0 (Is it up to date?)
    when i try to load this plugin:
    Code:
    package command;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.enchantments.Enchantment;
    import org.bukkit.entity.Player;
    
    import enchant.main;
    import net.md_5.bungee.api.ChatColor;
    
    public class cmd implements CommandExecutor{
      
        @SuppressWarnings("unused")
        private main plugin;
      
        public cmd(main plugin) {
            this.plugin = plugin;
            plugin.getCommand("ench").setExecutor(this);
        }
        public boolean onCommand(CommandSender sender, Command cmd, String labe,String args[],int arg[]) {
            if (!(sender instanceof Player)) {
                sender.sendMessage(ChatColor.RED + "Only a player may execute this command");
                return true;
            }
            Player plr = (Player) sender;
            org.bukkit.inventory.ItemStack item = plr.getInventory().getItemInMainHand();
            if (item == null) {
                plr.sendMessage(ChatColor.RED + "You must be holding an item!");
            return true;
            }
            plr.sendMessage(ChatColor.GREEN + "Item enchanted!");
            if (args[0].equalsIgnoreCase("prot")) {
                item.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, arg[1]);
            }
            if (args[0].equalsIgnoreCase("explosionprot")) {
                item.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, arg[1]);
            }
            if (args[0].equalsIgnoreCase("projectileprot")) {
                item.addEnchantment(Enchantment.PROTECTION_PROJECTILE, arg[1]);
            }
    
            if (args[0].equalsIgnoreCase("featherfalling")) {
                item.addEnchantment(Enchantment.PROTECTION_FALL, arg[1]);
            }
            if (args[0].equalsIgnoreCase("fireprot")) {
                item.addEnchantment(Enchantment.PROTECTION_FIRE, arg[1]);
            }
            if (args[0].equalsIgnoreCase("sharpness")) {
                item.addEnchantment(Enchantment.DAMAGE_ALL, arg[1]);
            }
            if (args[0].equalsIgnoreCase("bane")) {
                item.addEnchantment(Enchantment.DAMAGE_ARTHROPODS, arg[1]);
            }
            if (args[0].equalsIgnoreCase("smite")) {
                item.addEnchantment(Enchantment.DAMAGE_UNDEAD, arg[1]);
            }
            if (args[0].equalsIgnoreCase("power")) {
                item.addEnchantment(Enchantment.ARROW_DAMAGE, arg[1]);
            }
            if (args[0].equalsIgnoreCase("infinity")) {
                item.addEnchantment(Enchantment.ARROW_INFINITE, arg[1]);
            }
            if (args[0].equalsIgnoreCase("punch")) {
                item.addEnchantment(Enchantment.ARROW_KNOCKBACK, arg[1]);
            }
            if (args[0].equalsIgnoreCase("binding")) {
                item.addEnchantment(Enchantment.BINDING_CURSE, arg[1]);
            }
            if (args[0].equalsIgnoreCase("channeling")) {
                item.addEnchantment(Enchantment.CHANNELING, arg[1]);
            }
            if (args[0].equalsIgnoreCase("depthstrider")) {
                item.addEnchantment(Enchantment.DEPTH_STRIDER, arg[1]);
            }
            if (args[0].equalsIgnoreCase("haste")) {
                item.addEnchantment(Enchantment.DIG_SPEED, arg[1]);
            }
            if (args[0].equalsIgnoreCase("unbreaking")) {
                item.addEnchantment(Enchantment.DURABILITY, arg[1]);
            }
            if (args[0].equalsIgnoreCase("fireaspect")) {
                item.addEnchantment(Enchantment.FIRE_ASPECT, arg[1]);
            }
            if (args[0].equalsIgnoreCase("frostwalker")) {
                item.addEnchantment(Enchantment.FROST_WALKER, arg[1]);
            }
            if (args[0].equalsIgnoreCase("impaling")) {
                item.addEnchantment(Enchantment.IMPALING, arg[1]);
            }
            if (args[0].equalsIgnoreCase("fortune")) {
                item.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, arg[1]);
            }
            if (args[0].equalsIgnoreCase("looting")) {
                item.addEnchantment(Enchantment.LOOT_BONUS_MOBS, arg[1]);
            }
            if (args[0].equalsIgnoreCase("loyalty")) {
                item.addEnchantment(Enchantment.LOYALTY, arg[1]);
            }
            if (args[0].equalsIgnoreCase("luckofthesea")) {
                item.addEnchantment(Enchantment.LUCK, arg[1]);
            }
            if (args[0].equalsIgnoreCase("mending")) {
                item.addEnchantment(Enchantment.MENDING, arg[1]);
            }
            if (args[0].equalsIgnoreCase("multishot")) {
                item.addEnchantment(Enchantment.MULTISHOT, arg[1]);
            }
            if (args[0].equalsIgnoreCase("respiration")) {
                item.addEnchantment(Enchantment.OXYGEN, arg[1]);
            }
            if (args[0].equalsIgnoreCase("piercing")) {
                item.addEnchantment(Enchantment.PIERCING, arg[1]);
            }
            if (args[0].equalsIgnoreCase("quickcharge")) {
                item.addEnchantment(Enchantment.QUICK_CHARGE, arg[1]);
            }
            if (args[0].equalsIgnoreCase("riptide")) {
                item.addEnchantment(Enchantment.RIPTIDE, arg[1]);
            }
            if (args[0].equalsIgnoreCase("silktouch")) {
                item.addEnchantment(Enchantment.SILK_TOUCH, arg[1]);
            }
            if (args[0].equalsIgnoreCase("sweepingedge")) {
                item.addEnchantment(Enchantment.SWEEPING_EDGE, arg[1]);
            }
            if (args[0].equalsIgnoreCase("thorns")) {
                item.addEnchantment(Enchantment.THORNS, arg[1]);
            }
            if (args[0].equalsIgnoreCase("vanishing")) {
                item.addEnchantment(Enchantment.VANISHING_CURSE, arg[1]);
            }
            if (args[0].equalsIgnoreCase("aquaaffinity")) {
                item.addEnchantment(Enchantment.WATER_WORKER, arg[1]);
            return false;
            }
      
          
          
              
            return false;
        }
        @Override
        public boolean onCommand(CommandSender arg0, Command arg1, String arg2, String[] arg3) {
            // TODO Auto-generated method stub
            return false;
        }
    }
    this is probably not the right way to do this, but might as well try
     
    Last edited by a moderator: Sep 16, 2019
  2. Online

    timtower Administrator Administrator Moderator

  3. Offline

    joshua_coolteen

    fixed the error, but the /ench command wont work still. and idk where to begin to start fixing it
     
  4. Online

    timtower Administrator Administrator Moderator

    @joshua_coolteen Lets start with the fact that the first onCommand is not gonna run.
    As in Bukkit doesn't know it. Bukkit knows the second onCommand.
     
  5. Offline

    joshua_coolteen

    thats what was causing the error
     
  6. Online

    timtower Administrator Administrator Moderator

    Then what do you have now?
    And that shouldn't be causing an error. Then it just won't work.
     
  7. Offline

    joshua_coolteen

    what is causing it to not get recognized by bukkit? is it the added int agr[]?
     
  8. Online

    timtower Administrator Administrator Moderator

    Yeah, you should not add things.
    You need to use the one with @Override.
     
  9. Offline

    joshua_coolteen

    aight, but how could i make it to where they can choose a number? cause it wont except a string for the level
     
  10. Online

    timtower Administrator Administrator Moderator

    You need to convert that yourself.
     
  11. Offline

    joshua_coolteen

    im fairly new to making plugins, i have no clue on how to even start on doing that and i cant even find anything on google xD
     
  12. Online

    timtower Administrator Administrator Moderator

    Did you google this? "string to int java" ?
    If so: then you should have found stuff.
     
  13. Offline

    joshua_coolteen

    dang, alright. i have to start getting better at looking stuff up xD
     
  14. Online

    timtower Administrator Administrator Moderator

    What did you search for then?
     
  15. Offline

    joshua_coolteen

    the thing you told me, but is everything else good?
     
  16. Online

    timtower Administrator Administrator Moderator

    Don't know, does it work?
     
  17. Offline

    joshua_coolteen

    not currently in a place where i can test it, but when i do ill let you know here.

    alright, it works. but is it possible to increase the max ench lvl?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Sep 17, 2019
  18. Online

    timtower Administrator Administrator Moderator

  19. Offline

    joshua_coolteen

  20. Online

    timtower Administrator Administrator Moderator

    Not gonna spoonfeed that.
     
Thread Status:
Not open for further replies.

Share This Page