本文整理汇总了Java中org.bukkit.event.player.PlayerFishEvent.getCaught方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerFishEvent.getCaught方法的具体用法?Java PlayerFishEvent.getCaught怎么用?Java PlayerFishEvent.getCaught使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerFishEvent
的用法示例。
在下文中一共展示了PlayerFishEvent.getCaught方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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);
}
示例3: 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);
}
示例4: 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());
}
}
}
示例5: 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));
}
}
}
示例6: 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);
}
}
}
示例7: 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());
}
}
示例8: 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));
}
}
示例9: onFishOn
import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onFishOn(PlayerFishEvent event) {
if (tournament.isInProgress()) {
Entity theCatch = event.getCaught();
if (theCatch instanceof Item) {
tournament.addCatchToPlayer(event.getPlayer());
}
}
}
示例10: disableFishingRodPull
import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
@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.");
}
}
}
示例11: cancelSameTeam
import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
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);
}
}
}
示例12: onPlayerFishMonitor
import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
/**
* 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;
}
}
示例13: onCatch
import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
@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);
}
}
示例14: onFishCaught
import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onFishCaught(final PlayerFishEvent event) {
final PlayerStat stat = PlayerStat.ITEMS_CAUGHT;
// Get player
final Player player = event.getPlayer();
// Do general check
if (!plugin.doGeneralCheck(player, stat))
return;
Entity entity;
ItemStack item;
String materialName = null;
if (event.getCaught() != null) {
entity = event.getCaught();
if (!(entity instanceof Item)) {
return; // Did not catch an item
}
item = ((Item) entity).getItemStack();
if (event.getState().equals(State.CAUGHT_FISH)) {
materialName = StatzUtil.getFoodName(item);
if (materialName == null) {
materialName = item.getType().toString();
}
} else {
materialName = item.getType().toString();
}
} else {
// Did not catch anything.
return;
}
final String material = materialName;
// Update value to new stat.
plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, StatzUtil.makeQuery("uuid",
player.getUniqueId().toString(), "value", 1, "caught", material, "world", player.getWorld().getName()));
}
示例15: 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;
}
}