本文整理汇总了Java中org.bukkit.event.player.PlayerFishEvent类的典型用法代码示例。如果您正苦于以下问题:Java PlayerFishEvent类的具体用法?Java PlayerFishEvent怎么用?Java PlayerFishEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PlayerFishEvent类属于org.bukkit.event.player包,在下文中一共展示了PlayerFishEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerFish
import org.bukkit.event.player.PlayerFishEvent; //导入依赖的package包/类
@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);
}
}
示例2: Grappler
import org.bukkit.event.player.PlayerFishEvent; //导入依赖的package包/类
@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);
}
}
}
}
示例3: onFish
import org.bukkit.event.player.PlayerFishEvent; //导入依赖的package包/类
@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);
}
}
示例4: executeFishingActions
import org.bukkit.event.player.PlayerFishEvent; //导入依赖的package包/类
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);
}
示例5: change
import org.bukkit.event.player.PlayerFishEvent; //导入依赖的package包/类
@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());
}
}
示例6: onPlayerFish
import org.bukkit.event.player.PlayerFishEvent; //导入依赖的package包/类
@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);
}
示例7: a
import org.bukkit.event.player.PlayerFishEvent; //导入依赖的package包/类
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;
}
示例8: a
import org.bukkit.event.player.PlayerFishEvent; //导入依赖的package包/类
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;
}
示例9: onFish
import org.bukkit.event.player.PlayerFishEvent; //导入依赖的package包/类
@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());
}
}
}
示例10: onPlayerFishEvent
import org.bukkit.event.player.PlayerFishEvent; //导入依赖的package包/类
@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.");
}
}
}
示例11: nerfFishing
import org.bukkit.event.player.PlayerFishEvent; //导入依赖的package包/类
@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));
}
}
}
示例12: onPlayerFish
import org.bukkit.event.player.PlayerFishEvent; //导入依赖的package包/类
/**
* 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);
}
}
}
示例13: onPlayerFishEvent
import org.bukkit.event.player.PlayerFishEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerFishEvent(PlayerFishEvent event) {
Entity caught = event.getCaught();
if (caught instanceof Item) {
validateIllegalEnchants(((Item) caught).getItemStack());
}
}
示例14: onReelIn
import org.bukkit.event.player.PlayerFishEvent; //导入依赖的package包/类
/**
* 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);
}
示例15: onPlayerCatchEvent
import org.bukkit.event.player.PlayerFishEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerCatchEvent(PlayerFishEvent event){
if(event.getCaught() instanceof Item){
Item drop = (Item)event.getCaught();
drop.setItemStack(new ItemStack(Material.APPLE, 1));
}
}