Java Code Examples for org.bukkit.event.player.PlayerFishEvent#setCancelled()
The following examples show how to use
org.bukkit.event.player.PlayerFishEvent#setCancelled() .
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: CustomItemFish.java From AdditionsAPI with MIT License | 6 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onCustomItemFishLowest(CustomItemFishEvent customEvent) { if (customEvent.isCancelled()) return; CustomItem cItem = customEvent.getCustomItem(); if (!(cItem.getPermissions() instanceof FishingRodPermissions)) return; FishingRodPermissions perm = (FishingRodPermissions) cItem.getPermissions(); PlayerFishEvent event = customEvent.getPlayerFishEvent(); if (!PermissionUtils.allowedAction(event.getPlayer(), perm.getType(), perm.getReel())) event.setCancelled(true); }
Example 2
Source File: DisplayProtectionListener.java From QuickShop-Reremake with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) public void player(PlayerFishEvent event) { if (DisplayItem.getNowUsing() != DisplayType.REALITEM) { return; } if (event.getState() != State.CAUGHT_ENTITY) { return; } if (event.getCaught() == null) { return; } if (event.getCaught().getType() != EntityType.DROPPED_ITEM) { return; } final Item item = (Item) event.getCaught(); final ItemStack is = item.getItemStack(); if (!DisplayItem.checkIsGuardItemStack(is)) { return; } // item.remove(); event.getHook().remove(); // event.getCaught().remove(); event.setCancelled(true); sendAlert( "[DisplayGuard] Player " + event.getPlayer().getName() + " trying hook item use Fishing Rod, QuickShop already removed it."); Util.inventoryCheck(event.getPlayer().getInventory()); }
Example 3
Source File: IslandGuard1_9.java From askyblock with GNU General Public License v2.0 | 5 votes |
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true) public void onRodDamage(final PlayerFishEvent e) { if (e.getPlayer().isOp() || VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) { return; } if (!IslandGuard.inWorld(e.getPlayer().getLocation())) { return; } Player p = e.getPlayer(); if (e.getCaught() != null && (e.getCaught().getType().equals(EntityType.ARMOR_STAND) || e.getCaught().getType().equals(EntityType.ENDER_CRYSTAL))) { if (p.isOp() || VaultHelper.checkPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) { return; } // Check if on island if (plugin.getGrid().playerIsOnIsland(p)) { return; } // Check island Island island = plugin.getGrid().getIslandAt(e.getCaught().getLocation()); if (island == null && Settings.defaultWorldSettings.get(SettingsFlag.BREAK_BLOCKS)) { return; } if (island != null && island.getIgsFlag(SettingsFlag.BREAK_BLOCKS)) { return; } Util.sendMessage(p, ChatColor.RED + plugin.myLocale(p.getUniqueId()).islandProtected); e.getHook().remove(); e.setCancelled(true); } }
Example 4
Source File: IslandGuard.java From askyblock with GNU General Public License v2.0 | 4 votes |
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onFishing(final PlayerFishEvent e) { if (DEBUG) { plugin.getLogger().info("Player fish event " + e.getEventName()); plugin.getLogger().info("Player fish event " + e.getCaught()); } if (e.getCaught() == null) return; Player p = e.getPlayer(); if (!inWorld(p)) { return; } if (p.isOp() || VaultHelper.checkPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) { // You can do anything if you are Op of have the bypass return; } // Handle rods Island island = plugin.getGrid().getProtectedIslandAt(e.getCaught().getLocation()); // PVP check if (e.getCaught() instanceof Player) { // Check if this is the player who is holding the rod if (e.getCaught().equals(e.getPlayer())) { if (DEBUG) plugin.getLogger().info("DEBUG: player cught themselves!"); return; } if (island == null && (e.getCaught().getWorld().getEnvironment().equals(Environment.NORMAL) && !Settings.defaultWorldSettings.get(SettingsFlag.PVP)) || ((e.getCaught().getWorld().getEnvironment().equals(Environment.NETHER) && !Settings.defaultWorldSettings.get(SettingsFlag.NETHER_PVP)))) { Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).targetInNoPVPArea); e.setCancelled(true); e.getHook().remove(); return; } if (island != null && ((e.getCaught().getWorld().getEnvironment().equals(Environment.NORMAL) && !island.getIgsFlag(SettingsFlag.PVP)) || (e.getCaught().getWorld().getEnvironment().equals(Environment.NETHER) && !island.getIgsFlag(SettingsFlag.NETHER_PVP)))) { Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).targetInNoPVPArea); e.setCancelled(true); e.getHook().remove(); return; } } if (!plugin.getGrid().playerIsOnIsland(e.getPlayer())) { if (e.getCaught() instanceof Animals) { if (island == null && !Settings.defaultWorldSettings.get(SettingsFlag.HURT_MOBS)) { Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected); e.setCancelled(true); e.getHook().remove(); return; } if (island != null) { if ((!island.getIgsFlag(SettingsFlag.HURT_MOBS) && !island.getMembers().contains(p.getUniqueId()))) { Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected); e.setCancelled(true); e.getHook().remove(); return; } } } // Monster protection if (e.getCaught() instanceof Monster || e.getCaught() instanceof Squid || e.getCaught() instanceof Slime) { if (island == null && !Settings.defaultWorldSettings.get(SettingsFlag.HURT_MONSTERS)) { Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected); e.setCancelled(true); e.getHook().remove(); return; } if (island != null) { if ((!island.getIgsFlag(SettingsFlag.HURT_MONSTERS) && !island.getMembers().contains(p.getUniqueId()))) { Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected); e.setCancelled(true); e.getHook().remove(); } } } } }
Example 5
Source File: PlayerListener.java From AuthMeReloaded with GNU General Public License v3.0 | 4 votes |
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onPlayerFish(PlayerFishEvent event) { if (listenerService.shouldCancelEvent(event)) { event.setCancelled(true); } }