Java 类org.bukkit.event.player.PlayerFishEvent 实例源码

项目:HCFCore    文件:ExpMultiplierListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerFish(PlayerFishEvent event) {
    double amount = event.getExpToDrop();
    if (amount > 0) {
        amount = Math.ceil(amount * SettingsYML.EXP_MULTIPLIER_FISHING);
        ProjectileSource projectileSource = event.getHook().getShooter();
        if (projectileSource instanceof Player) {
            ItemStack stack = ((Player) projectileSource).getItemInHand();
            int enchantmentLevel = stack.getEnchantmentLevel(Enchantment.LUCK);
            if (enchantmentLevel > 0L) {
                amount = Math.ceil(amount * (enchantmentLevel * SettingsYML.EXP_MULTIPLIER_LUCK_PER_LEVEL));
            }
        }

        event.setExpToDrop((int) amount);
    }
}
项目:HCFCore    文件:ExpMultiplierListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerFish(PlayerFishEvent event) {
    double amount = event.getExpToDrop();
    if (amount > 0) {
        amount = Math.ceil(amount * SettingsYML.EXP_MULTIPLIER_FISHING);
        ProjectileSource projectileSource = event.getHook().getShooter();
        if (projectileSource instanceof Player) {
            ItemStack stack = ((Player) projectileSource).getItemInHand();
            int enchantmentLevel = stack.getEnchantmentLevel(Enchantment.LUCK);
            if (enchantmentLevel > 0L) {
                amount = Math.ceil(amount * (enchantmentLevel * SettingsYML.EXP_MULTIPLIER_LUCK_PER_LEVEL));
            }
        }

        event.setExpToDrop((int) amount);
    }
}
项目:AnnihilationPro    文件:Scout.java   
@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);
                }
            }
        }
    }
