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


Java PlayerFishEvent.setCancelled方法代码示例

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

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

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

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

示例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);
        }
    }
}
 
开发者ID:ddonofrio,项目名称:libelula,代码行数:12,代码来源:TeamManager.java

示例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!");
		}
	}
}
 
开发者ID:timvisee,项目名称:simple-survival-games,代码行数:29,代码来源:SSGPlayerListener.java

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

示例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;
    }
}
 
开发者ID:Pershonkey,项目名称:McMMOPlus,代码行数:52,代码来源:PlayerListener.java

示例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);
}
 
开发者ID:ST-DDT,项目名称:CrazyLogin,代码行数:7,代码来源:DynamicPlayerListener.java

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


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