Effect While Holding an Item

Discussion in 'Plugin Development' started by KoolzSkillz, Sep 29, 2014.

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

    KoolzSkillz

    Is it possible to make it so when you are holding an item you can get effects but when you switch it out they go, if so what event would i use?
    also can a custom name be used

    Thx to anyone that replys
     
  2. Offline

    Monkey_Swag

    Use a while statement for when the item in the player's hand's displayname is set to the displayname of your liking.
     
  3. Offline

    KoolzSkillz

  4. Offline

    Monkey_Swag

    KoolzSkillz depends. When exactly do you want this to trigger? You could use pretty much any method. PlayerMoveEvent, an onCommand method. Doesn't really matter.
     
  5. Offline

    KoolzSkillz

    Monkey_Swag
    so i have a kit, when the player switches to the stick named Fly, i want it to turn on fly, but after one use the stick removes itself from their inventory
     
  6. Offline

    Monkey_Swag

    KoolzSkillz do you mean right click the stick or hold the stick? You could use p#getCrusor() if it's not triggered by a right-click.
     
  7. Offline

    KoolzSkillz

    Monkey_Swag
    When they right click, im thinking what i do is make a hashmap and add then to the hashmap, then when they right click it it removes them so when they right click it again it adds them?

    Um What event is the one where they can right click with it on their hotbar, atm ive got it so you right click it with the inventory open
     
  8. Nooooooooooooooooooooooooooo.
     
  9. Offline

    KoolzSkillz

    AdamQpzm
    ?
    What ive got so far is they can right click it in their inventory. BUT how do i make it so they can left click in the hotbar
     
  10. KoolzSkillz That second one would fire an InventoryClickEvent
     
  11. Offline

    KoolzSkillz

    AdamQpzm

    This is what i have got so far
    Code:
    @EventHandler
      public void onInventoryClick(InventoryClickEvent event) {
        if (event.getInventory().getName().equalsIgnoreCase("null")) {
          return;
        } else {
        Player player = (Player)event.getWhoClicked();
        event.setCancelled(true);
        if ((event.getCurrentItem() == null) ||
          (event.getCurrentItem().getType() == Material.AIR) ||
          (!event.getCurrentItem().hasItemMeta())){
            if ((event.getCurrentItem().getType() == Material.STICK)){
                  if (!this.Fly.containsKey(player)) {
                player.setAllowFlight(true);
                player.setFlying(true);
                  this.Fly.put(player, null);
                  } else {
                      player.setAllowFlight(false);
                      player.setFlying(false);
                      player.getInventory().remove(Material.STICK);
                        this.Fly.remove(player);
     
Thread Status:
Not open for further replies.

Share This Page