Java Code Examples for org.bukkit.event.server.ServerListPingEvent#setMotd()
The following examples show how to use
org.bukkit.event.server.ServerListPingEvent#setMotd() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PingListener.java From SkyWarsReloaded with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onPing(final ServerListPingEvent serverListPingEvent) { if (SkyWarsReloaded.get().serverLoaded()) { if (GameMap.getMaps().size() > 0) { GameMap game = GameMap.getMaps().get(0); serverListPingEvent.setMotd(new Messaging.MessageFormatter().setVariable("matchstate", game.getMatchState().toString()) .setVariable("playercount","" + game.getPlayerCount()).setVariable("maxplayers", "" + game.getMaxPlayers()) .setVariable("displayname", game.getDisplayName()).format("bungee.motd")); } else { serverListPingEvent.setMotd(new Messaging.MessageFormatter().setVariable("matchstate", MatchState.ENDING.toString() ) .setVariable("playercount","0").setVariable("maxplayers", "0") .setVariable("displayname", "null").format("bungee.motd")); } } else { serverListPingEvent.setMotd(new Messaging.MessageFormatter().setVariable("matchstate", MatchState.ENDING.toString() ) .setVariable("playercount","0").setVariable("maxplayers", "0") .setVariable("displayname", "null").format("bungee.motd")); } }
Example 2
Source File: MOTD.java From CardinalPGM with MIT License | 6 votes |
@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) : "")); }
Example 3
Source File: MotdListener.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onServerListPing(ServerListPingEvent event) { final String format = PGM.get().getConfiguration().getMotd(); if (format == null || format.isEmpty()) return; event.setMotd(MessageFormat.format(format, event.getMotd(), mapName, phaseColor.toString())); }
Example 4
Source File: PingListener.java From UhcCore with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onPing(ServerListPingEvent event){ GameManager gm = GameManager.getGameManager(); if (gm == null){ return; // Still loading } if (gm.getConfiguration().getDisableMotd()){ return; // No motd support } // Display motd switch(gm.getGameState()){ case ENDED: event.setMotd(Lang.DISPLAY_MOTD_ENDED); break; case LOADING: event.setMotd(Lang.DISPLAY_MOTD_LOADING); break; case DEATHMATCH: case PLAYING: event.setMotd(Lang.DISPLAY_MOTD_PLAYING); break; case STARTING: event.setMotd(Lang.DISPLAY_MOTD_STARTING); break; case WAITING: event.setMotd(Lang.DISPLAY_MOTD_WAITING); break; default: event.setMotd(Lang.DISPLAY_MESSAGE_PREFIX); break; } }
Example 5
Source File: ExprMOTD.java From Skript with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("null") @Override public void change(Event e, @Nullable Object[] delta, ChangeMode mode) { ServerListPingEvent event = (ServerListPingEvent) e; switch (mode) { case SET: event.setMotd((String) delta[0]); break; case DELETE: event.setMotd(""); break; case RESET: event.setMotd(Bukkit.getMotd()); } }
Example 6
Source File: GameListeners.java From AnnihilationPro with MIT License | 5 votes |
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true) public void pingServer(ServerListPingEvent event) { if(GameVars.useMOTD()) { if(Game.getGameMap() == null || Game.getGameMap().getCurrentPhase() < 1) event.setMotd("In Lobby"); else event.setMotd("Phase "+Game.getGameMap().getCurrentPhase()); } }
Example 7
Source File: ServerListener.java From BedwarsRel with GNU General Public License v3.0 | 4 votes |
@EventHandler public void onServerListPing(ServerListPingEvent slpe) { // Only enabled on bungeecord if (!BedwarsRel.getInstance().isBungee()) { return; } if (BedwarsRel.getInstance().getGameManager() == null || BedwarsRel.getInstance().getGameManager().getGames() == null || BedwarsRel.getInstance().getGameManager().getGames().size() == 0) { return; } Game game = BedwarsRel.getInstance().getGameManager().getGames().get(0); if (game == null) { return; } switch (game.getState()) { case STOPPED: slpe.setMotd(replacePlaceholder(game, ChatColor.translateAlternateColorCodes('&', BedwarsRel.getInstance().getConfig().getString("bungeecord.motds.stopped")))); break; case WAITING: if (game.isFull()) { slpe.setMotd(replacePlaceholder(game, ChatColor.translateAlternateColorCodes('&', BedwarsRel.getInstance().getConfig().getString("bungeecord.motds.full")))); } else { slpe.setMotd(replacePlaceholder(game, ChatColor.translateAlternateColorCodes('&', BedwarsRel.getInstance().getConfig().getString("bungeecord.motds.lobby")))); } break; case RUNNING: slpe.setMotd(replacePlaceholder(game, ChatColor.translateAlternateColorCodes('&', BedwarsRel.getInstance().getConfig().getString("bungeecord.motds.running")))); break; default: slpe.setMotd(ChatColor.RED + "INVALID GAME STATE!"); break; } }
Example 8
Source File: BungeemodeListener.java From HeavySpleef with GNU General Public License v3.0 | 4 votes |
@EventHandler public void onServerListPing(ServerListPingEvent event) { BungeemodeConfig config = addon.getConfig(); if (!config.isEnabled() || !config.isUseMotd()) { return; } if (!addon.getHeavySpleef().isGamesLoaded()) { event.setMotd(addon.getI18n().getString(BungeemodeMessages.MOTD_SERVER_STARTING)); return; } String gameName = config.getGame(); GameManager manager = addon.getHeavySpleef().getGameManager(); if (!manager.hasGame(gameName)) { addon.getLogger().log(Level.WARNING, "Cannot handle server list ping: Game " + gameName + " does not exist!"); return; } Game game = manager.getGame(gameName); String motdKey; switch (game.getGameState()) { case DISABLED: motdKey = BungeemodeMessages.MOTD_DISABLED; break; case WAITING: motdKey = BungeemodeMessages.MOTD_WAITING; break; case LOBBY: motdKey = BungeemodeMessages.MOTD_LOBBY; break; case STARTING: case WARMUP: motdKey = BungeemodeMessages.MOTD_COUNTDOWN; break; case INGAME: motdKey = BungeemodeMessages.MOTD_INGAME; break; default: motdKey = BungeemodeMessages.MOTD_UNKNOWN; break; } String motd = addon.getI18n().getString(motdKey); event.setMotd(motd); }
Example 9
Source File: BukkitEventHandler.java From ServerListPlus with GNU General Public License v3.0 | 4 votes |
@EventHandler public void onServerListPing(final ServerListPingEvent event) { if (bukkit.getCore() == null) return; // Too early, we haven't finished initializing yet StatusResponse response = bukkit.getCore().createRequest(event.getAddress()).createResponse( bukkit.getCore().getStatus(), new ResponseFetcher() { @Override public Integer getOnlinePlayers() { return event.getNumPlayers(); } @Override public Integer getMaxPlayers() { return event.getMaxPlayers(); } @Override public int getProtocolVersion() { return -1; } }); // Description String message = response.getDescription(); if (message != null) event.setMotd(message); // Max players Integer max = response.getMaxPlayers(); if (max != null) event.setMaxPlayers(max); // Favicon FaviconSource favicon = response.getFavicon(); if (favicon != null) { CachedServerIcon icon = bukkit.getFavicon(favicon); if (icon != null) try { event.setServerIcon(icon); } catch (UnsupportedOperationException ignored) {} } }
Example 10
Source File: AOListener.java From AlwaysOnline with GNU General Public License v2.0 | 3 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onMOTD(ServerListPingEvent event) { if (AlwaysOnline.MOJANG_OFFLINE_MODE && this.MOTD != null) event.setMotd(this.MOTD); }