Discussion in 'Spigot Plugin Development' started by Ayresy, May 20, 2015.

  1. How would you check id a player is wear a type od armour and if they take it off and put diferent armour on.
    so if they are wearing full leather it would give them speed 3 but if theyre missing leather boots, helm chest plate etc they wouldnt have an effect

    thanks in advance
  2. Use if statements to check and then give them speed.
  3. check id a player is wear a type od armour. Proper English please XD
  4. But anyways, I understood the question. Use if statements to either check the item meta, or the item display name. Other than that, the only other way is to check if the item is an instance of a subclass of an ItemStack which from my experience, is a lot more work, and you will come out with a lot more listeners to work with which isn't really efficient.
  5. I was on a laggy tablet at school with 2 mins that why the English is poor, but thanks
  6. so i would check if the player .getHelmet.getType() == Diamond_Helmet.getDisplayName("Diamond Helment") then give them the effect or something similar i'm guessing
  7. You would do: player.getInventory().getHelmet().getItemMeta().getDisplayName().equals(<"whatever name you are looking for">))

    You don't compare Strings with ==
  8. ah okey thanks, it was only a draft of it
  9. Just a waste of time. Just check if the player is wearing leatherboots, leatherchestplate etc. Then do stuff.

    If you have a custom ItemStack, you check also for the displayname, but you weren't.
  10. Each time an InventoryClick is fired, check if the armor slots have changed a tick later - and if they either create a full set or break one. Then simply change that in a Set/Map (if you have only one effect, a Set will suffice. But if you have multiple effects - for example speed I with leather armor and speed II with iron armor, you will need a Map).

    Lastly, have a global runnable which updates the effects of people every tick / second / x seconds.
    • Useful Useful x 1
  11. This was only meant for if you wanted the armor to be of a specified type with a specified name, if you really just want the type of armor to be checked then you only need to compare the type
    • Useful Useful x 1
  12. Ok thanks guys
  13. Could you give an example of the map part pls but not spoon feed me im not understanding it properly
  14. What part of it don't you understand?
  15. The mapping part : "change that in a Set/Map (if you have only one effect," also could you check my other thread i need help with :s
  16. When they have a complete set of armor after a InventoryClickEvent, add them to a Set / put their player with the effect type in the Map. If they do not, remove it from the Set / Map
    • Useful Useful x 1
  17. okey thankss!
  18. Could you help me with my other new thread
  19. }else{

    p.sendMessage(ChatColor.AQUA + "You must wait " + ChatColor.YELLOW + ChatColor.BOLD + cooldown.get(p) + ChatColor.AQUA + " seconds before you enderpearl again!");
    ItemStack ep = new ItemStack(Material.ENDER_PEARL);
    ItemMeta meta = ep.getItemMeta();
    meta.setDisplayName("§eEnderpearl Cooldown: §c" + cooldown.get(p));

    How would i get the amount of enderpearls the player the player previously had then once the cooldown finishes put it to the right amount
  20. You are never going to learn unless you debug on your own. By the fact that you didn't even know that Strings are only to be compared with ==, shows signs of needing improvement in your knowledge of programming. Please learn the Java API first before moving on to things like bukkit, or you will just make it hard for yourself. I mean this in the nicest way possible...