项目:MoreFish    文件:FishingListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onFish(PlayerFishEvent event) {
    if (event.getState() == PlayerFishEvent.State.CAUGHT_FISH && event.getCaught() instanceof Item) {
        if (!contest.hasStarted() && plugin.getConfig().getBoolean("general.no-fishing-unless-contest")) {
            event.setCancelled(true);

            String msg = plugin.getLocale().getString("no-fishing-allowed");
            event.getPlayer().sendMessage(msg);
            return;
        }
        if (!isFishingEnabled(event)) {
            return;
        }

        executeFishingActions(event.getPlayer(), event);
    }
}
项目:MoreFish    文件:FishingListener.java   
private void executeFishingActions(Player catcher, PlayerFishEvent event) {
    CaughtFish fish = plugin.getFishManager().generateRandomFish(catcher);

    PlayerCatchCustomFishEvent customEvent = new PlayerCatchCustomFishEvent(catcher, fish, event);
    plugin.getServer().getPluginManager().callEvent(customEvent);

    if (customEvent.isCancelled()) {
        return;
    }

    boolean new1st = contest.hasStarted() && contest.isNew1st(fish);
    announceMessages(catcher, fish, new1st);

    if (fish.getRarity().hasFirework())
        launchFirework(catcher.getLocation().add(0, 1, 0));
    if (!fish.getCommands().isEmpty())
        executeCommands(catcher, fish);

    if (new1st) {
        contest.addRecord(catcher, fish);
    }

    ItemStack itemStack = plugin.getFishManager().getItemStack(fish, event.getPlayer().getName());
    Item caught = (Item) event.getCaught();
    caught.setItemStack(itemStack);
}
项目:Skellett    文件:ExprFixFishingGetXP.java   
@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode){
    Number xp = (Number)delta[0];
    Number xpNow = ((PlayerFishEvent)e).getExpToDrop();
    if (mode == ChangeMode.SET) {
        ((PlayerFishEvent)e).setExpToDrop(xp.intValue());
    }
    if (mode == ChangeMode.ADD) {
        ((PlayerFishEvent)e).setExpToDrop(xpNow.intValue() + xp.intValue());
    }
    if (mode == ChangeMode.REMOVE) {
        ((PlayerFishEvent)e).setExpToDrop(xpNow.intValue() - xp.intValue());
    }
    if (mode == ChangeMode.RESET) {
        ((PlayerFishEvent)e).setExpToDrop(xpNow.intValue());
    }
}
项目:AdvancedAchievements    文件:AchieveFishListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerFish(PlayerFishEvent event) {
    if (event.getState() != PlayerFishEvent.State.CAUGHT_FISH) {
        return;
    }

    Player player = event.getPlayer();
    NormalAchievements category;
    Item caughtItem = (Item) event.getCaught();
    if (caughtItem.getItemStack().getType() == Material.RAW_FISH) {
        category = NormalAchievements.FISH;
    } else {
        category = NormalAchievements.TREASURES;
    }

    if (plugin.getDisabledCategorySet().contains(category.toString())) {
        return;
    }

    if (!shouldIncreaseBeTakenIntoAccount(player, category)) {
        return;
    }

    updateStatisticAndAwardAchievementsIfAvailable(player, category, 1);
}
项目:CraftBukkit    文件:ItemFishingRod.java   
public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) {
    if (entityhuman.hookedFish != null) {
        int i = entityhuman.hookedFish.e();

        itemstack.damage(i, entityhuman);
        entityhuman.ba();
    } else {
        // CraftBukkit start
        EntityFishingHook hook = new EntityFishingHook(world, entityhuman);
        PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, (org.bukkit.entity.Fish) hook.getBukkitEntity(), PlayerFishEvent.State.FISHING);
        world.getServer().getPluginManager().callEvent(playerFishEvent);

        if (playerFishEvent.isCancelled()) {
            return itemstack;
        }
        // CraftBukkit end
        world.makeSound(entityhuman, "random.bow", 0.5F, 0.4F / (g.nextFloat() * 0.4F + 0.8F));
        if (!world.isStatic) {
            world.addEntity(hook); // CraftBukkit - moved creation up
        }

        entityhuman.ba();
    }

    return itemstack;
}
项目:Almura-Server    文件:ItemFishingRod.java   
public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) {
    if (entityhuman.hookedFish != null) {
        int i = entityhuman.hookedFish.c();

        itemstack.damage(i, entityhuman);
        entityhuman.aV();
    } else {
        // CraftBukkit start
        EntityFishingHook hook = new EntityFishingHook(world, entityhuman);
        PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, (org.bukkit.entity.Fish) hook.getBukkitEntity(), PlayerFishEvent.State.FISHING);
        world.getServer().getPluginManager().callEvent(playerFishEvent);

        if (playerFishEvent.isCancelled()) {
            return itemstack;
        }
        // CraftBukkit end
        world.makeSound(entityhuman, "random.bow", 0.5F, 0.4F / (f.nextFloat() * 0.4F + 0.8F));
        if (!world.isStatic) {
            world.addEntity(hook); // CraftBukkit - moved creation up
        }

        entityhuman.aV();
    }

    return itemstack;
}
项目:CraftoPlugin    文件:InteractionListener.java   
@EventHandler
public void onFish(PlayerFishEvent event) {
    debug("PlayerFishEvent(%s, %s, %s) called", event.getCaught(),
            event.getState(), event.getPlayer().getName());

    if (!event.getState().equals(PlayerFishEvent.State.CAUGHT_ENTITY) || event.getCaught() == null) {
        return;
    }

    EntityProtection protection = this.module.getProtection(event.getCaught().getUniqueId()).orElse(null);
    if (protection == null) { return; }

    if (!this.module.isAllowedToInteract(protection, event.getPlayer())) {
        event.setCancelled(true);

        // Only notify every 15 seconds
        Instant lastNotification = this.notifiedMap.getOrDefault(event.getPlayer().getUniqueId(), Instant.MIN);
        if (Duration.between(lastNotification, Instant.now()).getSeconds() > 15) {
            sendFailure(event.getPlayer(), "Dieses Objekt wurde von "
                    + protection.getOwner().getName() + " gesichert und du darfst nicht damit interagieren.");

            this.notifiedMap.put(event.getPlayer().getUniqueId(), Instant.now());
        }
    }
}
项目:ZentrelaRPG    文件:GrappleManager.java   
@EventHandler
public void onPlayerFishEvent(PlayerFishEvent event) {
    Fish hook = event.getHook();
    if (event.getState() != PlayerFishEvent.State.FISHING) {
        boolean isBlock = false;
        for (int dx = -1; dx <= 1; dx++) {
            for (int dy = -1; dy <= 1; dy++) {
                for (int dz = -1; dz <= 1; dz++) {
                    if (!RParticles.isAirlike(hook.getWorld().getBlockAt(hook.getLocation().getBlockX() + dx, hook.getLocation().getBlockY() + dy, hook.getLocation().getBlockZ() + dz))) {
                        isBlock = true;
                        break;
                    }
                }
            }
        }
        try {
            event.getPlayer().getEquipment().getItemInMainHand().setDurability((short) 0);
        } catch (Exception e) {

        }
        if (isBlock) {
            pullEntityToLocation(event.getPlayer(), hook.getLocation());
        } else {
            event.getPlayer().sendMessage(ChatColor.RED + "Your grapple wasn't hooked on anything.");
        }
    }
}
项目:ProjectAres    文件:PGMListener.java   
@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));
        }
    }
}
项目:OpenUHC    文件:Cutclean.java   
/**
 * Drops cooked fish whenever a player is fishing and receives raw fish.
 *
 * @param event The event
 */
