Exemplo n.º 1
0
  @EventHandler(priority = EventPriority.MONITOR)
  public void stackPlayer(PlayerInteractEntityEvent event) {
    // Do nothing if clicked entity is not a player.
    if (!(event.getRightClicked() instanceof Player)) return;

    // Do nothing if player does not have permission.
    Player player = event.getPlayer();
    if (!Perm.PLAYERSTACKER.has(player)) return;

    // Do nothing if clicking player is not stacking.
    User user = plugin.getUser(player.getUniqueId());
    if (user != null && !user.isStacking()) return;

    // Do nothing if clicked player is not stacking.
    Player clicked = (Player) event.getRightClicked();
    user = plugin.getUser(clicked.getUniqueId());
    if (user != null && !user.isStacking()) return;

    // Do nothing if player or clicked player are inside a vehicle.
    if (clicked.isInsideVehicle() || player.isInsideVehicle()) return;

    // Stack the player.
    Entity topPassenger = getTopPassenger(player);
    topPassenger.setPassenger(clicked);
  }
Exemplo n.º 2
0
  public void a(Packet7UseEntity packet7useentity) {
    // CraftBukkit start
    if (this.player.dead) {
      return;
    }
    // CraftBukkit end

    WorldServer worldserver = this.minecraftServer.a(this.player.dimension);
    Entity entity = worldserver.getEntity(packet7useentity.target);

    if (entity != null && this.player.e(entity) && this.player.g(entity) < 36.0D) {
      if (packet7useentity.c == 0) {
        // CraftBukkit start
        PlayerInteractEntityEvent piee =
            new PlayerInteractEntityEvent((Player) getPlayer(), entity.getBukkitEntity());
        server.getPluginManager().callEvent(piee);
        if (piee.isCancelled()) {
          return;
        }
        // CraftBukkit end
        this.player.c(entity);
      } else if (packet7useentity.c == 1) {
        this.player.d(entity);
      }
    }
  }
Exemplo n.º 3
0
 @EventHandler
 public void onBukkitEvent(PlayerInteractEntityEvent event) {
   event
       .getPlayer()
       .sendMessage(
           "Stop messing with that " + event.getRightClicked().getType().getName() + "!");
 }
Exemplo n.º 4
0
 @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
 public void onEntityRightClick(PlayerInteractEntityEvent event) {
   QuestManager qm = Quester.qMan;
   Player player = event.getPlayer();
   Quest quest = qm.getPlayerQuest(player.getName());
   if (quest != null) {
     if (!quest.allowedWorld(player.getWorld().getName().toLowerCase())) return;
     List<Objective> objs = quest.getObjectives();
     Entity entity = event.getRightClicked();
     ItemStack item = player.getItemInHand();
     for (int i = 0; i < objs.size(); i++) {
       if (objs.get(i).getType().equalsIgnoreCase("DYE")) {
         if (!qm.isObjectiveActive(player, i)) {
           continue;
         }
         DyeObjective obj = (DyeObjective) objs.get(i);
         if (entity.getType() == EntityType.SHEEP) {
           Sheep sheep = (Sheep) entity;
           if (item.getType() == Material.INK_SACK
               && obj.checkDye(15 - item.getDurability())
               && sheep.getColor().getDyeData() != (15 - item.getDurability())) {
             qm.incProgress(player, i);
             return;
           }
         }
       }
     }
   }
 }
Exemplo n.º 5
0
 @EventHandler
 void onPlayerInteractEntityEvent(PlayerInteractEntityEvent event) {
   if (event.getPlayer().hasMetadata("give-pet")) {
     if (event.getRightClicked() instanceof Tameable) {
       Tameable pet = (Tameable) event.getRightClicked();
       if (pet.isTamed() && pet.getOwner() instanceof Player) {
         Player player = (Player) pet.getOwner();
         if (player.equals(event.getPlayer())
             || event.getPlayer().hasPermission("omneity3.give-pet.override")) {
           OfflinePlayer reciever =
               plugin
                   .getServer()
                   .getOfflinePlayer(
                       (String) event.getPlayer().getMetadata("give-pet").get(0).value());
           pet.setOwner(reciever);
           event.getPlayer().removeMetadata("give-pet", plugin);
         } else {
           event.getPlayer().sendMessage("This pet is not yours to give");
           event.getPlayer().removeMetadata("give-pet", plugin);
         }
       } else {
         event.getPlayer().sendMessage("This pet is not tamed");
         event.getPlayer().removeMetadata("give-pet", plugin);
       }
     } else {
       event.getPlayer().sendMessage("That entity can not be a pet");
       event.getPlayer().removeMetadata("give-pet", plugin);
     }
   }
 }
