org.bukkit.event.player.PlayerFishEvent.State Java Examples
The following examples show how to use
org.bukkit.event.player.PlayerFishEvent.State.
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: Scout.java From AnnihilationPro with MIT License | 6 votes |
@EventHandler(priority = EventPriority.NORMAL) public void Grappler(PlayerFishEvent event) { Player player = event.getPlayer(); if(event.getState() == State.IN_GROUND) { AnniPlayer p = AnniPlayer.getPlayer(player.getUniqueId()); if(p != null && p.getKit().equals(this)) { if(isGrappleItem(player.getItemInHand())) { //event.getHook(). Location playerloc = player.getLocation(); Location loc = event.getHook().getLocation(); if (playerloc.distance(loc) < 3.0D) pullPlayerSlightly(player, loc); else pullEntityToLocation(player, loc); // Vector vec = playerloc.toVector(); // Vector vec2 = loc.toVector(); // player.setVelocity(vec2.subtract(vec).normalize().multiply(1)); player.getItemInHand().setDurability((short)0); } } } }
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: LifeskillingListener.java From EnchantmentsEnhance with GNU General Public License v3.0 | 5 votes |
/** * Fishing gives enhancement stone. * * @param e */ @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH) public void onFishing(PlayerFishEvent e) { // If the fishing is successful if (e.getState().equals(State.CAUGHT_FISH)) { Player player = e.getPlayer(); if (DropManager.fishingChance > random.nextDouble()) { DropManager.randomDrop(player, DropManager.fishingLootTable); } } }
Example #4
Source File: CustomItemFish.java From AdditionsAPI with MIT License | 5 votes |
@EventHandler(priority = EventPriority.MONITOR) public void onCustomItemFish(CustomItemFishEvent customEvent) { if (customEvent.isCancelled()) return; CustomItem cItem = customEvent.getCustomItem(); PlayerFishEvent event = customEvent.getPlayerFishEvent(); Player player = event.getPlayer(); if (cItem.getDurabilityMechanics() instanceof FishingRodDurability) { ItemStack item = customEvent.getCustomItemStack().getItemStack(); State state = event.getState(); FishingRodDurability mechanics = (FishingRodDurability) cItem.getDurabilityMechanics(); PlayerCustomItemDamageEvent damageEvent = new PlayerCustomItemDamageEvent(player, item, 0, cItem); switch (state) { case CAUGHT_ENTITY: if (event.getCaught().getType() == EntityType.DROPPED_ITEM) { damageEvent.setDamage(mechanics.getItemReel()); } else { damageEvent.setDamage(mechanics.getEntityReel()); } break; case CAUGHT_FISH: damageEvent.setDamage(mechanics.getFishCatch()); break; case IN_GROUND: damageEvent.setDamage(mechanics.getBlockReel()); break; default: break; } if (damageEvent.getDamage() != 0) Bukkit.getServer().getPluginManager().callEvent(damageEvent); } }