Java Code Examples for org.bukkit.Bukkit#getMaxPlayers()
The following examples show how to use
org.bukkit.Bukkit#getMaxPlayers() .
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: AbstractNetwork.java From helper with MIT License | 6 votes |
private StatusMessage produceStatusMessage() { StatusMessage msg = new StatusMessage(); msg.time = System.currentTimeMillis(); msg.id = this.instanceData.getId(); msg.groups = new ArrayList<>(this.instanceData.getGroups()); msg.players = new HashMap<>(); Players.forEach(p -> msg.players.put(p.getUniqueId(), p.getName())); msg.maxPlayers = Bukkit.getMaxPlayers(); msg.whitelisted = Bukkit.hasWhitelist(); // collect server metadata msg.metadata = new HashMap<>(); for (ServerMetadataProvider metadataProvider : this.metadataProviders) { try { for (ServerMetadata metadata : metadataProvider.provide()) { msg.metadata.put(metadata.key(), metadata.data()); } } catch (Exception e) { new RuntimeException("Exception calling ServerMetadataProvider " + metadataProvider, e).printStackTrace(); } } return msg; }
Example 2
Source File: SystemCommand.java From LagMonitor with MIT License | 6 votes |
private void displayMinecraftInfo(CommandSender sender) { //Minecraft specific sendMessage(sender, "TPS", String.valueOf(plugin.getTpsHistoryTask().getLastSample())); TrafficReader trafficReader = plugin.getTrafficReader(); if (trafficReader != null) { String formattedIncoming = readableBytes(trafficReader.getIncomingBytes().longValue()); String formattedOutgoing = readableBytes(trafficReader.getOutgoingBytes().longValue()); sendMessage(sender, "Incoming Traffic", formattedIncoming); sendMessage(sender, "Outgoing Traffic", formattedOutgoing); } Plugin[] plugins = Bukkit.getPluginManager().getPlugins(); sendMessage(sender, "Loaded Plugins", String.format("%d/%d", getEnabledPlugins(plugins), plugins.length)); int onlinePlayers = Bukkit.getOnlinePlayers().size(); int maxPlayers = Bukkit.getMaxPlayers(); sendMessage(sender, "Players", String.format("%d/%d", onlinePlayers, maxPlayers)); displayWorldInfo(sender); sendMessage(sender, "Server version", Bukkit.getVersion()); }
Example 3
Source File: SystemCommand.java From LagMonitor with MIT License | 6 votes |
private void displayMinecraftInfo(CommandSender sender) { //Minecraft specific sendMessage(sender, "TPS", String.valueOf(plugin.getTpsHistoryTask().getLastSample())); TrafficReader trafficReader = plugin.getTrafficReader(); if (trafficReader != null) { String formattedIncoming = readableBytes(trafficReader.getIncomingBytes().longValue()); String formattedOutgoing = readableBytes(trafficReader.getOutgoingBytes().longValue()); sendMessage(sender, "Incoming Traffic", formattedIncoming); sendMessage(sender, "Outgoing Traffic", formattedOutgoing); } Plugin[] plugins = Bukkit.getPluginManager().getPlugins(); sendMessage(sender, "Loaded Plugins", String.format("%d/%d", getEnabledPlugins(plugins), plugins.length)); int onlinePlayers = Bukkit.getOnlinePlayers().size(); int maxPlayers = Bukkit.getMaxPlayers(); sendMessage(sender, "Players", String.format("%d/%d", onlinePlayers, maxPlayers)); displayWorldInfo(sender); sendMessage(sender, "Server version", Bukkit.getVersion()); }
Example 4
Source File: SpigotPingResponseHandler.java From ProtocolSupport with GNU Affero General Public License v3.0 | 6 votes |
@Override public ServerPingResponseEvent createResponse(Connection connection) { List<Player> players = new ArrayList<>(Bukkit.getOnlinePlayers()); String motd = Bukkit.getMotd(); int maxPlayers = Bukkit.getMaxPlayers(); InternalServerListPingEvent bevent = new InternalServerListPingEvent(connection.getAddress().getAddress(), motd, maxPlayers, players); bevent.setServerIcon(Bukkit.getServerIcon()); Bukkit.getPluginManager().callEvent(bevent); ServerPingResponseEvent revent = new ServerPingResponseEvent( connection, new ProtocolInfo(connection.getVersion(), createServerVersionString()), bevent.getIcon() != null ? ServerPlatform.get().getMiscUtils().convertBukkitIconToBase64(bevent.getIcon()) : null, bevent.getMotd(), bevent.getNumPlayers(), bevent.getMaxPlayers(), bevent.players.stream() .limit(SpigotConfig.playerSample) .map(Player::getName) .collect(Collectors.toList()) ); Bukkit.getPluginManager().callEvent(revent); return revent; }
Example 5
Source File: ListCommand.java From CardinalPGM with MIT License | 6 votes |
@Command(aliases = {"list"}, desc = "Lists all online players.", flags = "v") public static void list(final CommandContext args, CommandSender sender) { boolean version = args.hasFlag('v'); String result = ChatColor.GRAY + ChatConstant.MISC_ONLINE.asMessage().getMessage(ChatUtil.getLocale(sender)) + " (" + Bukkit.getOnlinePlayers().size() + "/" + Bukkit.getMaxPlayers() + "): " + ChatColor.RESET; for (Player player : Bukkit.getOnlinePlayers()) { result += player.getDisplayName(); if (version) { result += ChatColor.GRAY + " (" + Protocols.getName(player.getProtocolVersion()) + ")"; } result += ChatColor.RESET + ", "; } if (result.endsWith(", ")) { result = result.substring(0, result.length() - 2); } sender.sendMessage(result); }
Example 6
Source File: GeyserBukkitPingPassthrough.java From Geyser with MIT License | 5 votes |
@Override public GeyserPingInfo getPingInformation() { try { ServerListPingEvent event = new GeyserPingEvent(InetAddress.getLocalHost(), Bukkit.getMotd(), Bukkit.getOnlinePlayers().size(), Bukkit.getMaxPlayers()); Bukkit.getPluginManager().callEvent(event); GeyserPingInfo geyserPingInfo = new GeyserPingInfo(event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); Bukkit.getOnlinePlayers().forEach(player -> { geyserPingInfo.addPlayer(player.getName()); }); return geyserPingInfo; } catch (Exception e) { logger.debug("Error while getting Bukkit ping passthrough: " + e.toString()); return new GeyserPingInfo(null, 0, 0); } }
Example 7
Source File: FreeForAllModule.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
@Override public FreeForAllModule parse(MapFactory factory, Logger logger, Document doc) throws InvalidXMLException { Element elPlayers = doc.getRootElement().getChild("players"); if (factory.hasModule(TeamModule.class)) { if (elPlayers != null) throw new InvalidXMLException("Cannot combine <players> and <teams>", elPlayers); return null; } else { int minPlayers = (int) PGM.get().getConfiguration().getMinimumPlayers(); int maxPlayers = Bukkit.getMaxPlayers(); int maxOverfill = maxPlayers; NameTagVisibility nameTagVisibility = NameTagVisibility.ALWAYS; boolean colors = false; if (elPlayers != null) { minPlayers = XMLUtils.parseNumber(elPlayers.getAttribute("min"), Integer.class, minPlayers); maxPlayers = XMLUtils.parseNumber(elPlayers.getAttribute("max"), Integer.class, maxPlayers); maxOverfill = XMLUtils.parseNumber( elPlayers.getAttribute("max-overfill"), Integer.class, maxOverfill); nameTagVisibility = XMLUtils.parseNameTagVisibility( Node.fromAttr(elPlayers, "show-name-tags"), nameTagVisibility); colors = XMLUtils.parseBoolean(Node.fromAttr(elPlayers, "colors"), colors); } return new FreeForAllModule( new FreeForAllOptions(minPlayers, maxPlayers, maxOverfill, nameTagVisibility, colors)); } }
Example 8
Source File: FreeForAllModule.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@Override public @Nullable FreeForAllModule parse(MapModuleContext context, Logger logger, Document doc) throws InvalidXMLException { Element elPlayers = doc.getRootElement().getChild("players"); if(context.hasModule(TeamModule.class)) { if(elPlayers != null) throw new InvalidXMLException("Cannot combine <players> and <teams>", elPlayers); return null; } else { int minPlayers = Config.minimumPlayers(); int maxPlayers = Bukkit.getMaxPlayers(); int maxOverfill = maxPlayers; org.bukkit.scoreboard.Team.OptionStatus nameTagVisibility = org.bukkit.scoreboard.Team.OptionStatus.ALWAYS; boolean colors = false; if(elPlayers != null) { minPlayers = XMLUtils.parseNumber(elPlayers.getAttribute("min"), Integer.class, minPlayers); maxPlayers = XMLUtils.parseNumber(elPlayers.getAttribute("max"), Integer.class, maxPlayers); maxOverfill = XMLUtils.parseNumber(elPlayers.getAttribute("max-overfill"), Integer.class, maxOverfill); nameTagVisibility = XMLUtils.parseNameTagVisibility(elPlayers, "show-name-tags").optional(nameTagVisibility); colors = XMLUtils.parseBoolean(elPlayers.getAttribute("colors"), colors); } if(minPlayers > maxPlayers) { throw new InvalidXMLException("min players (" + minPlayers + ") cannot be greater than max players (" + maxPlayers + ")", elPlayers); } return new FreeForAllModule(new FreeForAllOptions(minPlayers, maxPlayers, maxOverfill, nameTagVisibility, colors)); } }
Example 9
Source File: PaperPingResponseHandler.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override public ServerPingResponseEvent createResponse(Connection connection) { PaperServerListPingEvent bevent = new PaperServerListPingEvent( new StatusClientImpl(connection), Bukkit.getMotd(), Bukkit.getOnlinePlayers().size(), Bukkit.getMaxPlayers(), createServerVersionString(), connection.getVersion().getId(), Bukkit.getServerIcon() ); List<PlayerProfile> playerSample = bevent.getPlayerSample(); Bukkit.getOnlinePlayers().stream() .limit(SpigotConfig.playerSample) .map(player -> new NameUUIDPlayerProfile(player.getUniqueId(), player.getName())) .forEach(playerSample::add); Bukkit.getPluginManager().callEvent(bevent); ServerPingResponseEvent revent = new ServerPingResponseEvent( connection, new ProtocolInfo(bevent.getProtocolVersion(), bevent.getVersion()), bevent.getServerIcon() != null ? ServerPlatform.get().getMiscUtils().convertBukkitIconToBase64(bevent.getServerIcon()) : null, bevent.getMotd(), bevent.getNumPlayers(), bevent.getMaxPlayers(), bevent.getPlayerSample().stream().map(PlayerProfile::getName).collect(Collectors.toList()) ); Bukkit.getPluginManager().callEvent(revent); return revent; }