(Help)

Discussion in 'Plugin Development' started by Cooper PluginDev, Mar 1, 2014.

Thread Status:
Not open for further replies.
  1. How would I go about scanning if a player has a COLOURED wool on his head.
    I want it to be like if(player.getHelmet().getType() == Wool:Blue {
    Then do this
    }
    How would I check if the player has coloured wool?
     
  2. Offline

    Kuuichi

    Code:java
    1. DyeColor color = ((Wool) player.getHelmet().getState().getColor());
    2.  
    3. if(color == DyeColor.BLUE) {
    4.  
    5. }


    But make sure you check that the player has wool on their head first, because you're casting.
     
  3. Kuuichi
    Many errors, doesn't work. :/

    Kuuichi
    Says "Add cast to event"

    Anyone?

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

    Dudemister1999

    Maybe this will help you:

    Code:java
    1. public boolean isWearingBlueWool(Player player)
    2. {
    3. ItemStack helmet = player.getInventory().getHelmet();
    4.  
    5. if(helmet != null)
    6. {
    7. if(helmet.getType() == Material.WOOL)
    8. {
    9. Wool helm = new Wool(DyeColor.BLUE);
    10. if(helmet.isSimilar(helm.toItemStack()))
    11. {
    12. //Yessir, it's blue wool!
    13. return true;
    14. }
    15. else
    16. {
    17. //No sir, it isn't. :(
    18. return false;
    19. }
    20. }
    21. }
    22. return false;
    23. }


    Actually, here's a cleaner method.

    Code:java
    1. public boolean isWearingBlueWool(Player player)
    2. {
    3. ItemStack helmet = player.getInventory().getHelmet();
    4.  
    5. if(helmet != null && helmet.getType() == Material.WOOL)
    6. {
    7. Wool helm = new Wool(DyeColor.BLUE);
    8. return helmet.isSimilar(helm.toItemStack());
    9. }
    10. return false;
    11. }


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  5. Dudemister1999
    Uhmm, not sure....
    Here is my code:
    Code:java
    1. @EventHandler
    2. /* */ public void onPlayerInteract3(PlayerInteractEvent event) {
    3. /* 24 */ Player player = event.getPlayer();
    4. /* 25 */ ItemStack lb = new ItemStack(Material.WOOL);
    5. /* 26 */ if (((event.getAction() == Action.LEFT_CLICK_AIR) || (event.getAction() == Action.LEFT_CLICK_BLOCK)) &&
    6. /* 27 */ (player.getItemInHand().getType() == Material.WOOL)) {
    7. /* 28 */ Sound sound = Sound.PISTON_EXTEND;
    8. /* 29 */ if (player.getInventory().contains(Material.MOB_SPAWNER)) {
    9. /* 30 */ player.getInventory().removeItem(new ItemStack[] { new ItemStack(Material.MOB_SPAWNER, 1) });
    10. /* 31 */ player.getWorld().playSound(player.getPlayer().getLocation(), sound, 10.0F, 10.0F);
    11. /* 32 */ player.getWorld().playEffect(player.getLocation(), Effect.STEP_SOUND, Material.SNOW_BLOCK.getId());
    12. /* 33 */ player.getInventory().setHelmet(lb);
    13. player.sendMessage(ChatColor.BLUE + "Module> " + ChatColor.GRAY + "Module Class: " + ChatColor.GREEN + "Superman");
    14. /* */ }
    15. /* */ }
    16. /* */ }
    17.  
    18. }

    How would I change this: (player.getItemInHand().getType() == Material.WOOL)) { to a colour?
     
  6. Offline

    ThunderWaffeMC

    Get item id and data. Example:

    player.getItemInHand().getTypeId() == 50
    player.getItemInHand().getData() == 10
     
  7. @ThunderWaffleMC
    Error on the second ")"
    How do I fix this :/

    Anyone?

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

    Dudemister1999

    What exactly is it that you need to do? I know you need to check if the player is wearing blue wool, but I need to know when you need to do that, exactly.
     
  9. Dudemister1999
    I'm trying to check if the player has blue wool on his/her head and if the played does have blue wool it will do this.
    Basically, if the player is wearing blue wool you will be able to leap around etc etc.

    Anyone?

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

Share This Page