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


Java ServerListPingEvent类代码示例

本文整理汇总了Java中org.bukkit.event.server.ServerListPingEvent的典型用法代码示例。如果您正苦于以下问题:Java ServerListPingEvent类的具体用法?Java ServerListPingEvent怎么用?Java ServerListPingEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServerListPingEvent类属于org.bukkit.event.server包,在下文中一共展示了ServerListPingEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onMotd

import org.bukkit.event.server.ServerListPingEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onMotd(ServerListPingEvent event) {
    MotdProvider provider = service.getProvider();
    if (provider != null && provider.isEnabled()) {
        String motd = provider.provideMotd();
        if (motd != null) {
            event.setMotd(motd);
        }

        MotdServerIcon serverIcon = provider.provideServerIcon();
        if (serverIcon != null) {
            event.setServerIcon(BukkitMotdServerIcon.wrap(serverIcon)
                    .toCachedServerIcon());
        }
    }
}
 
开发者ID:andylizi,项目名称:ColorMOTD,代码行数:17,代码来源:MotdListener.java

示例2: handle

import org.bukkit.event.server.ServerListPingEvent; //导入依赖的package包/类
@Override
public void handle( ConnectionHandler connectionHandler, MessageC00RequestStatus message ) {
    JsonObject version = new JsonObject();
    version.addProperty( "name", "1.12.1" );
    version.addProperty( "protocol", 338 );
    JsonObject players = new JsonObject();
    FlexServer server = Flex.getServer();
    ServerListPingEvent event = EventFactory.call( new ServerListPingEvent( connectionHandler.getSocketAddress().getAddress(), server.getConfig().getServerName(), server.getPlayerManager().getOnlinePlayers().size(), server.getConfig().getMaxPlayers() ) );
    players.addProperty( "max", event.getMaxPlayers() );
    players.addProperty( "online", event.getNumPlayers() );
    JsonObject description = new JsonObject();
    description.addProperty( "text", event.getMotd() );
    JsonObject o = new JsonObject();
    o.add( "version", version );
    o.add( "players", players );
    o.add( "description", description );

    connectionHandler.sendMessage( new MessageS00ResponseStatus( Flex.getGson().toJson( o ) ) );

}
 
开发者ID:lukas81298,项目名称:FlexMC,代码行数:21,代码来源:ClientRequestStatusListener.java

示例3: onServerListPing

import org.bukkit.event.server.ServerListPingEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onServerListPing(ServerListPingEvent event) {
    String name = GameHandler.getGameHandler().getMatch().getCurrentMap().getMap().getName();
    ChatColor color = ChatColor.GRAY;
    switch (GameHandler.getGameHandler().getMatch().getMatchState()) {
        case ENDED:
            color = ChatColor.AQUA;
            break;
        case PLAYING:
            color = ChatColor.GOLD;
            break;
        case STARTING:
            color = ChatColor.GREEN;
            break;
    }
    event.setMotd(color + "\u00BB " + ChatColor.AQUA + name + color + " \u00AB" +
            (!Config.motd.equals("") ? "\n" + ChatColor.translateAlternateColorCodes('`', Config.motd) : ""));

}
 
开发者ID:Minehut,项目名称:GamePlate,代码行数:20,代码来源:MotdModule.java

示例4: initializeChannelsAndPing