Exemplo n.º 6
0
  @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
  public void onPlayerInteractEntity(final PlayerInteractEntityEvent event) {
    Location l = event.getRightClicked().getLocation();

    if (PlotManager.isPlotWorld(l)) {
      Player p = event.getPlayer();
      boolean canbuild = PlotMe.cPerms(p, "plotme.admin.buildanywhere");
      String id = PlotManager.getPlotId(l);

      if (id.equalsIgnoreCase("")) {
        if (!canbuild) {
          p.sendMessage(PlotMe.caption("ErrCannotBuild"));
          event.setCancelled(true);
        }
      } else {
        Plot plot = PlotManager.getPlotById(p, id);

        if (plot == null) {
          if (!canbuild) {
            p.sendMessage(PlotMe.caption("ErrCannotBuild"));
            event.setCancelled(true);
          }
        } else if (!plot.isAllowed(p.getName())) {
          if (!canbuild) {
            p.sendMessage(PlotMe.caption("ErrCannotBuild"));
            event.setCancelled(true);
          }
        } else {
          plot.resetExpire(PlotManager.getMap(l).DaysToExpiration);
        }
      }
    }
  }
 public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
   String eventplayer = event.getPlayer().getName();
   if (admin.freeze.contains(eventplayer)) {
     // cancel here
     event.setCancelled(true);
     event.getPlayer().sendMessage(ChatColor.RED + "Can't do that while frozen!");
   }
 }
Exemplo n.º 8
0
 @EventHandler
 public void onEntityInteract(PlayerInteractEntityEvent event) {
   boolean removed = this.elfs.remove(event.getRightClicked());
   if (removed) {
     event.setCancelled(true);
     ((LivingEntity) event.getRightClicked()).setHealth(0D);
   }
 }
Exemplo n.º 9
0
  /**
   * Give player hunter equipment.
   *
   * @param event
   */
  @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
  public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
    Player player = event.getPlayer();

    if (event.getRightClicked().equals(this.plugin.getNpcIds()[3]) && player.hasPermission(PERM)) {
      player.setItemInHand(Predator.COMPASS);
    }
  }
 @EventHandler
 public void entityInteractEvent(PlayerInteractEntityEvent event) {
   if (!event.isCancelled() && event.getRightClicked() != null) {
     boolean allowed =
         protectionManager.CanUseItem(
             event.getPlayer(), event.getPlayer().getLocation(), ItemType.Item);
     if (!allowed) event.setCancelled(true);
   }
 }
Exemplo n.º 11
0
  /*
   * Another example of a event handler. This one will give you the name of
   * the entity you interact with, if it is a Creature it will give you the
   * creature Id.
   */
  @EventHandler
  public void onPlayerInteract(PlayerInteractEntityEvent event) {
    final EntityType entityType = event.getRightClicked().getType();

    event
        .getPlayer()
        .sendMessage(
            MessageFormat.format(
                "You interacted with a {0} it has an id of {1}",
                entityType.getName(), entityType.getTypeId()));
  }
Exemplo n.º 12
0
  @EventHandler
  public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
    if (!npc.isSpawned()
        || !event.getPlayer().equals(player)
        || !npc.equals(CitizensAPI.getNPCRegistry().getNPC(event.getRightClicked()))) return;

    Equipper equipper = EQUIPPERS.get(npc.getEntity().getType());
    if (equipper == null) equipper = new GenericEquipper();
    equipper.equip(event.getPlayer(), npc);
    event.setCancelled(true);
  }
