本文整理汇总了Java中org.bukkit.event.player.PlayerFishEvent.setExpToDrop方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerFishEvent.setExpToDrop方法的具体用法?Java PlayerFishEvent.setExpToDrop怎么用?Java PlayerFishEvent.setExpToDrop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerFishEvent
的用法示例。
在下文中一共展示了PlayerFishEvent.setExpToDrop方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: onFish
import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
@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);
}
示例3: onPlayerFishHighest
import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
/**
* Handle PlayerFishEvents at the highest priority.
* <p>
* These events are used for the purpose of handling our anti-exploit
* code, as well as dealing with ice fishing.
*
* @param event The event to modify
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerFishHighest(PlayerFishEvent event) {
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player) || !SkillType.FISHING.getPermissions(player)) {
return;
}
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
switch (event.getState()) {
case FISHING:
if (!Permissions.krakenBypass(player)) {
event.setCancelled(fishingManager.exploitPrevention());
}
return;
case CAUGHT_FISH:
//TODO Update to new API once available! Waiting for case CAUGHT_TREASURE:
Item fishingCatch = (Item) event.getCaught();
if (Config.getInstance().getFishingOverrideTreasures() && fishingCatch.getItemStack().getType() != Material.RAW_FISH) {
fishingCatch.setItemStack(new ItemStack(Material.RAW_FISH, 1));
}
if (Permissions.vanillaXpBoost(player, SkillType.FISHING)) {
event.setExpToDrop(fishingManager.handleVanillaXpBoost(event.getExpToDrop()));
}
return;
case IN_GROUND:
Block block = player.getTargetBlock(null, 100);
if (fishingManager.canIceFish(block)) {
event.setCancelled(true);
fishingManager.iceFishing(event.getHook(), block);
}
return;
default:
return;
}
}