org.bukkit.event.player.PlayerAttackEntityEvent Java Examples
The following examples show how to use
org.bukkit.event.player.PlayerAttackEntityEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpawnMatchModule.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler public void onAttackEntity(final PlayerAttackEntityEvent event) { MatchPlayer player = match.getPlayer(event.getPlayer()); if (player != null) { State state = states.get(player); if (state != null) state.onEvent(event); } }
Example #2
Source File: EventFilterMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onAttack(final PlayerAttackEntityEvent event) { if(cancelUnlessInteracting(event, event.getPlayer())) { final MatchPlayer attacker = getMatch().getPlayer(event.getPlayer()); if(attacker == null || attacker.isSpawned()) return; getMatch().callEvent(new ObserverInteractEvent(attacker, ClickType.LEFT, null, event.getLeftClicked(), event.getPlayer().getInventory().getItemInMainHand())); } }
Example #3
Source File: BlockBreakRegion.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void onPlayerAttackEntity(PlayerAttackEntityEvent event) { if (event.getLeftClicked() instanceof ItemFrame) { if (region.contains(event.getLeftClicked().getLocation().toVector()) && filter.evaluate(event.getLeftClicked(), event.getPlayer(), event).equals(FilterState.DENY)) { event.setCancelled(true); } } }
Example #4
Source File: BlockEventRegion.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void onPlayerAttackEntity(PlayerAttackEntityEvent event) { if (event.getLeftClicked() instanceof ItemFrame) { if (region.contains(event.getLeftClicked().getLocation().toVector()) && filter.evaluate(event.getLeftClicked(), event.getPlayer(), event).equals(FilterState.DENY)) { event.setCancelled(true); } } }
Example #5
Source File: TntDefuse.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void onPlayerLeftClick(PlayerAttackEntityEvent event) { if (event.getLeftClicked() instanceof TNTPrimed) { if (TntTracker.getWhoPlaced(event.getLeftClicked()) != null) { UUID player = TntTracker.getWhoPlaced(event.getLeftClicked()); Optional<TeamModule> playerTeam = Teams.getTeamByPlayer(Bukkit.getPlayer(player)); if (Bukkit.getOfflinePlayer(player).isOnline()) { if (playerTeam.isPresent() && playerTeam.get().equals(Teams.getTeamByPlayer(event.getPlayer()).orNull()) && Teams.getTeamByPlayer(Bukkit.getPlayer(player)) != null && !playerTeam.get().isObserver()) { if (!event.getLeftClicked().getLocation().getBlock().isLiquid()) { if (!Bukkit.getPlayer(player).equals(event.getPlayer())) { event.getLeftClicked().remove(); event.getPlayer().sendMessage(ChatColor.RED + "You defused " + playerTeam.get().getColor() + Bukkit.getPlayer(player).getDisplayName() + ChatColor.RED + "'s TNT."); ChatChannel channel = GameHandler.getGameHandler().getMatch().getModules().getModule(AdminChannel.class); channel.sendMessage("[" + ChatColor.GOLD + "A" + ChatColor.WHITE + "] " + Teams.getTeamByPlayer(event.getPlayer()).get().getColor() + event.getPlayer().getDisplayName() + ChatColor.RESET + " defused " + playerTeam.get().getColor() + Bukkit.getPlayer(player).getDisplayName() + ChatColor.RESET + "'s " + ChatColor.DARK_RED + "TNT"); } } else { ChatUtil.sendWarningMessage(event.getPlayer(), "You may not defuse TNT in water!"); } } else { ChatUtil.sendWarningMessage(event.getPlayer(), "You may not defuse enemy TNT."); } } else { ChatUtil.sendWarningMessage(event.getPlayer(), "You may not defuse enemy TNT."); } } } }
Example #6
Source File: AttackSpeed.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void onPlayerAttack(PlayerAttackEntityEvent event) { Optional<TeamModule> team = Teams.getTeamByPlayer(event.getPlayer()); if (GameHandler.getGameHandler().getMatch().isRunning() && (!team.isPresent() || !team.get().isObserver())) { sendActionBar(event.getPlayer()); } }
Example #7
Source File: FreezeModule.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void onPlayerClick(PlayerAttackEntityEvent event) { if (event.getPlayer().hasPermission("cardinal.punish.freeze") && event.getLeftClicked() instanceof Player) { ItemStack item = event.getPlayer().getInventory().getItemInMainHand(); if (item != null && item.getType() == Material.ICE && item.getItemMeta() != null && item.getItemMeta().getDisplayName() != null && item.getItemMeta().getDisplayName().equals(ChatColor.AQUA + ChatConstant.UI_FREEZE_ITEM.getMessage(event.getPlayer().getLocale()))) { togglePlayerFreeze((Player) event.getLeftClicked(), event.getPlayer()); } } }
Example #8
Source File: SpectatorTools.java From CardinalPGM with MIT License | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onSpectatorMount(PlayerAttackEntityEvent event) { if (event.getLeftClicked() instanceof Player &&ObserverModule.testObserver(event.getPlayer()) && !ObserverModule.testObserver((Player) event.getLeftClicked()) && event.getPlayer().getGameMode().equals(GameMode.SPECTATOR)) { event.setCancelled(false); } }
Example #9
Source File: Spawning.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
@Override public void onEvent(PlayerAttackEntityEvent event) { super.onEvent(event); event.setCancelled(true); requestSpawn(); }
Example #10
Source File: AntiGriefListener.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void leftClickDefuse(final PlayerAttackEntityEvent event) { this.participantDefuse(event.getPlayer(), event.getLeftClicked()); }
Example #11
Source File: DefuseListener.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void leftClickDefuse(final PlayerAttackEntityEvent event) { this.participantDefuse(event.getPlayer(), event.getLeftClicked()); }
Example #12
Source File: ObserverModule.java From CardinalPGM with MIT License | 4 votes |
@EventHandler public void onEntityAttack(PlayerAttackEntityEvent event) { if (testObserverOrDead(event.getPlayer())) { event.setCancelled(true); } }
Example #13
Source File: State.java From PGM with GNU Affero General Public License v3.0 | votes |
public void onEvent(final PlayerAttackEntityEvent event) {}