Exemplo n.º 13
0
  @Override
  public void onInteractEntity(PlayerInteractEntityEvent event, PlayerDetails details) {
    Player player = event.getPlayer();
    Entity entity = event.getRightClicked();
    if (EntityNBT.isValidType(entity.getType())) {
      EntityNBT entityNBT = EntityNBT.fromEntity(entity);
      player.sendMessage(
          ChatColor.YELLOW + "Information about " + EntityTypeMap.getName(entity.getType()) + "");
      for (NBTVariableContainer vc : entityNBT.getAllVariables()) {
        player.sendMessage("" + ChatColor.LIGHT_PURPLE + ChatColor.ITALIC + vc.getName() + ":");
        for (NBTVariable var : vc) {
          String value = var.getValue();
          player.sendMessage(
              "  "
                  + ChatColor.AQUA
                  + var.getName()
                  + ": "
                  + ChatColor.WHITE
                  + (value != null ? value : ChatColor.ITALIC + "none"));
        }
      }
      player.sendMessage(ChatColor.YELLOW + "Extra information:");

      boolean extra = false;
      if (entityNBT instanceof MobNBT) {
        float[] chances = ((MobNBT) entityNBT).getDropChances();
        String[] names = {"head", "chest", "legs", "feet", "hand"};
        player.sendMessage("" + ChatColor.LIGHT_PURPLE + ChatColor.ITALIC + "Drop chance:");
        for (int i = 0; i < 5; ++i) {
          player.sendMessage(
              "  " + ChatColor.AQUA + names[i] + ": " + ChatColor.WHITE + chances[4 - i]);
        }
        extra = true;
      }
      if (entityNBT instanceof VillagerNBT) {
        VillagerNBT villagerNBT = (VillagerNBT) entityNBT;
        player.sendMessage("" + ChatColor.LIGHT_PURPLE + ChatColor.ITALIC + "Trades done:");
        int i = 1;
        for (VillagerNBTOffer offer : villagerNBT.getOffers()) {
          player.sendMessage(
              "  " + ChatColor.AQUA + "trade " + i + ": " + ChatColor.WHITE + offer.getUses());
          ++i;
        }
        extra = true;
      }
      if (!extra) {
        player.sendMessage("none");
      }
      event.setCancelled(true);
    } else {
      player.sendMessage(ChatColor.RED + "Not a valid entity!");
    }
  }
Exemplo n.º 14
0
 @EventHandler
 public void onInteract(PlayerInteractEntityEvent e) {
   Player p = (Player) e.getPlayer();
   if (adminMode.contains(p.getName())) {
     if (p.getInventory()
         .getItemInHand()
         .getItemMeta()
         .getDisplayName()
         .equals(ChatColor.GREEN + "Inventory Checker")) {
       p.performCommand("invsee " + ((Player) e.getRightClicked()).getName());
     }
   }
 }
Exemplo n.º 15
0
  @EventHandler
  public void onPlayerInteractEntity(PlayerInteractEntityEvent e) {
    Player clicker = e.getPlayer();
    if (!Util.isHoldingKickstick(clicker)) return;
    if (!Util.hasPermission(clicker, "kickstick")) return;
    if (e.getRightClicked() == null) return;

    if (e.getRightClicked() instanceof Player) {
      Player clicked = (Player) e.getRightClicked();
      clicked.kickPlayer(Messages.kickedByStick.replace("{A}", clicker.getName()));
      Util.sendMessage(clicker, Messages.adminKickStick.replace("{P}", clicked.getName()));
    }
  }
Exemplo n.º 16
0
 @EventHandler
 public void SpectatorInteractEntity(PlayerInteractEntityEvent event) {
   Player p = event.getPlayer();
   String pname = p.getName();
   for (i = 0; i < plugin.Watching.size(); i++) {
     if (plugin.Watching.get(i) != null) {
       if (plugin.Watching.get(i).contains(pname)) {
         event.setCancelled(true);
         p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
       }
     }
   }
 }
