Java Code Examples for org.bukkit.event.player.PlayerFishEvent#getCaught()
The following examples show how to use
org.bukkit.event.player.PlayerFishEvent#getCaught() .
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: PGMListener.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler public void nerfFishing(PlayerFishEvent event) { if (event.getCaught() instanceof Item) { Item caught = (Item) event.getCaught(); if (caught.getItemStack().getType() != Material.RAW_FISH) { caught.setItemStack(new ItemStack(Material.RAW_FISH)); } } }
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: PGMListener.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler public void nerfFishing(PlayerFishEvent event) { if (Config.Fishing.disableTreasure() && event.getCaught() instanceof Item) { Item caught = (Item) event.getCaught(); if (caught.getItemStack().getType() != Material.RAW_FISH) { caught.setItemStack(new ItemStack(Material.RAW_FISH)); } } }
Example 4
Source File: ItemsCaughtListener.java From Statz with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onFishCaught(final PlayerFishEvent event) { final PlayerStat stat = PlayerStat.ITEMS_CAUGHT; // Get player final Player player = event.getPlayer(); // Do general check if (!plugin.doGeneralCheck(player, stat)) return; Entity entity; ItemStack item; String materialName = null; if (event.getCaught() != null) { entity = event.getCaught(); if (!(entity instanceof Item)) { return; // Did not catch an item } item = ((Item) entity).getItemStack(); materialName = item.getType().name(); } else { // Did not catch anything. return; } PlayerStatSpecification specification = new ItemsCaughtSpecification(player.getUniqueId(), item.getAmount(), player.getWorld().getName(), item.getType()); // Update value to new stat. plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, specification.constructQuery()); }
Example 5
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 6
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(); } } } } }