diff --git a/src/main/java/org/ultramine/server/BackupManager.java b/src/main/java/org/ultramine/server/BackupManager.java index 0ad51f7..bada4a5 100644 --- a/src/main/java/org/ultramine/server/BackupManager.java +++ b/src/main/java/org/ultramine/server/BackupManager.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.ultramine.commands.CommandContext; -import org.ultramine.server.UltramineServerConfig.SettingsConf.AutoBackupConf; +import org.ultramine.server.UltramineServerConfig.ToolsConf.AutoBackupConf; import org.ultramine.server.data.ServerDataLoader; import org.ultramine.server.util.GlobalExecutors; import org.ultramine.server.util.ZipUtil; @@ -74,7 +74,7 @@ isBackuping = false; } - AutoBackupConf conf = ConfigurationHandler.getServerConfig().settings.autobackup; + AutoBackupConf conf = ConfigurationHandler.getServerConfig().tools.autobackup; if(conf.enabled && (System.currentTimeMillis() - lastBackupTime >= conf.interval*60*1000) && !isBackuping) { lastBackupTime = System.currentTimeMillis(); diff --git a/src/main/java/org/ultramine/server/UMEventHandler.java b/src/main/java/org/ultramine/server/UMEventHandler.java index 39b86ea..98a2bfd 100644 --- a/src/main/java/org/ultramine/server/UMEventHandler.java +++ b/src/main/java/org/ultramine/server/UMEventHandler.java @@ -1,6 +1,7 @@ package org.ultramine.server; -import org.ultramine.server.UltramineServerConfig.SettingsConf.MessagesConf.AutoBroacastConf; +import org.ultramine.server.UltramineServerConfig.ToolsConf.AutoBroacastConf; +import org.ultramine.server.UltramineServerConfig.ToolsConf.AutoDebugInfoConf; import org.ultramine.server.chunk.ChunkProfiler; import org.ultramine.server.util.BasicTypeParser; import org.ultramine.server.util.WarpLocation; @@ -72,54 +73,58 @@ MinecraftServer server = MinecraftServer.getServer(); server.getBackupManager().tick(); - AutoBroacastConf cfg = ConfigurationHandler.getServerConfig().settings.messages.autobroadcast; + AutoDebugInfoConf cfg = ConfigurationHandler.getServerConfig().tools.autoDebugInfo; if(cfg.enabled && server.getTickCounter() % (cfg.intervalSeconds*20) == 0) { - if(cfg.showDebugInfo) + double tps = Math.round(server.currentTPS*10)/10d; + double downtime = server.currentWait/1000/1000d; + double pickdowntime = server.pickWait/1000/1000d; + int load = (int)Math.round((50-downtime)/50*100); + int pickload = (int)Math.round((50-pickdowntime)/50*100); + ChatComponentText loadcomp = new ChatComponentText(Integer.toString(load).concat("%")); + ChatComponentText pickloadcomp = new ChatComponentText(Integer.toString(pickload).concat("%")); + ChatComponentText tpscomp = new ChatComponentText(Double.toString(tps)); + loadcomp.getChatStyle().setColor(load > 100 ? RED : DARK_GREEN); + pickloadcomp.getChatStyle().setColor(pickload >= 200 ? RED : DARK_GREEN); + tpscomp.getChatStyle().setColor(tps < 15 ? RED : DARK_GREEN); + + int mobcount = 0; + int itemcount = 0; + + for(WorldServer world : server.getMultiWorld().getLoadedWorlds()) { - double tps = Math.round(server.currentTPS*10)/10d; - double downtime = server.currentWait/1000/1000d; - double pickdowntime = server.pickWait/1000/1000d; - int load = (int)Math.round((50-downtime)/50*100); - int pickload = (int)Math.round((50-pickdowntime)/50*100); - ChatComponentText loadcomp = new ChatComponentText(Integer.toString(load).concat("%")); - ChatComponentText pickloadcomp = new ChatComponentText(Integer.toString(pickload).concat("%")); - ChatComponentText tpscomp = new ChatComponentText(Double.toString(tps)); - loadcomp.getChatStyle().setColor(load > 100 ? RED : DARK_GREEN); - pickloadcomp.getChatStyle().setColor(pickload >= 200 ? RED : DARK_GREEN); - tpscomp.getChatStyle().setColor(tps < 15 ? RED : DARK_GREEN); - - int mobcount = 0; - int itemcount = 0; - - for(WorldServer world : server.getMultiWorld().getLoadedWorlds()) + for(Entity ent : GenericIterableFactory.newCastingIterable(world.loadedEntityList, Entity.class)) { - for(Entity ent : GenericIterableFactory.newCastingIterable(world.loadedEntityList, Entity.class)) - { - if(ent.isEntityLiving() && !ent.isEntityPlayer()) - mobcount++; - else if(ent instanceof EntityItem) - itemcount++; - } + if(ent.isEntityLiving() && !ent.isEntityPlayer()) + mobcount++; + else if(ent instanceof EntityItem) + itemcount++; } - - ChatComponentTranslation full = new ChatComponentTranslation("ultramine.autobroadcast.debugmsg", loadcomp, pickloadcomp, tpscomp, - Integer.toString(mobcount), Integer.toString(itemcount)); - full.getChatStyle().setColor(YELLOW); - - server.getConfigurationManager().sendChatMsg(full); } - if(cfg.messages.length != 0) + ChatComponentTranslation full = new ChatComponentTranslation("ultramine.autobroadcast.debugmsg", loadcomp, pickloadcomp, tpscomp, + Integer.toString(mobcount), Integer.toString(itemcount)); + full.getChatStyle().setColor(YELLOW); + + server.addChatMessage(full); + for(EntityPlayerMP player : GenericIterableFactory.newCastingIterable(server.getConfigurationManager().playerEntityList, EntityPlayerMP.class)) + if(PermissionHandler.getInstance().has(player, "show.debuginfo")) + player.addChatMessage(full); + } + + AutoBroacastConf msgcfg = ConfigurationHandler.getServerConfig().tools.autobroadcast; + if(msgcfg.enabled && server.getTickCounter() % (msgcfg.intervalSeconds*20) == 0) + { + if(msgcfg.messages.length != 0) { - if(cfg.showAllMessages) + if(msgcfg.showAllMessages) { - for(String msg : cfg.messages) + for(String msg : msgcfg.messages) broadcastMessage(msg); } else { - broadcastMessage(cfg.messages[server.getTickCounter() % (cfg.intervalSeconds*20*cfg.messages.length) / (cfg.intervalSeconds*20)]); + broadcastMessage(msgcfg.messages[server.getTickCounter() % (msgcfg.intervalSeconds*20*msgcfg.messages.length) / (msgcfg.intervalSeconds*20)]); } } } diff --git a/src/main/java/org/ultramine/server/UltramineServerConfig.java b/src/main/java/org/ultramine/server/UltramineServerConfig.java index e8a2297..17b736d 100644 --- a/src/main/java/org/ultramine/server/UltramineServerConfig.java +++ b/src/main/java/org/ultramine/server/UltramineServerConfig.java @@ -9,6 +9,7 @@ { public ListenConf listen = new ListenConf(); public SettingsConf settings = new SettingsConf(); + public ToolsConf tools = new ToolsConf(); public Map databases = new HashMap(); public VanillaConf vanilla = new VanillaConf(); @@ -46,7 +47,6 @@ public SpawnLocationsConf spawnLocations = new SpawnLocationsConf(); public TeleportationConf teleportation = new TeleportationConf(); public MessagesConf messages = new MessagesConf(); - public AutoBackupConf autobackup = new AutoBackupConf(); public WatchdogThreadConf watchdogThread = new WatchdogThreadConf(); public SQLServerStorageConf inSQLServerStorage = new SQLServerStorageConf(); public SecurityConf security = new SecurityConf(); @@ -90,28 +90,8 @@ public static class MessagesConf { - public AutoBroacastConf autobroadcast = new AutoBroacastConf(); public boolean announcePlayerAchievements = true; public String motd = "A Minecraft Server"; - - public static class AutoBroacastConf - { - public boolean enabled = false; - public int intervalSeconds = 600; - public boolean showDebugInfo = false; - public String[] messages = new String[0]; - public boolean showAllMessages = false; - } - } - - public static class AutoBackupConf - { - public boolean enabled = false; - public int interval = 60; //minutes - public int maxBackups = 10; - public int maxDirSize = 50000; //megabytes - public List worlds = null; - public boolean notifyPlayers = true; } public static class WatchdogThreadConf @@ -132,6 +112,37 @@ public boolean checkBreakSpeed = true; } } + + public static class ToolsConf + { + public AutoBroacastConf autobroadcast = new AutoBroacastConf(); + public AutoDebugInfoConf autoDebugInfo = new AutoDebugInfoConf(); + public AutoBackupConf autobackup = new AutoBackupConf(); + + public static class AutoBroacastConf + { + public boolean enabled = false; + public int intervalSeconds = 600; + public String[] messages = new String[0]; + public boolean showAllMessages = false; + } + + public static class AutoDebugInfoConf + { + public boolean enabled = false; + public int intervalSeconds = 600; + } + + public static class AutoBackupConf + { + public boolean enabled = false; + public int interval = 60; //minutes + public int maxBackups = 10; + public int maxDirSize = 50000; //megabytes + public List worlds = null; + public boolean notifyPlayers = true; + } + } public static class DatabaseConf {