Exemplo n.º 17
0
  private void inGameInteractEntity(PlayerInteractEntityEvent iee, Game game, Player player) {

    if (iee.getPlayer().getItemInHand().getType().equals(Material.MONSTER_EGG)
        || iee.getPlayer().getItemInHand().getType().equals(Material.MONSTER_EGGS)
        || iee.getPlayer().getItemInHand().getType().equals(Material.DRAGON_EGG)) {
      iee.setCancelled(true);
      return;
    }

    if (iee.getRightClicked() != null) {
      if (!iee.getRightClicked().getType().equals(EntityType.VILLAGER)) {
        List<EntityType> preventClickTypes = Arrays.asList(EntityType.ITEM_FRAME);

        // armor stand in 1.8
        try {
          preventClickTypes.add(EntityType.valueOf("ARMOR_STAND"));
        } catch (Exception ex) {
          // nothing will happen, just not supported
        }

        if (preventClickTypes.contains(iee.getRightClicked().getType())) {
          iee.setCancelled(true);
        }

        return;
      }
    }

    iee.setCancelled(true);

    if (game.isSpectator(player)) {
      return;
    }

    BedwarsOpenShopEvent openShopEvent =
        new BedwarsOpenShopEvent(game, player, game.getItemShopCategories(), iee.getRightClicked());
    Main.getInstance().getServer().getPluginManager().callEvent(openShopEvent);

    if (openShopEvent.isCancelled()) {
      return;
    }

    if (game.isUsingOldShop(player)) {
      MerchantCategory.openCategorySelection(player, game);
    } else {
      NewItemShop itemShop = game.getNewItemShop(player);
      if (itemShop == null) {
        itemShop = game.openNewItemShop(player);
      }

      itemShop.setCurrentCategory(null);
      itemShop.openCategoryInventory(player);
    }
  }
Exemplo n.º 18
0
  @Override
  public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
    CraftPlayer player = (CraftPlayer) event.getPlayer();
    if (player.getItemInHand() != null) {
      switch (player.getItemInHand().getType()) {
        case WOOD_HOE:
        case STONE_HOE:
        case IRON_HOE:
        case GOLD_HOE:
        case DIAMOND_HOE:
          break;
        default:
          return;
      }

      Entity ent = event.getRightClicked();
      if (!(ent instanceof Animals)) return;
      Animals a1 = (Animals) ent;
      if (a1.isAdult()) return;

      if (getCooldown() > 0) {
        event
            .getPlayer()
            .sendMessage(
                ChatColor.RED
                    + "Veuillez attendre "
                    + getFormattedTime(getCooldown())
                    + " avant de pouvoir faire cela \u00e0 nouveau.");
        return;
      }

      List<Entity> entities = a1.getNearbyEntities(x, x, z);
      int i = 0;
      int j = count - 1;
      while (i < entities.size() && j > 0) {
        Entity e = entities.get(i);
        if (e instanceof Animals) {
          if (!((Animals) e).isAdult()) {
            ((Animals) e).setAdult();
            --j;
          }
        }
        ++i;
      }

      startCooldown();
    }
  }
Exemplo n.º 19
0
 @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
 public void onPlayerInteractsWithEntity(PlayerInteractEntityEvent event) {
   plugin
       .getServer()
       .getScheduler()
       .runTask(plugin, new ResetIgnoreSleepTask(plugin, event.getPlayer().getName()));
 }