@EventHandler(ignoreCancelled = true)
public void onPlayerFish(PlayerFishEvent event) {
  Entity caught = event.getCaught();
  if (caught instanceof ItemStack) {
    ItemStack fish = (ItemStack) caught;
    if (fish.getType().equals(Material.RAW_FISH)) {
      fish.setType(Material.COOKED_FISH);
    }
  }
}
项目:HCFCore    文件:EnchantLimitListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerFishEvent(PlayerFishEvent event) {
    Entity caught = event.getCaught();
    if (caught instanceof Item) {
        validateIllegalEnchants(((Item) caught).getItemStack());
    }
}
项目:HCFCore    文件:EnchantLimitListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerFishEvent(PlayerFishEvent event) {
    Entity caught = event.getCaught();
    if (caught instanceof Item) {
        validateIllegalEnchants(((Item) caught).getItemStack());
    }
}
项目:BukkitOldCombatMechanics    文件:ModuleFishingKnockback.java   
/**
 * This is to cancel dragging the player closer when you reel in
 */
@EventHandler(priority = EventPriority.HIGHEST)
private void onReelIn(PlayerFishEvent e){
    if(!isSettingEnabled("cancelDraggingIn") || e.getState() != PlayerFishEvent.State.CAUGHT_ENTITY) return;
    e.getHook().remove(); //Nuke the bobber and don't do anything else
    e.setCancelled(true);
}
项目:Damocles    文件:Fishing.java   
@EventHandler
public void onPlayerCatchEvent(PlayerFishEvent event){
    if(event.getCaught() instanceof Item){
        Item drop = (Item)event.getCaught();
        drop.setItemStack(new ItemStack(Material.APPLE, 1));
    }
}
项目:Skript    文件:EvtExperienceSpawn.java   
@SuppressWarnings("unchecked")
private final static void registerExecutor() {
    if (registeredExecutor)
        return;
    for (final Class<? extends Event> c : new Class[] {BlockExpEvent.class, EntityDeathEvent.class, ExpBottleEvent.class, PlayerFishEvent.class})
        Bukkit.getPluginManager().registerEvent(c, new Listener() {}, SkriptConfig.defaultEventPriority.value(), executor, Skript.getInstance(), true);
}
项目:world-of-icerealm    文件:FishingEventListener.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onFishOn(PlayerFishEvent event) {
    if (tournament.isInProgress()) {
        Entity theCatch = event.getCaught();

        if (theCatch instanceof Item) {
            tournament.addCatchToPlayer(event.getPlayer());
        }
    }
}
项目:MoreFish    文件:FishingListener.java   
private boolean isFishingEnabled(PlayerFishEvent event) {
    // Check if the world hasn't disabled
    if (plugin.getConfig().getStringList("general.contest-disabled-worlds")
            .contains(event.getPlayer().getWorld().getName()))
        return false;

    // Check if the contest is ongoing
    if (plugin.getConfig().getBoolean("general.only-for-contest") &&
            !contest.hasStarted())
        return false;

    // Check if the caught is fish
    return (!plugin.getConfig().getBoolean("general.replace-only-fish") ||
            ((Item) event.getCaught()).getItemStack().getType() == Material.RAW_FISH);
}
项目:WorldGuardFix    文件:Listeners.java   
@EventHandler(ignoreCancelled = true)
public void disableFishingRodPull(PlayerFishEvent e) {

    if (e.getCaught() instanceof Player
            && config.checkEnabled(Config.Node.FISHING_HOOK, e.getCaught().getLocation())) {

        final Player shooter = e.getPlayer();
        Player caught = (Player) e.getCaught();

        if (!shooter.equals(caught) && !helper.isPvPAllowed(shooter, caught)) {

            final int heldSlot = shooter.getInventory().getHeldItemSlot();
            shooter.getInventory().setHeldItemSlot((heldSlot + 1) % 9);

            Bukkit.getScheduler().runTaskLater(WorldGuardFix.getInstance(), new Runnable() {
                @Override
                public void run() {
                    shooter.getInventory().setHeldItemSlot(heldSlot);
                }
            }, 2L);

            e.setCancelled(true);
            shooter.sendMessage(ChatColor.RED.toString() + ChatColor.BOLD
                        + "Hey!" + ChatColor.GRAY + " Sorry, but you can't PvP here.");
        }
    }
}
项目:Skellett    文件:ExprFixFishingGetXP.java   
public boolean init(Expression<?>[] args, int arg1, Kleenean arg2, SkriptParser.ParseResult arg3) {
    if (!ScriptLoader.isCurrentEvent(PlayerFishEvent.class)) {
        Skript.error("You can not use Get XP expression in any event but 'on fishing:' event!");
        return false;
    }
    return true;
}
项目:Skellett    文件:ExprFishingGetHook.java   
public boolean init(Expression<?>[] args, int arg1, Kleenean arg2, SkriptParser.ParseResult arg3) {
    if (!ScriptLoader.isCurrentEvent(PlayerFishEvent.class)) {
        Skript.error("You can not use Get Hook expression in any event but 'on fishing:' event!");
        return false;
    }
    return true;
}
项目:Skellett    文件:ExprFishingGetCaught.java   
public boolean init(Expression<?>[] args, int arg1, Kleenean arg2, SkriptParser.ParseResult arg3) {
    if (!ScriptLoader.isCurrentEvent(PlayerFishEvent.class)) {
        Skript.error("You can not use Get Caught expression in any event but 'on fishing:' event!");
        return false;
    }
    return true;
}
项目:Skellett    文件:ExprFishingState.java   
public boolean init(Expression<?>[] args, int arg1, Kleenean arg2, SkriptParser.ParseResult arg3) {
    if (!ScriptLoader.isCurrentEvent(PlayerFishEvent.class)) {
        Skript.error("You can not use Fishing State expression in any event but 'on fishing:' event!");
        return false;
    }
    return true;
}
项目:libelula    文件:TeamManager.java   
public void cancelSameTeam(PlayerFishEvent e) {
    if (e.getCaught() instanceof Player) {
        Player damager = e.getPlayer();
        Player player = (Player) e.getCaught();
        TeamId playerTeam = plugin.pm.getTeamId(player);
        TeamId damagerTeam = plugin.pm.getTeamId(damager);
        if (playerTeam == damagerTeam) {
            e.setCancelled(true);
        }
    }
}
项目:libelula    文件:TeamManager.java   
public void cancelSameTeam(PlayerFishEvent e) {
    if (e.getCaught() instanceof Player) {
        Player damager = e.getPlayer();
        Player player = (Player) e.getCaught();
        TeamId playerTeam = plugin.pm.getTeamId(player);
        TeamId damagerTeam = plugin.pm.getTeamId(damager);
        if (playerTeam == damagerTeam) {
            e.setCancelled(true);
        }
    }
}
项目:Tweakkit-Server    文件:ItemFishingRod.java   
public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) {
    if (entityhuman.hookedFish != null) {
        int i = entityhuman.hookedFish.e();

        itemstack.damage(i, entityhuman);
        entityhuman.ba();
    } else {
        // CraftBukkit start
        EntityFishingHook hook = new EntityFishingHook(world, entityhuman);
        PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, (org.bukkit.entity.Fish) hook.getBukkitEntity(), PlayerFishEvent.State.FISHING);
        world.getServer().getPluginManager().callEvent(playerFishEvent);

        if (playerFishEvent.isCancelled()) {
            entityhuman.hookedFish = null;
            return itemstack;
        }
        // CraftBukkit end
        world.makeSound(entityhuman, "random.bow", 0.5F, 0.4F / (g.nextFloat() * 0.4F + 0.8F));
        if (!world.isStatic) {
            world.addEntity(hook); // CraftBukkit - moved creation up
        }

        entityhuman.ba();
    }

    return itemstack;
}
项目:Cauldron    文件:ItemFishingRod.java   
public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_)
{
    if (p_77659_3_.fishEntity != null)
    {
        int i = p_77659_3_.fishEntity.func_146034_e();
        p_77659_1_.damageItem(i, p_77659_3_);
        p_77659_3_.swingItem();
    }
    else
    {
        // CraftBukkit start
        EntityFishHook hook = new EntityFishHook(p_77659_2_, p_77659_3_);
        PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) p_77659_3_.getBukkitEntity(), null, (org.bukkit.entity.Fish) hook.getBukkitEntity(), PlayerFishEvent.State.FISHING);
        p_77659_2_.getServer().getPluginManager().callEvent(playerFishEvent);

        if (playerFishEvent.isCancelled())
        {
            return p_77659_1_;
        }

        // CraftBukkit end
        p_77659_2_.playSoundAtEntity(p_77659_3_, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!p_77659_2_.isRemote)
        {
            p_77659_2_.spawnEntityInWorld(hook); // CraftBukkit - moved creation up
        }

        p_77659_3_.swingItem();
    }

    return p_77659_1_;
}
项目:McMMOPlus    文件:PlayerListener.java   
/**
 * Monitor PlayerFishEvents.
 * <p>
 * These events are monitored for the purpose of handling the various
 * Fishing skills and abilities.
 *
 * @param event The event to monitor
 */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerFishMonitor(PlayerFishEvent event) {
    Player player = event.getPlayer();

    if (!UserManager.hasPlayerDataKey(player) || !SkillType.FISHING.getPermissions(player)) {
        return;
    }

    FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
    Entity caught = event.getCaught();

    switch (event.getState()) {
        case FISHING:
            if (fishingManager.canMasterAngler()) {
                fishingManager.masterAngler(event.getHook());
            }
            return;

        case CAUGHT_FISH:
            fishingManager.handleFishing((Item) caught);
            return;

        case CAUGHT_ENTITY:
            if (fishingManager.canShake(caught)) {
                fishingManager.shakeCheck((LivingEntity) caught);
            }
            return;

        default:
            return;
    }
}
项目:EnchantmentAPI    文件:FishingListener.java   
@EventHandler
public void onCatch(final PlayerFishEvent event) {
    if (!(event.getCaught() instanceof Item))
        return;

    final Item caught = (Item)event.getCaught();
    final ItemStack item = caught.getItemStack();
    if (!Enchantments.getAllEnchantments(item).isEmpty()) {
        Enchantments.removeAllEnchantments(item);
        mechanics.generateEnchantments(event.getPlayer(), item, bookLevel, false, random.nextLong())
                .getEnchantments().forEach((enchant, level) -> enchant.addToItem(item, level));
        caught.setItemStack(item);
    }
}
项目:Wayward    文件:PlayerFishListener.java   
@EventHandler(priority = EventPriority.LOW)
public void onPlayerFish(PlayerFishEvent event) {
    if (event.getState() == PlayerFishEvent.State.CAUGHT_FISH) {
        event.getCaught().remove();
        int roll = random.nextInt(101);
        if (roll > (100 - (getFishingConfig().getInt("chance") + 1))) {
            event.getPlayer().sendMessage(ChatColor.YELLOW + "The caught fish looks a bit off...");
        } else {
            roll = random.nextInt(fish.size() + 1);
            event.getPlayer().getWorld().dropItemNaturally(event.getHook().getLocation(), fish.get(roll)).setVelocity(reelVelocity(event.getPlayer(), event.getHook()));
        }
    }
}
项目:SpigotSource    文件:ItemFishingRod.java   
public InteractionResultWrapper<ItemStack> a(ItemStack itemstack, World world, EntityHuman entityhuman, EnumHand enumhand) {
    if (entityhuman.hookedFish != null) {
        int i = entityhuman.hookedFish.j();

        itemstack.damage(i, entityhuman);
        entityhuman.a(enumhand);
    } else {
        // CraftBukkit start
        EntityFishingHook hook = new EntityFishingHook(world, entityhuman);
        PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, (org.bukkit.entity.Fish) hook.getBukkitEntity(), PlayerFishEvent.State.FISHING);
        world.getServer().getPluginManager().callEvent(playerFishEvent);

        if (playerFishEvent.isCancelled()) {
            entityhuman.hookedFish = null;
            return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack);
        }
        // CraftBukkit end
        world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.H, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.j.nextFloat() * 0.4F + 0.8F));
        if (!world.isClientSide) {
            world.addEntity(hook); // CraftBukkit - moved creation up
        }

        entityhuman.a(enumhand);
        entityhuman.b(StatisticList.b((Item) this));
    }

    return new InteractionResultWrapper(EnumInteractionResult.SUCCESS, itemstack);
}
项目:simple-survival-games    文件:SSGPlayerListener.java   
@EventHandler
public void onPlayerFish(PlayerFishEvent event) {
    Player p = event.getPlayer();
    ArenaManager am = SimpleSurvivalGames.instance.getArenaManager();

    // Is the current player playing
    if(am.isInArena(p)) {
        ArenaPlayer ap = am.getPlayer(p);

        // Is the player in the lobby of the arena
        if(ap.isInLobby()) {

            // Has the player a arena spawn assigned
            if(ap.hasAssignedAreanSpawn()) {

                // Cancel the event and send a status message
                event.setCancelled(true);
                p.sendMessage(ChatColor.DARK_RED + "You can't fish inside the lobby of an arena!");
            }
        }

        // Is the player an spectators
        if(ap.isSpectator()) {
            event.setCancelled(true);
            ap.sendMessage(ChatColor.DARK_RED + "You can't fish while spectating!");
        }
    }
}
项目:AuthMeReloaded    文件:PlayerListenerTest.java   
@Test
public void shouldHandleSimpleCancelableEvents() {
    withServiceMock(listenerService)
        .check(listener::onPlayerShear, PlayerShearEntityEvent.class)
        .check(listener::onPlayerFish, PlayerFishEvent.class)
        .check(listener::onPlayerBedEnter, PlayerBedEnterEvent.class)
        .check(listener::onPlayerDropItem, PlayerDropItemEvent.class)
        .check(listener::onPlayerHitPlayerEvent, EntityDamageByEntityEvent.class)
        .check(listener::onPlayerConsumeItem, PlayerItemConsumeEvent.class)
        .check(listener::onPlayerInteract, PlayerInteractEvent.class)
        .check(listener::onPlayerPickupItem, PlayerPickupItemEvent.class)
        .check(listener::onPlayerInteractEntity, PlayerInteractEntityEvent.class);
}
项目:Craft-city    文件:ItemFishingRod.java   
public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) {
    if (entityhuman.hookedFish != null) {
        int i = entityhuman.hookedFish.c();

        itemstack.damage(i, entityhuman);
        entityhuman.bK();
    } else {
        // CraftBukkit start
        EntityFishingHook hook = new EntityFishingHook(world, entityhuman);
        PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, (org.bukkit.entity.Fish) hook.getBukkitEntity(), PlayerFishEvent.State.FISHING);
        world.getServer().getPluginManager().callEvent(playerFishEvent);

        if (playerFishEvent.isCancelled()) {
            return itemstack;
        }
        // CraftBukkit end

        world.makeSound(entityhuman, "random.bow", 0.5F, 0.4F / (e.nextFloat() * 0.4F + 0.8F));
        if (!world.isStatic) {
            world.addEntity(hook); // CraftBukkit - moved creation up
        }

        entityhuman.bK();
    }

    return itemstack;
}
项目:RoyalSurvivors    文件:SurvivorsListener.java   
@EventHandler
public void onFish(PlayerFishEvent e) {
    Player p = e.getPlayer();
    if (!RUtils.isInInfectedWorld(p)) return;
    e.setExpToDrop(0);
    PConfManager pcm = PConfManager.getPConfManager(p);
    float thirst = pcm.getFloat("thirst");
    if (!pcm.isSet("thirst")) {
        thirst = 1F;
        pcm.set("thirst", thirst);
    }
    p.setExp(thirst);
}
项目:MoreFish    文件:PlayerCatchCustomFishEvent.java   
public PlayerCatchCustomFishEvent(Player who, CaughtFish fish, PlayerFishEvent fishEvent) {
    super(who);
    this.fish = fish;
    this.fishEvent = fishEvent;
}
项目:MoreFish    文件:PlayerCatchCustomFishEvent.java   
public PlayerFishEvent getPlayerFishEvent() {
    return fishEvent;
}
项目:QuestManager    文件:FishingSkill.java   
@EventHandler
public void onPlayerFish(PlayerFishEvent e) {
    if (e.getState() != PlayerFishEvent.State.CAUGHT_FISH) {
        return;
    }

    if (!QuestManagerPlugin.questManagerPlugin.getPluginConfiguration().getWorlds()
            .contains(e.getPlayer().getWorld().getName())) {
        return;
    }


    //e.setCancelled(true);
    e.getCaught().remove();

    QuestPlayer qp = QuestManagerPlugin.questManagerPlugin.getPlayerManager().getPlayer(e.getPlayer());
    int level = qp.getSkillLevel(this);

    FishRecord record = getFish(level, e.getHook().getLocation());
    if (record == null) {
        e.getPlayer().sendMessage(BAD_RANGE_MESSAGE);
        return;
    }

    FishEvent event = new FishEvent(qp, new QualityItem(record.icon), record.difficulty);
    Bukkit.getPluginManager().callEvent(event);

    if (event.isCancelled()) {
        return;
    }

    int deltaDifficulty = Math.max(0, record.difficulty - level);
    double obstacleTime, obstacleDeviation, completionTime;
    int rows, amount;
    float reelDifficulty, reelDeviation;


    obstacleTime = baseObstacleDifficulty + (deltaDifficulty * obstacleDifficultyRate);
    obstacleDeviation = baseObstacleDeviation;
    completionTime = baseTimePerDifficulty * record.difficulty;
    rows = (int) Math.min(5, Math.max(1, 1 + ((int) record.difficulty / (int) difficultyPerRow)));
    amount = 1 + (int) Math.floor(extraFishPerLevel * Math.max(level - record.difficulty, 0));
    reelDifficulty = baseReelDifficulty + (reelDifficultyRate * deltaDifficulty);
    reelDeviation = baseReelDeviation;

    ////////Modifer Code - Move to eventhandler if mechs moved out of skill/////////

    event.setObstacleDifficultyModifier(event.getObstacleDifficultyModifier()
            - (obstacleDifficultyDiscount * level));
    event.setReelDifficultyModifier(event.getReelDifficultyModifier()
            - (reelDifficultyDiscount * level));
    event.setTimeModifier(event.getTimeModifier() - (timeDiscount * level));
    event.setQualityModifier(event.getQualityModifier() + (level * qualityRate));

    ////////////////////////////////////////////////////////////////////////////////

    //apply modifiers
    obstacleTime *= event.getObstacleDifficultyModifier();
    obstacleDeviation *= event.getObstacleDeviationModifier();
    completionTime *= event.getTimeModifier();
    reelDifficulty *= event.getReelDifficultyModifier();
    reelDeviation *= event.getReelDeviationModifier();

    QualityItem reward = new QualityItem(record.icon.clone());
    reward.getUnderlyingItem().setAmount(amount);
    reward.setQuality(reward.getQuality() * event.getQualityModifier());

    FishingGui gui = new FishingGui(e.getPlayer(), reward, record.difficulty, rows,
            reelDifficulty, reelDeviation, letRate, obstacleTime, obstacleDeviation, completionTime);
    InventoryMenu menu = new InventoryMenu(qp, gui);
    QuestManagerPlugin.questManagerPlugin.getInventoryGuiHandler().showMenu(e.getPlayer(), menu);
    gui.start();

}