當前位置: 首頁>>代碼示例>>Java>>正文


Java PlayerKickEvent.isCancelled方法代碼示例

本文整理匯總了Java中org.bukkit.event.player.PlayerKickEvent.isCancelled方法的典型用法代碼示例。如果您正苦於以下問題:Java PlayerKickEvent.isCancelled方法的具體用法?Java PlayerKickEvent.isCancelled怎麽用?Java PlayerKickEvent.isCancelled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.player.PlayerKickEvent的用法示例。


在下文中一共展示了PlayerKickEvent.isCancelled方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: disconnect

import org.bukkit.event.player.PlayerKickEvent; //導入方法依賴的package包/類
public void disconnect(String s) {
    // CraftBukkit start - fire PlayerKickEvent
    String leaveMessage = EnumChatFormat.YELLOW + this.player.getName() + " left the game.";

    PlayerKickEvent event = new PlayerKickEvent(this.server.getPlayer(this.player), s, leaveMessage);

    if (this.server.getServer().isRunning()) {
        this.server.getPluginManager().callEvent(event);
    }

    if (event.isCancelled()) {
        // Do not kick the player
        return;
    }
    // Send the possibly modified leave message
    s = event.getReason();
    // CraftBukkit end
    ChatComponentText chatcomponenttext = new ChatComponentText(s);

    this.networkManager.handle(new PacketPlayOutKickDisconnect(chatcomponenttext), new GenericFutureListener[] { new PlayerConnectionFuture(this, chatcomponenttext)});
    this.a(chatcomponenttext); // CraftBukkit - Process quit immediately
    this.networkManager.g();
}
 
開發者ID:OvercastNetwork,項目名稱:CraftBukkit,代碼行數:24,代碼來源:PlayerConnection.java

示例2: onPlayerKick

import org.bukkit.event.player.PlayerKickEvent; //導入方法依賴的package包/類
@EventHandler
public void onPlayerKick(PlayerKickEvent event) {
	Player p = event.getPlayer();
	ArenaManager am = SimpleSurvivalGames.instance.getArenaManager();
	
	// Make sure the player is not null
	if(p == null)
		return;
	
	// Make sure the event was not cancelled
	if(event.isCancelled())
		return;
	
	// Is the current in any arena
	if(am.isInArena(p)) {
		Arena arena = am.getPlayer(p).getArena();
		
		// Kick the player out of the arena
		SimpleSurvivalGames.instance.getArenaManager().kick(p);
		
		// Show a message to all players this player died
		arena.sendMessage(ChatColor.GOLD + p.getName() + ChatColor.DARK_RED + " lost connection!");
	}
}
 
開發者ID:timvisee,項目名稱:simple-survival-games,代碼行數:25,代碼來源:SSGPlayerListener.java

示例3: disconnect

import org.bukkit.event.player.PlayerKickEvent; //導入方法依賴的package包/類
public void disconnect(String s) {
    if (!this.disconnected) {
        // CraftBukkit start
        String leaveMessage = EnumChatFormat.YELLOW + this.player.getName() + " left the game.";

        PlayerKickEvent event = new PlayerKickEvent(this.server.getPlayer(this.player), s, leaveMessage);

        if (this.server.getServer().isRunning()) {
            this.server.getPluginManager().callEvent(event);
        }

        if (event.isCancelled()) {
            // Do not kick the player
            return;
        }
        // Send the possibly modified leave message
        s = event.getReason();
        // CraftBukkit end

        this.player.l();
        this.sendPacket(new Packet255KickDisconnect(s));
        this.networkManager.d();

        // CraftBukkit start
        leaveMessage = event.getLeaveMessage();
        if (leaveMessage != null && leaveMessage.length() > 0) {
            this.minecraftServer.getPlayerList().sendMessage(ChatMessage.d(leaveMessage));
        }
        // CraftBukkit end

        this.minecraftServer.getPlayerList().disconnect(this.player);
        this.disconnected = true;
    }
}
 
開發者ID:AlmuraDev,項目名稱:Almura-Server,代碼行數:35,代碼來源:PlayerConnection.java

示例4: kickPlayerFromServer

import org.bukkit.event.player.PlayerKickEvent; //導入方法依賴的package包/類
public void kickPlayerFromServer(String p_147360_1_)
{
    // CraftBukkit start
    String leaveMessage = EnumChatFormatting.YELLOW + this.playerEntity.getCommandSenderName() + " left the game.";
    PlayerKickEvent event = new PlayerKickEvent(this.server.getPlayer(this.playerEntity), p_147360_1_, leaveMessage);

    if (this.server.getServer().isServerRunning())
    {
        this.server.getPluginManager().callEvent(event);
    }

    if (event.isCancelled())
    {
        // Do not kick the player
        return;
    }

    // Send the possibly modified leave message
    p_147360_1_ = event.getReason();
    // CraftBukkit end
    final ChatComponentText chatcomponenttext = new ChatComponentText(p_147360_1_);
    this.netManager.scheduleOutboundPacket(new S40PacketDisconnect(chatcomponenttext), new GenericFutureListener[] {new GenericFutureListener()
    {
        private static final String __OBFID = "CL_00001453";
        public void operationComplete(Future p_operationComplete_1_)
        {
            NetHandlerPlayServer.this.netManager.closeChannel(chatcomponenttext);
        }
    }});
    this.onDisconnect(chatcomponenttext); // CraftBukkit - Process quit immediately
    this.netManager.disableAutoRead();
}
 
