@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);
}
}
java类org.bukkit.event.player.PlayerFishEvent的实例源码
ExpMultiplierListener.java 文件源码
项目:HCFCore
阅读 26
收藏 0
点赞 0
评论 0
ExpMultiplierListener.java 文件源码
项目:HCFCore
阅读 30
收藏 0
点赞 0
评论 0
@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);
}
}
Scout.java 文件源码
项目:AnnihilationPro
阅读 22
收藏 0
点赞 0
评论 0
@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);
}
}
}
}
FishingListener.java 文件源码
项目:MoreFish
阅读 20
收藏 0
点赞 0
评论 0
@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);
}
}
FishingListener.java 文件源码
项目:MoreFish
阅读 20
收藏 0
点赞 0
评论 0
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);
}
ExprFixFishingGetXP.java 文件源码
项目:Skellett
阅读 24
收藏 0
点赞 0
评论 0
@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());
}
}
AchieveFishListener.java 文件源码
项目:AdvancedAchievements
阅读 25
收藏 0
点赞 0
评论 0
@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);
}
ItemFishingRod.java 文件源码
项目:CraftBukkit
阅读 35
收藏 0
点赞 0
评论 0
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;
}
ItemFishingRod.java 文件源码
项目:Almura-Server
阅读 28
收藏 0
点赞 0
评论 0
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;
}
InteractionListener.java 文件源码
项目:CraftoPlugin
阅读 29
收藏 0
点赞 0
评论 0
@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());
}
}
}
GrappleManager.java 文件源码
项目:ZentrelaRPG
阅读 44
收藏 0
点赞 0
评论 0
@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.");
}
}
}
PGMListener.java 文件源码
项目:ProjectAres
阅读 26
收藏 0
点赞 0
评论 0
@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));
}
}
}
Cutclean.java 文件源码
项目:OpenUHC
阅读 23
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
}
EnchantLimitListener.java 文件源码
项目:HCFCore
阅读 23
收藏 0
点赞 0
评论 0
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerFishEvent(PlayerFishEvent event) {
Entity caught = event.getCaught();
if (caught instanceof Item) {
validateIllegalEnchants(((Item) caught).getItemStack());
}
}
EnchantLimitListener.java 文件源码
项目:HCFCore
阅读 24
收藏 0
点赞 0
评论 0
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerFishEvent(PlayerFishEvent event) {
Entity caught = event.getCaught();
if (caught instanceof Item) {
validateIllegalEnchants(((Item) caught).getItemStack());
}
}
ModuleFishingKnockback.java 文件源码
项目:BukkitOldCombatMechanics
阅读 30
收藏 0
点赞 0
评论 0
/**
* 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);
}
Fishing.java 文件源码
项目:Damocles
阅读 21
收藏 0
点赞 0
评论 0
@EventHandler
public void onPlayerCatchEvent(PlayerFishEvent event){
if(event.getCaught() instanceof Item){
Item drop = (Item)event.getCaught();
drop.setItemStack(new ItemStack(Material.APPLE, 1));
}
}
EvtExperienceSpawn.java 文件源码
项目:Skript
阅读 22
收藏 0
点赞 0
评论 0
@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);
}
FishingEventListener.java 文件源码
项目:world-of-icerealm
阅读 25
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.NORMAL)
public void onFishOn(PlayerFishEvent event) {
if (tournament.isInProgress()) {
Entity theCatch = event.getCaught();
if (theCatch instanceof Item) {
tournament.addCatchToPlayer(event.getPlayer());
}
}
}
FishingListener.java 文件源码
项目:MoreFish
阅读 26
收藏 0
点赞 0
评论 0
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);
}
Listeners.java 文件源码
项目:WorldGuardFix
阅读 28
收藏 0
点赞 0
评论 0
@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.");
}
}
}
ExprFixFishingGetXP.java 文件源码
项目:Skellett
阅读 28
收藏 0
点赞 0
评论 0
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;
}
ExprFishingGetHook.java 文件源码
项目:Skellett
阅读 24
收藏 0
点赞 0
评论 0
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;
}
ExprFishingGetCaught.java 文件源码
项目:Skellett
阅读 22
收藏 0
点赞 0
评论 0
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;
}
ExprFishingState.java 文件源码
项目:Skellett
阅读 52
收藏 0
点赞 0
评论 0
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;
}
TeamManager.java 文件源码
项目:libelula
阅读 22
收藏 0
点赞 0
评论 0
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);
}
}
}
TeamManager.java 文件源码
项目:libelula
阅读 27
收藏 0
点赞 0
评论 0
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);
}
}
}
ItemFishingRod.java 文件源码
项目:Tweakkit-Server
阅读 35
收藏 0
点赞 0
评论 0
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;
}
ItemFishingRod.java 文件源码
项目:Cauldron
阅读 35
收藏 0
点赞 0
评论 0
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_;
}
PlayerListener.java 文件源码
项目:McMMOPlus
阅读 26
收藏 0
点赞 0
评论 0
/**
* 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;
}
}