Kit isn't given during duel?

Discussion in 'Spigot Plugin Development' started by OopsyPoopsy, May 6, 2017.

  1. Hello Spigot.

    In my practice plugin, the kit isn't given during a duel. The method <kit>.giveKit(player); works for everything else but for some reason in the accept method, it doesn't work.

    Duel Class:

    Code (Java):

    package me.idc.Practice.Duel;



    import org.bukkit.Bukkit;

    import org.bukkit.Material;

    import org.bukkit.command.Command;

    import org.bukkit.command.CommandExecutor;

    import org.bukkit.command.CommandSender;

    import org.bukkit.entity.Player;

    import org.bukkit.event.EventHandler;

    import org.bukkit.event.Listener;

    import org.bukkit.event.inventory.InventoryClickEvent;

    import org.bukkit.inventory.Inventory;

    import org.bukkit.inventory.ItemStack;

    import org.bukkit.scheduler.BukkitRunnable;



    import me.idc.Practice.Main;

    import me.idc.Practice.Utils.DuelSelector;



    public class Duel implements CommandExecutor, Listener  {

    Main plugin;

    public Duel(Main instance) {

    plugin = instance;

    }

    @Override

    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {

    Player p = (Player) sender;

    if (cmd.getName().equalsIgnoreCase("duel")) {

    if (args.length == 0) {

    p.sendMessage("§c/duel <player>");

    return true;

    }

    Player target = Bukkit.getServer().getPlayer(args[0]);

    if (target == null) {

    p.sendMessage("§cCould not find player " + args[0]);

    return true;

    }

    if (target == p) {

    p.sendMessage("§cThat duel doesn't exist!");

    return true;

    }

    p.openInventory(DuelSelector.kits);

    DuelPlacement.pickkit.put(p, target);

    DuelPlacement.waiting.put(target, p);

    return true;

    }

    return true;

    }

    @EventHandler

    public void onClick(InventoryClickEvent e) {


    Player p = (Player) e.getWhoClicked();

    ItemStack clicked = e.getCurrentItem();

    Inventory inventory = e.getInventory();

    if (inventory.getName().equals(DuelSelector.kits.getName())) {


    Player target = DuelPlacement.pickkit.get(p);

    Player duel = DuelPlacement.waiting.get(target);


    if (clicked.getType() == Material.GOLD_SWORD) {

    e.setCancelled(true);

    p.closeInventory();


    duel.sendMessage("§eDuel request to §6" + target.getName() + " §ehas been sent!");

    target.sendMessage("§6" + duel.getName() + " §ehas sent you a duel request with kit §6NoDebuff§e! Do §6/accept " + duel.getName() + " §eto accept!");

    DuelPlacement.pickkit.remove(p);

    DuelPlacement.awaitingreply.put(target, duel);

    DuelPlacement.awaitingreply.put(duel, target);

    DuelPlacement.duelnodebuff.put(target, duel);

    DuelPlacement.duelnodebuff.put(target, duel);

    new BukkitRunnable() {

    public void run() {

    DuelPlacement.awaitingreply.remove(target);

    DuelPlacement.awaitingreply.remove(duel);

    DuelPlacement.duelnodebuff.remove(duel);

    DuelPlacement.duelnodebuff.remove(target);

    target.sendMessage("§eDuel request from §6" + duel.getName() + " §ehas expired!");

    }

    }.runTaskLater(plugin, 1200);

    }

    }

    }

    @EventHandler

    public void onClick1(InventoryClickEvent e) {


    Player p = (Player) e.getWhoClicked();

    ItemStack clicked = e.getCurrentItem();

    Inventory inventory = e.getInventory();

    if (inventory.getName().equals(DuelSelector.kits.getName())) {


    Player target = DuelPlacement.pickkit.get(p);

    Player duel = DuelPlacement.waiting.get(target);


    if (clicked.getType() == Material.DIAMOND_SWORD) {

    e.setCancelled(true);

    p.closeInventory();


    duel.sendMessage("§eDuel request to §6" + target.getName() + " §ehas been sent!");

    target.sendMessage("§6" + duel.getName() + " §ehas sent you a duel request with kit §6Debuff§e! Do §6/accept " + duel.getName() + " §eto accept!");

    DuelPlacement.pickkit.remove(p);

    DuelPlacement.awaitingreply.put(target, duel);

    DuelPlacement.awaitingreply.put(duel, target);

    DuelPlacement.dueldebuff.put(target, duel);

    DuelPlacement.dueldebuff.put(target, duel);

    new BukkitRunnable() {

    public void run() {

    DuelPlacement.awaitingreply.remove(target);

    DuelPlacement.awaitingreply.remove(duel);

    DuelPlacement.dueldebuff.remove(duel);

    DuelPlacement.dueldebuff.remove(target);

    target.sendMessage("§eDuel request from §6" + duel.getName() + " §ehas expired!");

    }

    }.runTaskLater(plugin, 1200);

    }

    }


    }

    @EventHandler

    public void onClick2(InventoryClickEvent e) {


    Player p = (Player) e.getWhoClicked();

    ItemStack clicked = e.getCurrentItem();

    Inventory inventory = e.getInventory();

    if (inventory.getName().equals(DuelSelector.kits.getName())) {


    Player target = DuelPlacement.pickkit.get(p);

    Player duel = DuelPlacement.waiting.get(target);


    if (clicked.getType() == Material.FEATHER) {

    e.setCancelled(true);

    p.closeInventory();


    duel.sendMessage("§eDuel request to §6" + target.getName() + " §ehas been sent!");

    target.sendMessage("§6" + duel.getName() + " §ehas sent you a duel request with kit §6Combo§e! Do §6/accept " + duel.getName() + " §eto accept!");

    DuelPlacement.pickkit.remove(p);

    DuelPlacement.awaitingreply.put(target, duel);

    DuelPlacement.awaitingreply.put(duel, target);

    DuelPlacement.duelcombo.put(target, duel);

    DuelPlacement.duelcombo.put(target, duel);

    new BukkitRunnable() {

    public void run() {

    DuelPlacement.awaitingreply.remove(target);

    DuelPlacement.awaitingreply.remove(duel);

    DuelPlacement.duelcombo.remove(duel);

    DuelPlacement.duelcombo.remove(target);

    target.sendMessage("§eDuel request from §6" + duel.getName() + " §ehas expired!");

    }

    }.runTaskLater(plugin, 1200);

    }

    }

    }

    @EventHandler

    public void onClick3(InventoryClickEvent e) {


    Player p = (Player) e.getWhoClicked();

    ItemStack clicked = e.getCurrentItem();

    Inventory inventory = e.getInventory();

    if (inventory.getName().equals(DuelSelector.kits.getName())) {


    Player target = DuelPlacement.pickkit.get(p);

    Player duel = DuelPlacement.waiting.get(target);


    if (clicked.getType() == Material.GOLDEN_APPLE) {

    e.setCancelled(true);

    p.closeInventory();


    duel.sendMessage("§eDuel request to §6" + target.getName() + " §ehas been sent!");

    target.sendMessage("§6" + duel.getName() + " §ehas sent you a duel request with kit §6Gapple§e! Do §6/accept " + duel.getName() + " §eto accept!");

    DuelPlacement.pickkit.remove(p);

    DuelPlacement.awaitingreply.put(target, duel);

    DuelPlacement.awaitingreply.put(duel, target);

    DuelPlacement.duelgapple.put(target, duel);

    DuelPlacement.duelgapple.put(target, duel);

    new BukkitRunnable() {

    public void run() {

    DuelPlacement.awaitingreply.remove(target);

    DuelPlacement.awaitingreply.remove(duel);

    DuelPlacement.duelgapple.remove(duel);

    DuelPlacement.duelgapple.remove(target);

    target.sendMessage("§eDuel request from §6" + duel.getName() + " §ehas expired!");

    }

    }.runTaskLater(plugin, 1200);

    }

    }


    }

    }
     
    Accept Class
    Code (Java):

    package me.idc.Practice.Duel;



    import java.util.Random;



    import org.bukkit.Bukkit;

    import org.bukkit.Location;

    import org.bukkit.command.Command;

    import org.bukkit.command.CommandExecutor;

    import org.bukkit.command.CommandSender;

    import org.bukkit.entity.Player;

    import org.bukkit.scheduler.BukkitRunnable;



    import me.idc.Practice.Main;

    import me.idc.Practice.Kits.Combo;

    import me.idc.Practice.Kits.Debuff;

    import me.idc.Practice.Kits.Gapple;

    import me.idc.Practice.Kits.NoDebuff;

    import me.idc.Practice.Queue.Queues;



    public class Accept implements CommandExecutor {

    Main plugin;

    public Accept(Main instance) {

    plugin = instance;

    }

    @Override

    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {

    Player p = (Player) sender;

    if (cmd.getName().equalsIgnoreCase("accept")) {

    if (args.length == 0) {

    p.sendMessage("§c/accept <player>");

    return true;

    }

    Player target = Bukkit.getServer().getPlayer(args[0]);

    if (target == null) {

    p.sendMessage("§cCould not find player " + args[0]);

    return true;

    }

    Player accept = DuelPlacement.awaitingreply.get(p);

    Player duel = DuelPlacement.awaitingreply.get(accept);

    if (!DuelPlacement.awaitingreply.containsKey(target) || DuelPlacement.awaitingreply.get(target) != p) {

    p.sendMessage("§cThat duel doesn't exist!");

    return true;

    }

    DuelPlacement.awaitingreply.remove(duel);

    DuelPlacement.awaitingreply.remove(accept);


    if (DuelPlacement.dueldebuff.containsKey(duel) && DuelPlacement.dueldebuff.containsKey(accept)) {

    Debuff.giveKit(accept);

    Debuff.giveKit(duel);

    } else

    if (DuelPlacement.duelnodebuff.containsKey(duel) && DuelPlacement.duelnodebuff.containsKey(accept)) {

    NoDebuff.giveKit(accept);

    NoDebuff.giveKit(duel);

    } else

    if (DuelPlacement.duelcombo.containsKey(duel) && DuelPlacement.duelcombo.containsKey(accept)) {

    Combo.giveKit(accept);

    Combo.giveKit(duel);

    accept.setMaximumNoDamageTicks(0);

    duel.setMaximumNoDamageTicks(0);

    } else

    if (DuelPlacement.duelgapple.containsKey(duel) && DuelPlacement.duelgapple.containsKey(accept)) {

    Gapple.giveKit(accept);

    Gapple.giveKit(duel);

    return true;

    }



    int size = plugin.getConfig().getConfigurationSection("arenas").getKeys(false).size();

     

    int select = new Random().nextInt(size) + 1;

     

    int xLoc = plugin.getConfig().getInt("arenas." + select + ".x1");

    int yLoc = plugin.getConfig().getInt("arenas." + select + ".y1");

    int zLoc = plugin.getConfig().getInt("arenas." + select + ".z1");

    int xLoc2 = plugin.getConfig().getInt("arenas." + select + ".x2");

    int yLoc2 = plugin.getConfig().getInt("arenas." + select + ".y2");

    int zLoc2 = plugin.getConfig().getInt("arenas." + select + ".z2");

    int yaw1 = plugin.getConfig().getInt("arenas." + select + ".yaw1");

    int yaw2 = plugin.getConfig().getInt("arenas." + select + ".yaw2");

    int pitch1 = plugin.getConfig().getInt("arenas." + select + ".pitch1");

    int pitch2 = plugin.getConfig().getInt("arenas." + select + ".pitch2");

     

    Location location = new Location(Bukkit.getWorld("world"), xLoc, yLoc, zLoc, yaw1, pitch1);

    Location location2 = new Location(Bukkit.getWorld("world"), xLoc2, yLoc2, zLoc2, yaw2, pitch2);


    duel.teleport(location);

    accept.teleport(location2);

    Queues.awaitingstart.add(duel);

    Queues.awaitingstart.add(accept);

    Queues.inmatch.add(duel);

    Queues.inmatch.add(accept);

    accept.showPlayer(duel);

    duel.showPlayer(accept);

    duel.sendMessage("§eMatch starting against §6" + target.getPlayer().getName());

    accept.sendMessage("§eMatch starting against §6" + p.getName());

    duel.sendMessage("§eMatch Starting in §65 §eseconds");

    accept.sendMessage("§eMatch Starting in §65 §eseconds");

    new BukkitRunnable() {

    public void run() {

    accept.sendMessage("§eMatch Starting in §64 §eseconds");

    duel.sendMessage("§eMatch Starting in §64 §eseconds");

    new BukkitRunnable() {

    public void run() {

    accept.sendMessage("§eMatch Starting in §63 §eseconds");

    duel.sendMessage("§eMatch Starting in §63 §eseconds");

    new BukkitRunnable() {

    public void run() {

    accept.sendMessage("§eMatch Starting in §62 §eseconds");

    duel.sendMessage("§eMatch Starting in §62 §eseconds");

    new BukkitRunnable() {

    public void run() {

    accept.sendMessage("§eMatch Starting in §61 §eseconds");

    target.getPlayer().sendMessage("§eMatch Starting in §61 §eseconds");

    new BukkitRunnable() {

    public void run() {

    accept.sendMessage("§eMatch has started!");

    duel.sendMessage("§eMatch has started!");

    Queues.awaitingstart.remove(duel);

    Queues.awaitingstart.remove(accept);

    }

    }.runTaskLater(plugin, 20);

    }

    }.runTaskLater(plugin, 20);

    }

    }.runTaskLater(plugin, 20);

    }

    }.runTaskLater(plugin, 20);


    }

    }.runTaskLater(plugin, 20);



    }

    return true;

    }
     
    }
     
  2. In your main class where your onEnable() is do you have:
    Code (Text):
    getServer().getCommand("accept").setExecutor(new Accept());
     
  3. Yep.

    Code (Java):

    this.getCommand("accept").setExecutor(new me.idc.Practice.Duel.Accept(this));
     
    The only problem is that the kit isn't given. Everything else works fine.
     
  4. Could we See the class Gapple?
     
  5. Could we see the classes Gapple/Combo/Debuff/NoDebuff
    Particularly the #giveKit method.


    Sent from my iPhone using Tapatalk
     

  6. Combo:
    Code (Java):

    package me.idc.Practice.Kits;

    import org.bukkit.Material;
    import org.bukkit.enchantments.Enchantment;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.potion.Potion;
    import org.bukkit.potion.PotionType;

    public class Combo implements Listener {
       
        public static void giveKit(final Player p) {
           
            ItemStack combo = new ItemStack(Material.ENCHANTED_BOOK);
            ItemMeta combometa = combo.getItemMeta();
            combometa.setDisplayName("§6Combo Kit");
            combo.setItemMeta(combometa);
           
            p.getInventory().clear();
            p.getInventory().setItem(0, combo);
            p.updateInventory();
        }
       
        @EventHandler
        public void onInteract(PlayerInteractEvent e) {
            Player p = e.getPlayer();
           
            ItemStack combo = new ItemStack(Material.ENCHANTED_BOOK);
            ItemMeta combometa = combo.getItemMeta();
            combometa.setDisplayName("§6Combo Kit");
            combo.setItemMeta(combometa);
           
            ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
            ItemMeta swordmeta = sword.getItemMeta();
            swordmeta.addEnchant(Enchantment.FIRE_ASPECT, 1, true);
            swordmeta.addEnchant(Enchantment.DAMAGE_ALL, 1, true);
            swordmeta.addEnchant(Enchantment.DURABILITY, 3, true);
            sword.setItemMeta(swordmeta);
           
            if (p.getItemInHand().equals(combo)) {
                if (e.getAction() == Action.RIGHT_CLICK_AIR) {
                    p.getInventory().setBoots(new ItemStack(Material.DIAMOND_BOOTS));
                    p.getInventory().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS));
                    p.getInventory().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE));
                    p.getInventory().setHelmet(new ItemStack(Material.DIAMOND_HELMET));
                    p.getInventory().getBoots().addEnchantment(Enchantment.DURABILITY, 3);
                    p.getInventory().getBoots().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                    p.getInventory().getLeggings().addEnchantment(Enchantment.DURABILITY, 3);
                    p.getInventory().getLeggings().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                    p.getInventory().getChestplate().addEnchantment(Enchantment.DURABILITY, 3);
                    p.getInventory().getChestplate().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                    p.getInventory().getHelmet().addEnchantment(Enchantment.DURABILITY, 3);
                    p.getInventory().getHelmet().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                    p.getInventory().setItem(0, sword);
                    p.getInventory().setItem(1, new ItemStack(Material.GOLDEN_APPLE, 64, (short)1));
                    p.getInventory().setItem(2, new ItemStack(Material.GOLDEN_CARROT, 64));
                   
                    final ItemStack item = new ItemStack(Material.POTION, 1);
                    final ItemStack speed = new ItemStack(Material.POTION, 1);
                   p.getInventory().addItem(new ItemStack[] { item });
                   final Potion speeditem = new Potion(1);
                   speeditem.setType(PotionType.SPEED);
                   speeditem.setLevel(2);
                   speeditem.setSplash(false);
                   speeditem.apply(speed);    
                   final ItemStack firres = new ItemStack(Material.POTION, 1);
                   p.getInventory().addItem(new ItemStack[] { item });
                   final Potion fireitem = new Potion(1);
                   fireitem.setType(PotionType.FIRE_RESISTANCE);
                   fireitem.setLevel(1);
                   fireitem.setSplash(false);
                   fireitem.apply(firres);    
                   
                    p.getInventory().setItem(3, firres);
                    p.getInventory().setItem(4, speed);
                    p.getInventory().setItem(30, firres);
                    p.getInventory().setItem(31, speed);
                    p.getInventory().setItem(22, speed);
                    p.getInventory().setItem(21, firres);
                }
            }
        }

    }
     
    Debuff
    Code (Java):

    package me.idc.Practice.Kits;

    import org.bukkit.Material;
    import org.bukkit.enchantments.Enchantment;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.potion.Potion;
    import org.bukkit.potion.PotionType;

    public class Debuff implements Listener {
       
        public static void giveKit(final Player p) {
        ItemStack debuff = new ItemStack(Material.ENCHANTED_BOOK);
        ItemMeta meta = debuff.getItemMeta();
        meta.setDisplayName("§6Debuff Kit");
        debuff.setItemMeta(meta);
       
        p.getInventory().clear();
        p.getInventory().setItem(0, debuff);
        p.updateInventory();
        }
       
        @EventHandler
        public void onInteract(PlayerInteractEvent e) {
            Player p = e.getPlayer();
           
            ItemStack debuff = new ItemStack(Material.ENCHANTED_BOOK);
            ItemMeta meta = debuff.getItemMeta();
            meta.setDisplayName("§6Debuff Kit");
            debuff.setItemMeta(meta);
       
        ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
        ItemMeta swordmeta = sword.getItemMeta();
        swordmeta.addEnchant(Enchantment.FIRE_ASPECT, 1, true);
        swordmeta.addEnchant(Enchantment.DAMAGE_ALL, 1, true);
        swordmeta.addEnchant(Enchantment.DURABILITY, 3, true);
        sword.setItemMeta(swordmeta);
       
        if (p.getItemInHand().equals(debuff)) {
            if (e.getAction() == Action.RIGHT_CLICK_AIR) {
                p.getInventory().clear();
        p.getInventory().setBoots(new ItemStack(Material.DIAMOND_BOOTS));
        p.getInventory().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS));
        p.getInventory().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE));
        p.getInventory().setHelmet(new ItemStack(Material.DIAMOND_HELMET));
        p.getInventory().getBoots().addEnchantment(Enchantment.DURABILITY, 3);
        p.getInventory().getBoots().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
        p.getInventory().getLeggings().addEnchantment(Enchantment.DURABILITY, 3);
        p.getInventory().getLeggings().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
        p.getInventory().getChestplate().addEnchantment(Enchantment.DURABILITY, 3);
        p.getInventory().getChestplate().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
        p.getInventory().getHelmet().addEnchantment(Enchantment.DURABILITY, 3);
        p.getInventory().getHelmet().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
        p.getInventory().setItem(0, sword);
        p.getInventory().setItem(1, new ItemStack(Material.ENDER_PEARL, 16));
        p.getInventory().setItem(2, new ItemStack(Material.GOLDEN_CARROT, 64));
        final ItemStack item = new ItemStack(Material.POTION, 1);
        final Potion pot = new Potion(1);
        pot.setType(PotionType.INSTANT_HEAL);
        pot.setLevel(2);
        pot.setSplash(true);
        pot.apply(item);
        for (int i = 0; i < 34; ++i) {
            final ItemStack speed = new ItemStack(Material.POTION, 1);
            p.getInventory().addItem(new ItemStack[] { item });
            final Potion speeditem = new Potion(1);
            speeditem.setType(PotionType.SPEED);
            speeditem.setLevel(2);
            speeditem.setSplash(false);
            speeditem.apply(speed);    
            final ItemStack firres = new ItemStack(Material.POTION, 1);
            p.getInventory().addItem(new ItemStack[] { item });
            final Potion fireitem = new Potion(1);
            fireitem.setType(PotionType.FIRE_RESISTANCE);
            fireitem.setLevel(1);
            fireitem.setSplash(false);
            fireitem.setHasExtendedDuration(true);
            fireitem.apply(firres);      
            final ItemStack slow = new ItemStack(Material.POTION, 1);
            p.getInventory().addItem(new ItemStack[] { item });
            final Potion slowitem = new Potion(1);
            slowitem.setType(PotionType.SLOWNESS);
            slowitem.setLevel(1);
            slowitem.setSplash(true);
            slowitem.apply(slow);    
            final ItemStack poison = new ItemStack(Material.POTION, 1);
            final Potion poisonitem = new Potion(1);
            poisonitem.setType(PotionType.POISON);
            poisonitem.setLevel(1);
            poisonitem.setSplash(true);
            poisonitem.apply(poison);    
            p.getInventory().setItem(7, firres);
            p.getInventory().setItem(8, speed);
            p.getInventory().setItem(17, speed);
            p.getInventory().setItem(26, speed);
            p.getInventory().setItem(35, speed);
            p.getInventory().setItem(16, poison);
            p.getInventory().setItem(24, poison);
            p.getInventory().setItem(15, slow);
            p.getInventory().setItem(25, slow);
        p.updateInventory();
        }
        }
        }
        }
    }
     
    Gapple:
    Code (Java):

    package me.idc.Practice.Kits;

    import org.bukkit.Material;
    import org.bukkit.enchantments.Enchantment;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.potion.Potion;
    import org.bukkit.potion.PotionType;

    public class Gapple implements Listener {
       
        public static void giveKit(final Player p) {
           
            ItemStack gapple = new ItemStack(Material.ENCHANTED_BOOK);
            ItemMeta gapplemeta = gapple.getItemMeta();
            gapplemeta.setDisplayName("§6Gapple Kit");
            gapple.setItemMeta(gapplemeta);
           
            p.getInventory().clear();
            p.getInventory().setItem(0, gapple);
            p.updateInventory();
        }
       
        @EventHandler
        public void onInteract(PlayerInteractEvent e) {
            Player p = e.getPlayer();
           
            ItemStack gapple = new ItemStack(Material.ENCHANTED_BOOK);
            ItemMeta gapplemeta = gapple.getItemMeta();
            gapplemeta.setDisplayName("§6Gapple Kit");
            gapple.setItemMeta(gapplemeta);
           
            ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
            ItemMeta swordmeta = sword.getItemMeta();
            swordmeta.addEnchant(Enchantment.FIRE_ASPECT, 1, true);
            swordmeta.addEnchant(Enchantment.DAMAGE_ALL, 1, true);
            swordmeta.addEnchant(Enchantment.DURABILITY, 3, true);
            sword.setItemMeta(swordmeta);
           
            if (p.getItemInHand().equals(gapple)) {
                if (e.getAction() == Action.RIGHT_CLICK_AIR) {
                    p.getInventory().setBoots(new ItemStack(Material.DIAMOND_BOOTS));
                    p.getInventory().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS));
                    p.getInventory().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE));
                    p.getInventory().setHelmet(new ItemStack(Material.DIAMOND_HELMET));
                    p.getInventory().getBoots().addEnchantment(Enchantment.DURABILITY, 3);
                    p.getInventory().getBoots().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                    p.getInventory().getLeggings().addEnchantment(Enchantment.DURABILITY, 3);
                    p.getInventory().getLeggings().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                    p.getInventory().getChestplate().addEnchantment(Enchantment.DURABILITY, 3);
                    p.getInventory().getChestplate().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                    p.getInventory().getHelmet().addEnchantment(Enchantment.DURABILITY, 3);
                    p.getInventory().getHelmet().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                    p.getInventory().setItem(0, sword);
                    p.getInventory().setItem(1, new ItemStack(Material.GOLDEN_APPLE, 64, (short)1));
                    p.getInventory().setItem(2, new ItemStack(Material.GOLDEN_CARROT, 64));
                   
                    final ItemStack item = new ItemStack(Material.POTION, 1);
                    final ItemStack speed = new ItemStack(Material.POTION, 1);
                   p.getInventory().addItem(new ItemStack[] { item });
                   final Potion speeditem = new Potion(1);
                   speeditem.setType(PotionType.SPEED);
                   speeditem.setLevel(2);
                   speeditem.setSplash(false);
                   speeditem.apply(speed);    
                   final ItemStack firres = new ItemStack(Material.POTION, 1);
                   p.getInventory().addItem(new ItemStack[] { item });
                   final Potion fireitem = new Potion(1);
                   fireitem.setType(PotionType.FIRE_RESISTANCE);
                   fireitem.setLevel(1);
                   fireitem.setSplash(false);
                   fireitem.apply(firres);    
                   
                    p.getInventory().setItem(3, firres);
                    p.getInventory().setItem(4, speed);
                    p.getInventory().setItem(30, firres);
                    p.getInventory().setItem(31, speed);
                    p.getInventory().setItem(22, speed);
                    p.getInventory().setItem(21, firres);
                }
            }
        }

    }
     
    NoDebuff:
    Code (Java):

    package me.idc.Practice.Kits;

    import org.bukkit.Material;
    import org.bukkit.enchantments.Enchantment;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.potion.Potion;
    import org.bukkit.potion.PotionType;

    public class NoDebuff implements Listener {
       
        public static void giveKit(final Player p) {
        ItemStack nodebuff = new ItemStack(Material.ENCHANTED_BOOK);
        ItemMeta meta = nodebuff.getItemMeta();
        meta.setDisplayName("§6NoDebuff Kit");
        nodebuff.setItemMeta(meta);
       
        p.getInventory().clear();
        p.getInventory().setItem(0, nodebuff);
        p.updateInventory();
        }
       
        @EventHandler
        public void onInteract(PlayerInteractEvent e) {
            Player p = e.getPlayer();
           
        ItemStack nodebuff = new ItemStack(Material.ENCHANTED_BOOK);
        ItemMeta meta = nodebuff.getItemMeta();
        meta.setDisplayName("§6NoDebuff Kit");
        nodebuff.setItemMeta(meta);
       
        ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
        ItemMeta swordmeta = sword.getItemMeta();
        swordmeta.addEnchant(Enchantment.FIRE_ASPECT, 1, true);
        swordmeta.addEnchant(Enchantment.DAMAGE_ALL, 1, true);
        swordmeta.addEnchant(Enchantment.DURABILITY, 3, true);
        sword.setItemMeta(swordmeta);
       
        if (p.getItemInHand().equals(nodebuff)) {
            if (e.getAction() == Action.RIGHT_CLICK_AIR) {
                p.getInventory().clear();
        p.getInventory().setBoots(new ItemStack(Material.DIAMOND_BOOTS));
        p.getInventory().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS));
        p.getInventory().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE));
        p.getInventory().setHelmet(new ItemStack(Material.DIAMOND_HELMET));
        p.getInventory().getBoots().addEnchantment(Enchantment.DURABILITY, 3);
        p.getInventory().getBoots().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
        p.getInventory().getLeggings().addEnchantment(Enchantment.DURABILITY, 3);
        p.getInventory().getLeggings().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
        p.getInventory().getChestplate().addEnchantment(Enchantment.DURABILITY, 3);
        p.getInventory().getChestplate().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
        p.getInventory().getHelmet().addEnchantment(Enchantment.DURABILITY, 3);
        p.getInventory().getHelmet().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
        p.getInventory().setItem(0, sword);
        p.getInventory().setItem(1, new ItemStack(Material.ENDER_PEARL, 16));
        p.getInventory().setItem(2, new ItemStack(Material.GOLDEN_CARROT, 64));
        final ItemStack item = new ItemStack(Material.POTION, 1);
        final Potion pot = new Potion(1);
        pot.setType(PotionType.INSTANT_HEAL);
        pot.setLevel(2);
        pot.setSplash(true);
        pot.apply(item);
        for (int i = 0; i < 34; ++i) {
            final ItemStack speed = new ItemStack(Material.POTION, 1);
            p.getInventory().addItem(new ItemStack[] { item });
            final Potion speeditem = new Potion(1);
            speeditem.setType(PotionType.SPEED);
            speeditem.setLevel(2);
            speeditem.setSplash(false);
            speeditem.apply(speed);    
            final ItemStack firres = new ItemStack(Material.POTION, 1);
            p.getInventory().addItem(new ItemStack[] { item });
            final Potion fireitem = new Potion(1);
            fireitem.setType(PotionType.FIRE_RESISTANCE);
            fireitem.setLevel(1);
            fireitem.setSplash(false);
            fireitem.setHasExtendedDuration(true);
            fireitem.apply(firres);        
            p.getInventory().setItem(7, firres);
            p.getInventory().setItem(8, speed);
            p.getInventory().setItem(17, speed);
            p.getInventory().setItem(26, speed);
            p.getInventory().setItem(35, speed);
        p.updateInventory();
        }
        }
        }
        }
    }
     
     
  7. This isn't some of the most terrifying static abuse I've ever seen. For gods sake, please learn OOP.
     
    • Agree Agree x 2
  8. You don't switch the keys here. You repeat the same key insert twice, you'd want it to be this instead:
    Code (Text):

    DuelPlacement.awaitingreply.put(target, duel);

    DuelPlacement.awaitingreply.put(duel, target);

    DuelPlacement.duelnodebuff.put(target, duel);

    DuelPlacement.duelnodebuff.put(duel, target);
     
    As for your work, it would do you a lot of good to learn some basics. Your design structure is pretty crappy and almost entirely redundant.
     
    • Agree Agree x 1
  9. It would be best to create an abstract kit class that can be inherited by each of the other classes NoGapple, Gapple etc... makes for alot more cleaner, readable, and easily editable code.