Exemplo n.º 20
0
  @EventHandler
  public void onInteractEntity(PlayerInteractEntityEvent iee) {
    Player p = iee.getPlayer();
    Game g = Main.getInstance().getGameManager().getGameOfPlayer(p);
    if (g == null) {
      return;
    }

    if (g.getState() == GameState.WAITING) {
      iee.setCancelled(true);
      return;
    }

    if (g.getState() == GameState.RUNNING) {
      this.inGameInteractEntity(iee, g, p);
    }
  }
  @EventHandler
  public void interactEvent(PlayerInteractEntityEvent event) {

    /*
    If a LivingEntity was right clicked with a name tag, and stack custom named mobs is false, then follow.
     */
    if (!getPlugin().getConfig().getBoolean("stack-custom-named-mobs")
        && event.getPlayer().getItemInHand().getType() == Material.NAME_TAG
        && event.getRightClicked() instanceof LivingEntity) {

      LivingEntity entity = (LivingEntity) event.getRightClicked();
      ;

      /*
      Initialised blank name tag to get default name if it changes in future updates.
       */
      ItemStack normalNameTag = new ItemStack(Material.NAME_TAG, 1, (byte) 0);

      /*
      Get the item the player is holding.
       */
      ItemStack itemInHand = event.getPlayer().getItemInHand();

      /*
      If the creature has the required data and the name tag isn't blank, then follow.
       */
      if (StackUtils.hasRequiredData(entity)
          && !itemInHand
              .getItemMeta()
              .getDisplayName()
              .equalsIgnoreCase(normalNameTag.getItemMeta().getDisplayName())) {

        /*
        If there is more than one creature in the stack, then peel one off and don't allow it to stack again.
         */
        if (StackUtils.getStackSize(entity) > 1) {

          getPlugin().getStackUtils().peelOffStack(entity, false);

        } else {
          entity.removeMetadata("quantity", getPlugin());
        }
      }
    }
  }
Exemplo n.º 22
0
  @Override
  public boolean onInteractEntity(PlayerInteractEntityEvent e, int level) {
    if (e.getRightClicked() instanceof LivingEntity) {
      LivingEntity le = (LivingEntity) e.getRightClicked();

      le.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 20 * 60, 20 * level));

      if (le instanceof Player) {
        e.getPlayer()
            .sendMessage("You cast " + this.getName() + " on " + ((Player) le).getName() + "!");
        ((Player) le).sendMessage(e.getPlayer().getName() + " cast " + this.getName() + " on you!");
      } else {
        e.getPlayer().sendMessage("You cast " + this.getName() + " on that thing!");
      }

      return true;
    }
    return false;
  }
Exemplo n.º 23
0
  @EventHandler
  public void playerInteractEntityEvent(PlayerInteractEntityEvent e) {
    if (!Minegusta.getServer().containsWorld(e.getPlayer().getWorld())) return;

    DwarfPower rage = DwarfPower.battleCryBoost(e);

    if (rage.isPlayer() && rage.isDwarf() && rage.hasAxe()) {
      rage.applyBattleCryBoost();
    }
  }
  @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
  void onEntityInteract(PlayerInteractEntityEvent event) {
    if (!(event.getRightClicked() instanceof Villager)) return;
    Villager villager = (Villager) event.getRightClicked();

    if (plugin.isShopkeeper(villager)) return; // shopkeeper interaction is handled elsewhere
    Log.debug("Interaction with Non-shopkeeper villager ..");

    if (villager.hasMetadata("NPC")) {
      // ignore any interaction with citizens2 NPCs
      Log.debug("  ignoring (probably citizens2) NPC");
      return;
    }

    Player player = event.getPlayer();
    if (Settings.disableOtherVillagers) {
      // don't allow trading with other villagers
      event.setCancelled(true);
      if (Settings.hireOtherVillagers) {
        // allow hiring of other villagers
        Log.debug("  trade prevented, but possible hire ..");
        if (this.handleHireOtherVillager(player, villager)) {
          // hiring was successful -> prevent normal trading
          Log.debug("    ..success");
        } else {

        }
      } else {
        Log.debug("  trade prevented");
      }
    } else if (Settings.hireOtherVillagers) {
      // allow hiring of other villagers
      Log.debug("  possible hire ..");
      if (this.handleHireOtherVillager(player, villager)) {
        // hiring was successful -> prevent normal trading
        Log.debug("    ..success (normal trading prevented)");
        event.setCancelled(true);
      } else {
        // hiring was not successful -> no preventing of normal villager trading
        Log.debug("    ..failed");
      }
    }
  }
