本文整理汇总了Java中org.bukkit.event.player.PlayerFishEvent.setCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerFishEvent.setCancelled方法的具体用法?Java PlayerFishEvent.setCancelled怎么用?Java PlayerFishEvent.setCancelled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerFishEvent
的用法示例。
在下文中一共展示了PlayerFishEvent.setCancelled方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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());
}
}
}
示例3: 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);
}
示例4: 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.");
}
}
}
示例5: 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);
}
}
}
示例6: onPlayerFish
import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerFish(PlayerFishEvent event) {
Player p = event.getPlayer();
ArenaManager am = SimpleSurvivalGames.instance.getArenaManager();
// Is the current player playing
if(am.isInArena(p)) {
ArenaPlayer ap = am.getPlayer(p);
// Is the player in the lobby of the arena
if(ap.isInLobby()) {
// Has the player a arena spawn assigned
if(ap.hasAssignedAreanSpawn()) {
// Cancel the event and send a status message
event.setCancelled(true);
p.sendMessage(ChatColor.DARK_RED + "You can't fish inside the lobby of an arena!");
}
}
// Is the player an spectators
if(ap.isSpectator()) {
event.setCancelled(true);
ap.sendMessage(ChatColor.DARK_RED + "You can't fish while spectating!");
}
}
}
示例7: onPlayerFish
import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = false, priority = EventPriority.LOWEST)
public void onPlayerFish(PlayerFishEvent e) {
if (plugin.pm.isGhost((Player) e.getPlayer())) {
e.setCancelled(true);
}
}
示例8: 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;
}
}
示例9: PlayerFish
import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
public void PlayerFish(final PlayerFishEvent event)
{
if (!plugin.isLoggedIn(event.getPlayer()))
event.setCancelled(true);
}
示例10: onPlayerFish
import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerFish(PlayerFishEvent event) {
if (listenerService.shouldCancelEvent(event)) {
event.setCancelled(true);
}
}