Solved When i hold my item onSlotChange it wont work!

Discussion in 'Plugin Development' started by MajorSkillage, Oct 4, 2014.

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

    MajorSkillage

    When i am holding a diamond sword it wont work then when i switch to anything else from a diamond sword it works! D:< halp!
    Code:
      @EventHandler
      public void onItemInteract(PlayerItemHeldEvent e) {
          p = e.getPlayer();
          String w = p.getWorld().getName();
        int item = this.p.getItemInHand().getTypeId();
        if (item == id && !getConfig().getStringList("disabled_worlds").contains(w)){
          ItemStack dhelmet = new ItemStack(getConfig().getInt("helmet on hold"));
          ItemStack dchest = new ItemStack(getConfig().getInt("chestplate on hold"));
          ItemStack dlegs = new ItemStack(getConfig().getInt("leggings on hold"));
          ItemStack dboots = new ItemStack(getConfig().getInt("boots on hold"));
          p.getInventory().setHelmet(dhelmet);
          p.getInventory().setChestplate(dchest);
          p.getInventory().setLeggings(dlegs);
          p.getInventory().setBoots(dboots);
        } else if (item != id && getConfig().getString("remove armour after pvp") == "true") {
          ItemStack air = new ItemStack(Material.AIR);
          p.getInventory().setHelmet(air);
          p.getInventory().setChestplate(air);
          p.getInventory().setLeggings(air);
          p.getInventory().setBoots(air);
        }
      }
    Oh also id = getConfig().getInt("id"); incase u guys get freaked out x)
     
  2. MajorSkillage For the boolean why not do if(getConfig().getBoolean("RemoveArmour"){ //That returns true.
     
  3. Offline

    MajorSkillage

    ahh forgot, thanks

    still having the issue though, so now what? :I

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

Share This Page