開發者ID:xtrafrancyz,項目名稱:Cauldron,代碼行數:33,代碼來源:NetHandlerPlayServer.java

示例5: disconnect

import org.bukkit.event.player.PlayerKickEvent; //導入方法依賴的package包/類
public void disconnect(String s) {
    // CraftBukkit start - fire PlayerKickEvent
    String leaveMessage = EnumChatFormat.YELLOW + this.player.getName() + " left the game.";

    PlayerKickEvent event = new PlayerKickEvent(this.server.getPlayer(this.player), s, leaveMessage);

    if (this.server.getServer().isRunning()) {
        this.server.getPluginManager().callEvent(event);
    }

    if (event.isCancelled()) {
        // Do not kick the player
        return;
    }
    // Send the possibly modified leave message
    s = event.getReason();
    // CraftBukkit end
    final ChatComponentText chatcomponenttext = new ChatComponentText(s);

    this.networkManager.sendPacket(new PacketPlayOutKickDisconnect(chatcomponenttext), new GenericFutureListener() {
        public void operationComplete(Future future) throws Exception { // CraftBukkit - decompile error
            PlayerConnection.this.networkManager.close(chatcomponenttext);
        }
    }, new GenericFutureListener[0]);
    this.a(chatcomponenttext); // CraftBukkit - fire quit instantly
    this.networkManager.stopReading();
    // CraftBukkit - Don't wait
    this.minecraftServer.postToMainThread(new Runnable() {
        public void run() {
            PlayerConnection.this.networkManager.handleDisconnection();
        }
    });
}
 
開發者ID:bergerkiller,項目名稱:SpigotSource,代碼行數:34,代碼來源:PlayerConnection.java

示例6: disconnect

import org.bukkit.event.player.PlayerKickEvent; //導入方法依賴的package包/類
public void disconnect(String s) {
    if (!this.disconnected) {
        // CraftBukkit start
        String leaveMessage = EnumChatFormat.YELLOW + this.player.name + " left the game.";

        PlayerKickEvent event = new PlayerKickEvent(this.server.getPlayer(this.player), s, leaveMessage);

        if (this.server.getServer().isRunning()) {
            this.server.getPluginManager().callEvent(event);
        }

        if (event.isCancelled()) {
            // Do not kick the player
            return;
        }
        // Send the possibly modified leave message
        s = event.getReason();
        // CraftBukkit end

        this.player.k();
        this.sendPacket(new Packet255KickDisconnect(s));
        this.networkManager.d();

        // CraftBukkit start
        leaveMessage = event.getLeaveMessage();
        if (leaveMessage != null && leaveMessage.length() > 0) {
            this.minecraftServer.getPlayerList().sendAll(new Packet3Chat(leaveMessage));
        }
        // CraftBukkit end

        this.minecraftServer.getPlayerList().disconnect(this.player);
        this.disconnected = true;
    }
}
 
開發者ID:didoupimpon,項目名稱:Craft-city,代碼行數:35,代碼來源:PlayerConnection.java

示例7: onPlayerKick

import org.bukkit.event.player.PlayerKickEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerKick(PlayerKickEvent event)
{
	if (! event.isCancelled())
	{
		onPlayerDisconnect(event.getPlayer());
	}
}
 
開發者ID:dmulloy2,項目名稱:SwornParkour,代碼行數:9,代碼來源:PlayerListener.java

示例8: onPlayerKick

import org.bukkit.event.player.PlayerKickEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerKick(PlayerKickEvent event)
{
	if (event.isCancelled())
		return;

	Player player = event.getPlayer();
	PlayerData data = plugin.getPlayerDataCache().getData(player);

	// Clear the previousLocation variable
	if (data.getPreviousLocation() != null)
	{
		player.teleport(data.getPreviousLocation());
		data.setPreviousLocation(null);
	}

	// Attempt to prevent invalid kicks caused by sitting in chairs.
	// This works by checking whether or not the player sat recently
	// and whether or not the kick was valid.  This only works on Spigot,
	// since the kick messages in CraftBukkit are "Nope", which can be for
	// a variety of reasons.

	if (data.isSatRecently() && event.getReason().equals("NaN in position (Hacking?)"))
	{
		// Check if their position is valid
		Location location = player.getLocation();
		if (isValid(location.getX()) && isValid(location.getY()) && isValid(location.getZ()))
		{
			plugin.getLogHandler().log("Blocked invalid kick for {0}", player.getName());
			event.setCancelled(true);
			return;
		}

		// Teleport them to spawn as a fallback
		player.teleport(player.getWorld().getSpawnLocation());

		// Were we successful?
		location = player.getLocation();
		if (isValid(location.getX()) && isValid(location.getY()) && isValid(location.getZ()))
		{
			plugin.getLogHandler().log("Corrected invalid position for {0}", player.getName());
			event.setCancelled(true);
			return;
		}
	}
}
 
開發者ID:dmulloy2,項目名稱:SwornRPG,代碼行數:47,代碼來源:PlayerListener.java


注:本文中的org.bukkit.event.player.PlayerKickEvent.isCancelled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。