本文整理汇总了Java中cn.nukkit.Server.getMaxPlayers方法的典型用法代码示例。如果您正苦于以下问题:Java Server.getMaxPlayers方法的具体用法?Java Server.getMaxPlayers怎么用?Java Server.getMaxPlayers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.nukkit.Server
的用法示例。
在下文中一共展示了Server.getMaxPlayers方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: QueryRegenerateEvent
import cn.nukkit.Server; //导入方法依赖的package包/类
public QueryRegenerateEvent(Server server, int timeout) {
this.timeout = timeout;
this.serverName = server.getMotd();
this.listPlugins = (boolean) server.getConfig("settings.query-plugins", true);
this.plugins = server.getPluginManager().getPlugins().values().toArray(new Plugin[server.getPluginManager().getPlugins().values().size()]);
List<Player> players = new ArrayList<>();
for (Player player : server.getOnlinePlayers().values()) {
if (player.isOnline()) {
players.add(player);
}
}
this.players = players.toArray(new Player[players.size()]);
this.gameType = (server.getGamemode() & 0x01) == 0 ? "SMP" : "CMP";
this.version = server.getVersion();
this.server_engine = server.getName() + " " + server.getNukkitVersion();
this.map = server.getDefaultLevel() == null ? "unknown" : server.getDefaultLevel().getName();
this.numPlayers = this.players.length;
this.maxPlayers = server.getMaxPlayers();
this.whitelist = server.hasWhitelist() ? "on" : "off";
this.port = server.getPort();
this.ip = server.getIp();
}
示例2: QueryRegenerateEvent
import cn.nukkit.Server; //导入方法依赖的package包/类
public QueryRegenerateEvent(Server server, int timeout) {
this.timeout = timeout;
this.serverName = server.getMotd();
this.listPlugins = (boolean) server.getConfig("settings.query-plugins", true);
this.plugins = server.getPluginManager().getPlugins().values().toArray(new Plugin[server.getPluginManager().getPlugins().values().size()]);
List<Player> players = new ArrayList<>();
for (Player player : server.getOnlinePlayers().values()) {
if (player.isOnline()) {
players.add(player);
}
}
this.players = players.toArray(new Player[players.size()]);
this.gameType = (server.getDefaultGamemode() & 0x01) == 0 ? "SMP" : "CMP";
this.version = server.getVersion();
this.server_engine = server.getName() + " " + server.getNukkitVersion();
this.map = server.getDefaultLevel() == null ? "unknown" : server.getDefaultLevel().getName();
this.numPlayers = this.players.length;
this.maxPlayers = server.getMaxPlayers();
this.whitelist = server.hasWhitelist() ? "on" : "off";
this.port = server.getPort();
this.ip = server.getIp();
}
示例3: execute
import cn.nukkit.Server; //导入方法依赖的package包/类
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
Server server = sender.getServer();
sender.sendMessage(TextFormat.GREEN + "---- " + TextFormat.WHITE + "Server status" + TextFormat.GREEN + " ----");
long time = (System.currentTimeMillis() - Nukkit.START_TIME) / 1000;
int seconds = NukkitMath.floorDouble(time % 60);
int minutes = NukkitMath.floorDouble((time % 3600) / 60);
int hours = NukkitMath.floorDouble(time % (3600 * 24) / 3600);
int days = NukkitMath.floorDouble(time / (3600 * 24));
String upTimeString = TextFormat.RED + "" + days + TextFormat.GOLD + " days " +
TextFormat.RED + hours + TextFormat.GOLD + " hours " +
TextFormat.RED + minutes + TextFormat.GOLD + " minutes " +
TextFormat.RED + seconds + TextFormat.GOLD + " seconds";
sender.sendMessage(TextFormat.GOLD + "Uptime: " + upTimeString);
TextFormat tpsColor = TextFormat.GREEN;
float tps = server.getTicksPerSecond();
if (tps < 17) {
tpsColor = TextFormat.GOLD;
} else if (tps < 12) {
tpsColor = TextFormat.RED;
}
sender.sendMessage(TextFormat.GOLD + "Current TPS: " + tpsColor + NukkitMath.round(tps, 2));
sender.sendMessage(TextFormat.GOLD + "Load: " + tpsColor + server.getTickUsage() + "%");
sender.sendMessage(TextFormat.GOLD + "Network upload: " + TextFormat.GREEN + NukkitMath.round((server.getNetwork().getUpload() / 1024 * 1000), 2) + " kB/s");
sender.sendMessage(TextFormat.GOLD + "Network download: " + TextFormat.GREEN + NukkitMath.round((server.getNetwork().getDownload() / 1024 * 1000), 2) + " kB/s");
sender.sendMessage(TextFormat.GOLD + "Thread count: " + TextFormat.GREEN + Thread.getAllStackTraces().size());
Runtime runtime = Runtime.getRuntime();
double totalMB = NukkitMath.round(((double) runtime.totalMemory()) / 1024 / 1024, 2);
double usedMB = NukkitMath.round((double) (runtime.totalMemory() - runtime.freeMemory()) / 1024 / 1024, 2);
double maxMB = NukkitMath.round(((double) runtime.maxMemory()) / 1024 / 1024, 2);
double usage = usedMB / maxMB * 100;
TextFormat usageColor = TextFormat.GREEN;
if (usage > 85) {
usageColor = TextFormat.GOLD;
}
sender.sendMessage(TextFormat.GOLD + "Used memory: " + usageColor + usedMB + " MB. (" + NukkitMath.round(usage, 2) + "%)");
sender.sendMessage(TextFormat.GOLD + "Total memory: " + TextFormat.RED + totalMB + " MB.");
sender.sendMessage(TextFormat.GOLD + "Maximum VM memory: " + TextFormat.RED + maxMB + " MB.");
sender.sendMessage(TextFormat.GOLD + "Available processors: " + TextFormat.GREEN + runtime.availableProcessors());
TextFormat playerColor = TextFormat.GREEN;
if (((float) server.getOnlinePlayers().size() / (float) server.getMaxPlayers()) > 0.85) {
playerColor = TextFormat.GOLD;
}
sender.sendMessage(TextFormat.GOLD + "Players: " + playerColor + server.getOnlinePlayers().size() + TextFormat.GREEN + " online, " +
TextFormat.RED + server.getMaxPlayers() + TextFormat.GREEN + " max. ");
for (Level level : server.getLevels().values()) {
sender.sendMessage(
TextFormat.GOLD + "World \"" + level.getFolderName() + "\"" + (!Objects.equals(level.getFolderName(), level.getName()) ? " (" + level.getName() + ")" : "") + ": " +
TextFormat.RED + level.getChunks().size() + TextFormat.GREEN + " chunks, " +
TextFormat.RED + level.getEntities().length + TextFormat.GREEN + " entities, " +
TextFormat.RED + level.getBlockEntities().size() + TextFormat.GREEN + " blockEntities." +
" Time " + ((level.getTickRate() > 1 || level.getTickRateTime() > 40) ? TextFormat.RED : TextFormat.YELLOW) + NukkitMath.round(level.getTickRateTime(), 2) + "ms" +
(level.getTickRate() > 1 ? " (tick rate " + level.getTickRate() + ")" : "")
);
}
return true;
}