@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);
        }
      }
    }
  }
  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);
    }
  }
Esempio n. 3
0
 @EventHandler
 public void onEntityInteract(PlayerInteractEntityEvent event) {
   boolean removed = this.elfs.remove(event.getRightClicked());
   if (removed) {
     event.setCancelled(true);
     ((LivingEntity) event.getRightClicked()).setHealth(0D);
   }
 }
 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!");
   }
 }
 @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);
   }
 }
  @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");
      }
    }
  }
 @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);
     }
   }
 }
  @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);
  }
Esempio n. 9
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!");
    }
  }
  @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());
  }
Esempio n. 11
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!");
       }
     }
   }
 }
Esempio n. 12
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());
         }
       }
     }
   }
 }
  @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);
    }
  }
Esempio n. 14
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);
      }
    }
  }
Esempio n. 15
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);
   }
 }
Esempio n. 16
0
 @EventHandler
 public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
   if (um.isSpectator(event.getPlayer().getName())) event.setCancelled(true);
 }
Esempio n. 17
0
 @Override
 public void onInteractEntity(PlayerInteractEntityEvent event) {
   //	CivLog.debug("\tMissionBook )
   event.setCancelled(true);
 }
  @EventHandler(priority = EventPriority.HIGH)
  public void onInteractEntity(PlayerInteractEntityEvent event) {
    if (event.getRightClicked() == null) {
      return;
    }

    Entity entity = event.getRightClicked();
    Player player = event.getPlayer();
    if (!player.hasMetadata("bw-addteamjoin")) {
      if (!(entity instanceof LivingEntity)) {
        return;
      }

      LivingEntity livEntity = (LivingEntity) entity;
      Game game = Main.getInstance().getGameManager().getGameOfPlayer(player);
      if (game == null) {
        return;
      }

      if (game.getState() != GameState.WAITING) {
        return;
      }

      Team team = game.getTeam(ChatColor.stripColor(livEntity.getCustomName()));
      if (team == null) {
        return;
      }

      game.playerJoinTeam(player, team);
      event.setCancelled(true);
      return;
    }

    List<MetadataValue> values = player.getMetadata("bw-addteamjoin");
    if (values == null || values.size() == 0) {
      return;
    }

    event.setCancelled(true);
    TeamJoinMetaDataValue value = (TeamJoinMetaDataValue) values.get(0);
    if (!((boolean) value.value())) {
      return;
    }

    if (!(entity instanceof LivingEntity)) {
      player.sendMessage(
          ChatWriter.pluginMessage(ChatColor.RED + Main._l("errors.entitynotcompatible")));
      return;
    }

    LivingEntity living = (LivingEntity) entity;
    living.setRemoveWhenFarAway(false);
    living.setCanPickupItems(false);
    living.setCustomName(value.getTeam().getChatColor() + value.getTeam().getDisplayName());
    living.setCustomNameVisible(
        Main.getInstance().getBooleanConfig("jointeam-entity.show-name", true));

    if (Utils.isSupportingTitles()) {
      if (living.getType().equals(EntityType.valueOf("ARMOR_STAND"))) {
        Utils.equipArmorStand(living, value.getTeam());
      }
    }

    player.removeMetadata("bw-addteamjoin", Main.getInstance());
    player.sendMessage(
        ChatWriter.pluginMessage(
            ChatColor.GREEN
                + Main._l(
                    "success.teamjoinadded",
                    ImmutableMap.of(
                        "team",
                        value.getTeam().getChatColor()
                            + value.getTeam().getDisplayName()
                            + ChatColor.GREEN))));
  }
Esempio n. 19
0
  @EventHandler
  public void onRotate(PlayerInteractEntityEvent event) {
    if (!(event
        .getRightClicked()
        .getType()
        .equals(EntityType.ITEM_FRAME))) { // Before we do anything lets check were interacting with
      // ItemFrames
      return;
    }
    TregminePlayer player = plugin.getPlayer(event.getPlayer());
    if (player.getRank().canModifyZones()) { // Lets people with "canModifyZones"
      return;
    }

    ZoneWorld world = plugin.getWorld(player.getWorld());

    Entity entity = event.getRightClicked();
    Location location = entity.getLocation();
    Point pos = new Point(location.getBlockX(), location.getBlockZ());

    Zone zone = world.findZone(pos);
    Zone.Permission perm = zone.getUser(player);
    Lot lot = world.findLot(pos);

    if (perm != null && perm == Zone.Permission.Banned) { // Eliminate banned from zone
      event.setCancelled(true);
      player.sendMessage(
          ChatColor.RED
              + "["
              + zone.getName()
              + "] "
              + "You are banned from "
              + zone.getName()
              + ".");
    }

    if (zone != null && lot == null) { // If Zone but not Lot
      if (perm == Zone.Permission.Allowed
          || perm == Zone.Permission.Maker
          || perm == Zone.Permission.Owner) { // Checks if player is Allowed/Maker/Owner
        return;
      }
      if (zone.getDestroyDefault()) { // If people can destroy, Then we will let them rotate.
        return;
      }
      // If still at this point then they are not allowed to rotate item frames so BURN THEM ALIVE!!
      player.setFireTicks(50);
      event.setCancelled(true);
      player.sendMessage(
          ChatColor.RED
              + "["
              + zone.getName()
              + "] "
              + "You are not allowed to rotate item frames in "
              + zone.getName()
              + ".");
      return;
    } else if (zone != null && lot != null) { // If lot in a zone
      if (perm == Zone.Permission.Owner
          && zone.isCommunist()) { // Zone owners can modify lots in communist zones
        return;
      }
      if (lot.isOwner(player)) { // Lot owners can always modify lots
        return;
      }
      // If still at this point then they are not allowed to rotate item frames so BURN THEM ALIVE!!
      player.setFireTicks(50);
      event.setCancelled(true);
      player.sendMessage(
          ChatColor.RED
              + "["
              + zone.getName()
              + "] "
              + "You are not allowed to rotate item frames in "
              + zone.getName()
              + ".");
      return;
    } else { // No Zone (obviously No Lot) so just end.
      return;
    }
  }
Esempio n. 20
0
 public static void global_no_ninngen(
     Player pl, final Plugin plugin, final PlayerInteractEntityEvent event) {
   pl.sendMessage(THRPlugin.thrpre + ChatColor.GRAY + "このニンゲンは何を話しているんだろう・・・");
   pl.closeInventory();
   event.setCancelled(true);
 }