Exemplo n.º 25
0
 @EventHandler(priority = EventPriority.HIGH)
 public void removeItemFromFrame(PlayerInteractEntityEvent event) {
   Entity entity = event.getRightClicked();
   Player p = event.getPlayer();
   if (!entity.getType().equals(EntityType.ITEM_FRAME)) {
     return;
   }
   ItemFrame iFrame = (ItemFrame) entity;
   if (iFrame.getItem() != null && !iFrame.getItem().getType().equals(Material.AIR)) return;
   OwnedLand land = OwnedLand.getApplicableLand(entity.getLocation());
   if (land == null) {
     return;
   }
   if (!land.hasPermTo(p, this)) {
     p.sendMessage(
         ChatColor.RED
             + getPlugin().getMessageConfig().getString("event.build.itemFrameRemoveDirectly"));
     event.setCancelled(true);
   }
 }
Exemplo n.º 26
0
 @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
 public void onClick(PlayerInteractEntityEvent event) {
   Player player = event.getPlayer();
   Entity entity = event.getRightClicked();
   if (entity == null) {
     return;
   }
   if (entity.getType() != EntityType.ITEM_FRAME && entity.getType() != EntityType.ARMOR_STAND) {
     return;
   }
   if (entity.getType() == EntityType.ITEM_FRAME) {
     if (!AllowAction.allowAction(entity.getLocation(), player, FlagManager.ITEMFRAME)) {
       event.setCancelled(true);
     }
   } else {
     if (!AllowAction.allowAction(entity.getLocation(), player, FlagManager.ARMORSTAND)) {
       event.setCancelled(true);
     }
   }
 }
Exemplo n.º 27
0
 @EventHandler
 private void preventRiding(PlayerInteractEntityEvent event) {
   if (checkRules(event.getPlayer().getWorld())) {
     if (event.getRightClicked() instanceof Horse) {
       Horse horse = (Horse) event.getRightClicked();
       if (horse.getOwner() != null) {
         if (horse.getOwner().getUniqueId().equals(event.getPlayer().getUniqueId()) == false) {
           event.getPlayer().sendMessage("This is not your horse!");
           event.setCancelled(!event.getPlayer().isOp());
         }
       }
     }
   }
 }
Exemplo n.º 28
0
 @EventHandler
 public void onEntityInteract(PlayerInteractEntityEvent event) {
   if (event.getRightClicked() instanceof Player == false
       || GameManager.INSTANCE.getSession((Player) event.getRightClicked()) == null) return;
   ItemStack item = event.getPlayer().getItemInHand();
   if (item == null) return;
   Player clicked = (Player) event.getRightClicked();
   if (item.getType().equals(Material.SHEARS)) {
     if (bandage.containsKey(event.getPlayer().getName())
         && bandage
             .get(event.getPlayer().getName())
             .equals(((Player) event.getRightClicked()).getName())) {
       GeneralUtils.addHealthByPaper(clicked);
     } else {
       event.getPlayer().sendMessage("Health: " + clicked.getHealth());
     }
   }
 }
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
    if (event.isCancelled()) return;

    final Player player = event.getPlayer();
    final Entity e = event.getRightClicked();

    if (player.getWorld() != plugin.getIslandWorld()) return;
    if (player.isOp()) return;
    if (player.hasPermission("islandworld.bypass.island")) return;

    if (e instanceof Vehicle) {
      if (!(plugin.getConfig().getBoolean("flags.use-vehicle", false)
          || plugin.canBuildOnLocation(player, e.getLocation()))) event.setCancelled(true);
    } else {
      if (e != null && !plugin.canBuildOnLocation(player, e.getLocation()))
        event.setCancelled(true);
    }

    plugin.debug("Event :" + event.getEventName() + ", cancelled:" + event.isCancelled());
  }
Exemplo n.º 30
0
  @EventHandler
  public void onInteractEntity(PlayerInteractEntityEvent e) {
    if (e.getPlayer().getItemInHand().getType().equals(Material.LEASH)) {
      Entity target = e.getRightClicked();
      if (target == null) return;

      Location loc = target.getLocation();
      if (loc == null) return;

      if (!loc.getWorld().getName().equals("world")) return;

      if (!pl.v().canInteractEntity(e.getPlayer(), e.getRightClicked())) {
        e.getPlayer()
            .sendMessage(pl.TAG + ChatColor.DARK_RED + "Vous ne pouvez utiliser de laisse ici.");
        e.setCancelled(true);
      }
    }
  }