当前位置: 首页>>代码示例>>Java>>正文


Java PlayerFishEvent类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:18,代码来源:ExpMultiplierListener.java

示例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);
				}
			}
		}
	}
 
开发者ID:MrLittleKitty,项目名称:AnnihilationPro,代码行数:27,代码来源:Scout.java

示例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);
    }
}
 
开发者ID:elsiff,项目名称:MoreFish,代码行数:18,代码来源:FishingListener.java

示例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);
}
 
开发者ID:elsiff,项目名称:MoreFish,代码行数:27,代码来源:FishingListener.java

示例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());
	}
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:18,代码来源:ExprFixFishingGetXP.java

示例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);
}
 
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:26,代码来源:AchieveFishListener.java

示例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;
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:27,代码来源:ItemFishingRod.java

示例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;
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:27,代码来源:ItemFishingRod.java

示例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());
		}
	}
}
 
开发者ID:Craftolution,项目名称:CraftoPlugin,代码行数:26,代码来源:InteractionListener.java

示例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.");
        }
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:28,代码来源:GrappleManager.java

示例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));
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:10,代码来源:PGMListener.java

示例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);
    }
  }
}
 
开发者ID:twizmwazin,项目名称:OpenUHC,代码行数:16,代码来源:Cutclean.java

示例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());
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:8,代码来源:EnchantLimitListener.java

示例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);
}
 
开发者ID:gvlfm78,项目名称:BukkitOldCombatMechanics,代码行数:10,代码来源:ModuleFishingKnockback.java

示例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));
	}
}
 
开发者ID:DamoclesProject,项目名称:Damocles,代码行数:8,代码来源:Fishing.java


注:本文中的org.bukkit.event.player.PlayerFishEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。