Solved Getting messages twice when right clicking endercrystal?

Discussion in 'Spigot Plugin Development' started by FroZenKeyboard, May 1, 2017.

  1. So i got this code:

    Code (Text):
        public void onInteract(PlayerInteractEntityEvent e) {
            if(e.getRightClicked().getType() == EntityType.ENDER_CRYSTAL) {
                if(points.getInt("points." + e.getPlayer().getUniqueId()) == 0) {
                    e.getPlayer().sendMessage(Crates + "§5You got no points!");
                }else if(points.getInt("points." + e.getPlayer().getUniqueId()) > 0) {
                        int kills = points.getInt("points." + e.getPlayer().getUniqueId());
                        points.set("points." + e.getPlayer().getUniqueId(), Integer.valueOf(kills - 1));
                      try {
                      } catch (IOException e1) {
    And everytime i click the ender crystal, it sends the "T" message twice. I know it's the 1.9 update, two hands. But i found nothing that really helped.

  2. Because sometime the event is fired twice, once every hand. Maybe you can do a short cooldown using a Set<Player> and a bukkitRunnable
  3. I know why it's comming. And how could a runnable fix that?
  4. BananaPuncher714


    Use e.getHand() to determine which one is right clicking. There's this thing called Google that gives answers to those who look.
    Code (Text):
    if ( !e.getHand().equals( EquipmentSlot.HAND ) ) return;
    That returns if they player isn't using their main hand.
    • Winner Winner x 1
    • Useful Useful x 1
  5. Umh, seems like this is a better way.
    • Like Like x 1
  6. Thank you! It worked, thanks to @BananaPuncher714!
    • Like Like x 1