import org.bukkit.event.server.ServerListPingEvent; //导入依赖的package包/类
public static void initializeChannelsAndPing() {
	registerMercuryChannels();
	Bukkit.getScheduler().runTaskTimer(BetterShardsPlugin.getInstance(), new Runnable() {

		@Override
		public void run() {
			InetAddress address = null;
			try {
				address = InetAddress.getByName("127.0.0.1");
			} catch (UnknownHostException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			ServerListPingEvent event = new ServerListPingEvent(address, Bukkit.getMotd(), Bukkit.getOnlinePlayers().size(),
					Bukkit.getMaxPlayers());
			Bukkit.getPluginManager().callEvent(event);
			sendPlayerCount(event.getMaxPlayers());
		}
		
	}, 100, 100);
}
 
开发者ID:Civcraft,项目名称:BetterShards,代码行数:22,代码来源:MercuryManager.java

示例5: onServerListPing

import org.bukkit.event.server.ServerListPingEvent; //导入依赖的package包/类
@EventHandler
public void onServerListPing(ServerListPingEvent event) {
	FileConfiguration config = SpleefMain.getInstance().getBungeeConfigAccessor().getConfig();
	if (config.getBoolean("supportBungeecord")) {
		if (config.getBoolean("epicSpleefBungee.enabled")) {
			String name = config.getString("instantJoinLobbyOrArena");
			for (SpleefArena arena : SpleefArena.getSpleefArenas()) {
				if (arena.getName().equals(name)) {
					String[] lines = arena.getSignText();
					for (int i = 0; i < lines.length; i++) {
						if (lines[i] == null) {
							lines[i] = "";
						}
						lines[i] = lines[i].replace("=!=", "");
					}
					event.setMotd(lines[0] + "=!=" + lines[1] + "=!=" + lines[2] + "=!=" + lines[3]);
					return;
				}
			}
		}
	}
}
 
开发者ID:BtoBastian,项目名称:EpicSpleef,代码行数:23,代码来源:ServerListPingListener.java

示例6: onServerListPing

import org.bukkit.event.server.ServerListPingEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onServerListPing(ServerListPingEvent event) {
    try {
        String name = match.getLoadedMap().getName();
        if (match.getState() == MatchState.ENDED) {
            event.setMotd(ChatColor.RED + "\u00BB " + ChatColor.AQUA + name + ChatColor.RED + " \u00AB");
        } else if (match.getState() == MatchState.PLAYING) {
            event.setMotd(ChatColor.GOLD + "\u00BB " + ChatColor.AQUA + name + ChatColor.GOLD + " \u00AB");
        } else if (match.getState() == MatchState.STARTING) {
            event.setMotd(ChatColor.GREEN + "\u00BB " + ChatColor.AQUA + name + ChatColor.GREEN + " \u00AB");
        } else {
            event.setMotd(ChatColor.GRAY + "\u00BB " + ChatColor.AQUA + name + ChatColor.GRAY + " \u00AB");
        }
    } catch (NullPointerException ex) {

    }
}
 
开发者ID:dentmaged,项目名称:Cardinal-Plus,代码行数:18,代码来源:MOTD.java

示例7: onServerListPing

import org.bukkit.event.server.ServerListPingEvent; //导入依赖的package包/类
@HookHandler(priority = Priority.CRITICAL)
public void onServerListPing(final ServerListPingHook hook) {
    server.getPluginManager().callEvent(
            new ServerListPingEvent(hook.getRequesterAddress(), hook.getMotd().getFullText(), hook
                    .getCurrentPlayers(), hook.getMaxPlayers()) {
                @Override
                public void setMotd(String motd) {
                    super.setMotd(motd);
                    hook.setMotd(motd);
                }

                @Override
                public void setMaxPlayers(int maxPlayers) {
                    super.setMaxPlayers(maxPlayers);
                    hook.setMaxPlayers(maxPlayers);
                }

                @Override
                public void setServerIcon(CachedServerIcon icon) throws IllegalArgumentException,
                        UnsupportedOperationException {
                    super.setServerIcon(icon);
                }
            });
}
 
开发者ID:CanaryBukkitTeam,项目名称:CanaryBukkit,代码行数:25,代码来源:CanaryServerListener.java

示例8: serverListPing

import org.bukkit.event.server.ServerListPingEvent; //导入依赖的package包/类
@Deprecated
@SuppressWarnings("unused")
public void serverListPing(ServerListPingEvent event){
	if(this.logServerPings && false){
		String msg = "";
		if (loggingMethods.contains(LoggingMethod.SINGLE_FILE)){
			
		}
		if (loggingMethods.contains(LoggingMethod.UUID_FILES)){
			
		}
		if (loggingMethods.contains(LoggingMethod.MYSQL)){
			dbl.scheduleSQLExecution(new SQL("INSERT INTO " + ci.getConfig().getString("Database.Connection_log_table_name") + " (hostname, count) VALUES ('" + event.getAddress() + "', ##AUTO##);", ci.getConfig().getString("Database.Connection_log_table_name"), new Timestamp(UnitConverter.getCurrentTimestamp())));
		}
		if (loggingMethods.contains(LoggingMethod.MINECRAFT_LOG)){
			ci.log.info(msg);
		}
	}
}
 
开发者ID:comdude2,项目名称:ConnectionInfo,代码行数:20,代码来源:ConnectionHandler.java

示例9: onServerPing

import org.bukkit.event.server.ServerListPingEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onServerPing(ServerListPingEvent event)
{
    event.setMotd(TFM_Util.randomChatColor() + "Tatsu" + TFM_Util.randomChatColor() + "Craft " + ChatColor.DARK_GRAY + "-" + TFM_Util.randomChatColor() + " Bukkit v" + TFM_ServerInterface.getVersion());

    if (TFM_ServerInterface.isIPBanned(event.getAddress().getHostAddress()))
    {
        event.setMotd(ChatColor.RED + "You are banned.");
    }
    else if (TFM_ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
    {
        event.setMotd(ChatColor.RED + "Server is in admin mode.");
    }
    else if (Bukkit.hasWhitelist())
    {
        event.setMotd(ChatColor.RED + "Whitelist enabled.");
    }
    else if (Bukkit.getOnlinePlayers().length >= Bukkit.getMaxPlayers())
    {
        event.setMotd(ChatColor.RED + "Server is full.");
    }
}
 
开发者ID:Yoshi41023,项目名称:TatsuCraftMod,代码行数:23,代码来源:TFM_ServerListener.java

示例10: onServerListPing

import org.bukkit.event.server.ServerListPingEvent; //导入依赖的package包/类
@Override
@EventHandler
public void onServerListPing(ServerListPingEvent e)
{
	super.onServerListPing(e);

	if (plugin.isInMaintenanceMode())
	{
		e.setMotd(ChatColor.YELLOW + "En maintenance...");
		return;
	}

	String motd = ScapegoatPlugin.SCAPEGOAT_COLOR + "Bouc-�missaire" + ChatColor.RESET + " | " + ChatColor.DARK_RED
			+ "Partie en cours.";
	e.setMotd(motd);
}
 
开发者ID:Elarcis,项目名称:Scapegoat,代码行数:17,代码来源:Running.java

示例11: onServerListPing

import org.bukkit.event.server.ServerListPingEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onServerListPing(ServerListPingEvent event) {
    String name = match.getLoadedMap().getName();
    ChatColor color = ChatColor.GRAY;
    switch (match.getState()) {
        case ENDED:
            color = ChatColor.AQUA;
            break;
        case PLAYING:
            color = ChatColor.GOLD;
            break;
        case STARTING:
            color = ChatColor.GREEN;
            break;
    }
    event.setMotd(color + "\u00BB " + ChatColor.AQUA + name + color + " \u00AB" +
            (!Config.motdMessage.equals("") ? "\n" + ChatColor.translateAlternateColorCodes('`', Config.motdMessage) : ""));

}
 
开发者ID:twizmwazin,项目名称:CardinalPGM,代码行数:20,代码来源:MOTD.java

示例12: setMotd

import org.bukkit.event.server.ServerListPingEvent; //导入依赖的package包/类
@EventHandler
public void setMotd(ServerListPingEvent e) {
	if(xEssentialsMemory.motdEnabled) {
		e.setMotd(ChatColor.translateAlternateColorCodes('&', xEssentialsMemory.motdMessage));	
	} else if(xEssentialsMemory.motdRandom) {
		if(it.hasNext()) {
			e.setMotd(ChatColor.translateAlternateColorCodes('&', it.next()));
		} else {
			while(it.hasPrevious()) {
				it.previous();
			}
			if(it.hasNext()) {
				e.setMotd(ChatColor.translateAlternateColorCodes('&', it.next()));
			}
		}
	}
}
 
开发者ID:xize,项目名称:xEssentials_old_Source,代码行数:18,代码来源:motd.java

示例13: onServerListPing

import org.bukkit.event.server.ServerListPingEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onServerListPing(final ServerListPingEvent event){
    String debugmsg = "Get ping from " + event.getAddress().getHostAddress() + "!";

    final String motd = plugin.formatting(chooseMsg());
    if (motd != null) {
        event.setMotd(motd);
        debugmsg += " Motd: '" + motd + "'";
    }
    if (plugin.getConfigs().getUseFakeMaxPlayers()){
        event.setMaxPlayers(plugin.getConfigs().getFakeMaxPlayers());
        debugmsg += " FakeMaxPlayers: '" + plugin.getConfigs().getFakeMaxPlayers() + "'";
    }

    plugin.debug(debugmsg);
}
 
开发者ID:ThunderGemios10,项目名称:MotdManager-Reloaded,代码行数:17,代码来源:ServerListener.java

示例14: onServerListPing

import org.bukkit.event.server.ServerListPingEvent; //导入依赖的package包/类
@EventHandler
public void onServerListPing(ServerListPingEvent event) {
    UUID uuid = getDatabaseManager().getPlayerUUID(event.getAddress().getHostAddress());
    if (uuid != null) {
        OfflinePlayer player = Bukkit.getOfflinePlayer(uuid);
        try {
            event.setServerIcon(Bukkit.loadServerIcon(getImageHandler().getImageForUser(player.getUniqueId(), player.getName())));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:me4502,项目名称:AdvancedServerListIcons,代码行数:13,代码来源:AdvancedServerListIconsSpigot.java

示例15: handlePing

import org.bukkit.event.server.ServerListPingEvent; //导入依赖的package包/类
@EventHandler
public void handlePing(ServerListPingEvent event) {
    if (Main.getInstance().hasAddress(event.getAddress())) {
        OpenPlayerData data = DataManager.getInstance().getPlayerData(Main.getInstance().fromAddress(event.getAddress()));

        if (data.getName() == null) {
            event.setMotd(colorize("&aCome and play!"));
        } else {
            event.setMotd(colorize("&aWelcome, &e" + data.getName() + "&a!\n&6Level: &c" + data.getLevel() + " &7|&e " + data.getRegion().getName()));
        }
    } else {
        event.setMotd(colorize("&aCome and play!"));
    }
}
 
开发者ID:Dragovorn,项目名称:OpenRPG,代码行数:15,代码来源:PingHandler.java


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