diff --git a/Plugins/BuildFiles/common.xml b/Plugins/BuildFiles/common.xml index bc70c93b2..397965bce 100644 --- a/Plugins/BuildFiles/common.xml +++ b/Plugins/BuildFiles/common.xml @@ -293,4 +293,19 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Plugins/Core/src/me/chiss/Core/ClientData/ClientClass.java b/Plugins/Core/src/me/chiss/Core/ClientData/ClientClass.java deleted file mode 100644 index 883e44701..000000000 --- a/Plugins/Core/src/me/chiss/Core/ClientData/ClientClass.java +++ /dev/null @@ -1,483 +0,0 @@ -package me.chiss.Core.ClientData; - -import java.util.AbstractMap; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map.Entry; - - -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; - -import me.chiss.Core.Class.IPvpClass; -import me.chiss.Core.Skill.ISkill; -import me.chiss.Core.Skill.ISkill.SkillType; -import mineplex.core.account.CoreClient; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.minecraft.game.core.classcombat.Class.IPvpClass.ClassType; -import mineplex.minecraft.game.core.classcombat.Class.repository.token.CustomBuildToken; - -public class ClientClass extends ClientDataBase implements IClientClass -{ - //Class and Skills - private IPvpClass _gameClass; - private HashMap> _skillMap; - - //Temp - private IPvpClass _lastClass; - private ItemStack[] _lastArmor; - private HashMap _lastItems; - private HashMap> _lastSkillMap; - - public ClientClass(CoreClient client) - { - super(client, "Class", null); - - _lastItems = new HashMap(); - _lastArmor = new ItemStack[4]; - _lastSkillMap = new HashMap>(); - } - - @Override - public void Load() - { - - } - - @Override - protected void LoadToken(Object token) - { - // TODO Auto-generated method stub - - } - - @Override - public String GetName() - { - return Client.GetPlayerName(); - } - - @Override - public void ResetToDefaults(boolean equipItems, boolean equipDefaultArmor) - { - if (equipDefaultArmor) - { - if (_lastArmor[3] != null) - GetInventory().setHelmet(_lastArmor[3].clone()); - - if (_lastArmor[2] != null) - GetInventory().setChestplate(_lastArmor[2].clone()); - - if (_lastArmor[1] != null) - GetInventory().setLeggings(_lastArmor[1].clone()); - - if (_lastArmor[0] != null) - GetInventory().setBoots(_lastArmor[0].clone()); - } - - if (equipItems) - { - for (Entry defaultItem : _lastItems.entrySet()) - { - GetInventory().setItem(defaultItem.getKey(), (defaultItem.getValue() == null ? new ItemStack(Material.AIR) : defaultItem.getValue().clone())); - } - } - - SetGameClass(_lastClass, false); - - NewSkills(); - for (Entry> entry : _lastSkillMap.entrySet()) - AddSkill(entry.getValue().getKey(), entry.getValue().getValue()); - } - - @Override - public void SetGameClass(IPvpClass gameClass) - { - SetGameClass(gameClass, true); - } - - @Override - public void SetGameClass(IPvpClass gameClass, boolean addDefaultSkills) - { - ClearSkills(); - - _gameClass = gameClass; - - if (_gameClass == null) - return; - - //Load Saved - if (Client.Manager.Classes().GetRestore().IsActive()) - { - Collection> skills = Client.Manager.Classes().GetRestore().GetBuild(Client.GetPlayerName(), gameClass); - - if (skills != null) - { - for (Entry skill : skills) - AddSkill(skill.getKey(), skill.getValue()); - - //Inform - UtilPlayer.message(Client.GetPlayer(), F.main("Class", "Armor Class: " + F.oo(_gameClass.GetName(), true))); - return; - } - } - - _lastClass = gameClass; - - for (ISkill cur : gameClass.GetDefaultSkills().keySet()) - { - if (addDefaultSkills || cur.GetSkillType() == SkillType.Class) - AddSkill(cur, gameClass.GetDefaultSkills().get(cur)); - } - - //Inform - UtilPlayer.message(Client.GetPlayer(), F.main("Class", "Armor Class: " + F.oo(_gameClass.GetName(), true))); - } - - @Override - public IPvpClass GetGameClass() - { - return _gameClass; - } - - @Override - public void ClearDefaults() - { - _lastItems.clear(); - _lastArmor = new ItemStack[4]; - _lastSkillMap.clear(); - } - - public String GetGameClassTag() - { - IPvpClass gameClass = GetGameClass(); - if (gameClass == null) return ""; - return gameClass.GetName().charAt(0)+"."; - } - - public void NewSkills() - { - ClearSkills(); - _skillMap = new HashMap>(); - } - - public void ClearSkills() - { - if (_skillMap != null) - for (Entry entry : _skillMap.values()) - entry.getKey().RemoveUser(Client.GetPlayer()); - - _skillMap = null; - } - - public void AddSkill(String skillName, int level) - { - ISkill skill = Client.Manager.Skills().GetSkill(skillName); - if (skill == null) - return; - - AddSkill(skill, level); - } - - @Override - public void AddSkill(ISkill skill, int level) - { - if (level <= 0) - return; - - if (_skillMap == null) - _skillMap = new HashMap>(); - - if (_skillMap.get(skill.GetSkillType()) != null) - _skillMap.get(skill.GetSkillType()).getKey().RemoveUser(Client.GetPlayer()); - - _skillMap.put(skill.GetSkillType(), new AbstractMap.SimpleEntry(skill, level)); - _lastSkillMap.put(skill.GetSkillType(), new AbstractMap.SimpleEntry(skill, level)); - - skill.AddUser(Client.GetPlayer(), level); - - //Save - if (Client.Manager.Classes().GetRestore().IsActive()) - Client.Manager.Classes().GetRestore().SaveBuild(Client.GetPlayerName(), _gameClass, GetSkills()); - } - - @Override - public void RemoveSkill(ISkill skill) - { - if (skill == null) - return; - - if (_skillMap == null) - return; - - _skillMap.remove(skill.GetSkillType()); - _lastSkillMap.remove(skill.GetSkillType()); - - skill.RemoveUser(Client.GetPlayer()); - } - - @Override - public Collection> GetSkills() - { - if (_skillMap == null) - _skillMap = new HashMap>(); - - return _skillMap.values(); - } - - @Override - public Collection> GetDefaultSkills() - { - return _lastSkillMap.values(); - } - - @Override - public void ResetSkills() - { - for (Entry entry : GetSkills()) - { - entry.getKey().Reset(Client.GetPlayer()); - } - } - - public void ClearDefaultSkills() - { - _lastSkillMap = new HashMap>(); - } - - public boolean IsGameClass(ClassType type) - { - if (GetGameClass() == null) - return false; - - return GetGameClass().GetType() == type; - } - - public ISkill GetSkillByType(SkillType skillType) - { - if (_skillMap == null) - _skillMap = new HashMap>(); - - if (_skillMap.containsKey(skillType)) - return _skillMap.get(skillType).getKey(); - - return null; - } - - public int GetSkillLevel(ISkill skill) - { - //No Class - if (_skillMap == null) - return 0; - - if (_skillMap.containsKey(skill.GetSkillType()) && _skillMap.get(skill.GetSkillType()).getKey() == skill) - return _skillMap.get(skill.GetSkillType()).getValue(); - - return 0; - } - - public void SetSkillLevel(ISkill skill, int level) - { - _skillMap.put(skill.GetSkillType(), new AbstractMap.SimpleEntry(skill, level)); - } - - @Override - public PlayerInventory GetInventory() - { - if (Client.GetPlayer() == null) - return null; - - return Client.GetPlayer().getInventory(); - } - - @Override - public void OpenInventory(Inventory skillsCategory) - { - if (Client.GetPlayer() == null) - return; - - Client.GetPlayer().openInventory(skillsCategory); - } - - @Override - public void CloseInventory() - { - if (Client.GetPlayer() == null) - return; - - Client.GetPlayer().closeInventory(); - } - - @SuppressWarnings("deprecation") - @Override - public void UpdateInventory() - { - if (Client.GetPlayer() == null) - return; - - Client.GetPlayer().updateInventory(); - } - - public void ListSkills(Player caller) - { - UtilPlayer.message(caller, F.main("Skill", "Listing Class Skills;")); - - for (SkillType type : SkillType.values()) - if (caller.isOp() || type != SkillType.Class) - if (_skillMap.containsKey(type)) - UtilPlayer.message(caller, F.desc(type.toString(), _skillMap.get(type).getKey().GetName() + " " + F.elem(_skillMap.get(type).getValue() + "/" + _skillMap.get(type).getKey().GetMaxLevel()))); - } - - @Override - public void AddDefaultArmor(ItemStack[] armorContents) - { - _lastArmor = armorContents; - } - - @Override - public void PutDefaultItem(ItemStack deliverable, int slot) - { - _lastItems.put(slot, deliverable); - } - - @Override - public ItemStack[] GetDefaultArmor() - { - if (_lastArmor[0] == null || _lastArmor[1] == null || _lastArmor[2] == null || _lastArmor[3] == null) - return new ItemStack[4]; - - ItemStack[] armorReturn = new ItemStack[4]; - - armorReturn[3] = _lastArmor[3].clone(); - armorReturn[2] = _lastArmor[2].clone(); - armorReturn[1] = _lastArmor[1].clone(); - armorReturn[0] = _lastArmor[0].clone(); - - return armorReturn; - } - - @Override - public HashMap GetDefaultItems() - { - return _lastItems; - } - - @Override - public void SetDefaultHead(ItemStack armor) - { - _lastArmor[3] = armor; - } - - @Override - public void SetDefaultChest(ItemStack armor) - { - _lastArmor[2] = armor; - } - - @Override - public void SetDefaultLegs(ItemStack armor) - { - _lastArmor[1] = armor; - } - - @Override - public void SetDefaultFeet(ItemStack armor) - { - _lastArmor[0] = armor; - } - - public void EquipCustomBuild(CustomBuildToken customBuild) - { - EquipCustomBuild(customBuild, true, true); - } - - public void EquipCustomBuild(CustomBuildToken customBuild, boolean equipItems, boolean equipDefaultArmor) - { - _lastClass = Client.Manager.Classes().GetClass(customBuild.PvpClassId); - - if (_lastClass == null) - return; - - _lastSkillMap.remove(SkillType.Class); - - if (equipDefaultArmor) - { - SetDefaultHead(ItemStackFactory.Instance.CreateStack(_lastClass.GetHead())); - SetDefaultChest(ItemStackFactory.Instance.CreateStack(_lastClass.GetChestplate())); - SetDefaultLegs(ItemStackFactory.Instance.CreateStack(_lastClass.GetLeggings())); - SetDefaultFeet(ItemStackFactory.Instance.CreateStack(_lastClass.GetBoots())); - } - - if (equipItems) - { - for (int i=0; i < 9; i++) - { - if (customBuild.Slots == null || customBuild.Slots.size() <= i || customBuild.Slots.get(i).Material == "AIR" || customBuild.Slots.get(i).Material == "NULL") - _lastItems.put(i, null); - else - { - /* - if (ItemFactory.Instance.GetItem(customBuild.Slots.get(i).Material) != null) - _lastItems.put(i, ItemFactory.Instance.GetItem(customBuild.Slots.get(i).Material).); - */ - _lastItems.put(i, ItemStackFactory.Instance.CreateStack(Material.getMaterial(customBuild.Slots.get(i).Material), customBuild.Slots.get(i).Amount)); - } - } - } - - if (customBuild.SwordSkillId != -1) - _lastSkillMap.put(SkillType.Sword, Client.Manager.Skills().GetSkillBySalesPackageId(customBuild.SwordSkillId)); - else - _lastSkillMap.remove(SkillType.Sword); - - if (customBuild.AxeSkillId != -1) - _lastSkillMap.put(SkillType.Axe, Client.Manager.Skills().GetSkillBySalesPackageId(customBuild.AxeSkillId)); - else - _lastSkillMap.remove(SkillType.Axe); - - if (customBuild.BowSkillId != -1) - _lastSkillMap.put(SkillType.Bow, Client.Manager.Skills().GetSkillBySalesPackageId(customBuild.BowSkillId)); - else - _lastSkillMap.remove(SkillType.Bow); - - if (customBuild.ClassPassiveASkillId != -1) - _lastSkillMap.put(SkillType.PassiveA, Client.Manager.Skills().GetSkillBySalesPackageId(customBuild.ClassPassiveASkillId)); - else - _lastSkillMap.remove(SkillType.PassiveA); - - if (customBuild.ClassPassiveBSkillId != -1) - _lastSkillMap.put(SkillType.PassiveB, Client.Manager.Skills().GetSkillBySalesPackageId(customBuild.ClassPassiveBSkillId)); - else - _lastSkillMap.remove(SkillType.PassiveB); - - if (customBuild.GlobalPassiveASkillId != -1) - _lastSkillMap.put(SkillType.PassiveC, Client.Manager.Skills().GetSkillBySalesPackageId(customBuild.GlobalPassiveASkillId)); - else - _lastSkillMap.remove(SkillType.PassiveC); - - if (customBuild.GlobalPassiveBSkillId != -1) - _lastSkillMap.put(SkillType.PassiveD, Client.Manager.Skills().GetSkillBySalesPackageId(customBuild.GlobalPassiveBSkillId)); - else - _lastSkillMap.remove(SkillType.PassiveD); - - if (customBuild.GlobalPassiveCSkillId != -1) - _lastSkillMap.put(SkillType.PassiveE, Client.Manager.Skills().GetSkillBySalesPackageId(customBuild.GlobalPassiveCSkillId)); - else - _lastSkillMap.remove(SkillType.PassiveE); - - ResetToDefaults(equipItems, equipDefaultArmor); - - Client.Donor().SetTokens(customBuild.SkillTokensBalance, customBuild.ItemTokensBalance); - - ListSkills(Client.GetPlayer()); - Client.GetPlayer().getWorld().playSound(Client.GetPlayer().getLocation(), Sound.LEVEL_UP, 1f, 1f); - - Client.GetPlayer().sendMessage(F.main("Class", "You equipped " + F.skill(customBuild.Name) + ".")); - } -} diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java index f4d6dd31c..19bf74191 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java @@ -43,7 +43,6 @@ public class LobbyBalancer implements Listener, Runnable synchronized (_serverLock) { - long timeStart = System.currentTimeMillis(); if (_playersSentToBestServer >= _maxPlayersToSendToBestServer) { _playersSentToBestServer = 0; diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/DynamicMonitor.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/DynamicMonitor.java deleted file mode 100644 index 1b7ad77da..000000000 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/DynamicMonitor.java +++ /dev/null @@ -1,6 +0,0 @@ -package mineplex.servermonitor; - -public class DynamicMonitor -{ - -} diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/GroupStatusData.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/GroupStatusData.java index c8f4de139..b38d5cb52 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/GroupStatusData.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/GroupStatusData.java @@ -3,11 +3,24 @@ package mineplex.servermonitor; import java.util.ArrayList; import java.util.List; + public class GroupStatusData { public String Name; + public int EmptyServers; public int Players; public int MaxPlayers; public List Servers = new ArrayList(); + + public void addServer(ServerStatusData serverStatusData) + { + Players += serverStatusData.Players; + MaxPlayers += serverStatusData.MaxPlayers; + + if (serverStatusData.Players == 0) + EmptyServers++; + + Servers.add(serverStatusData); + } } diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/Repository.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/Repository.java index 7debf6a20..770167b42 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/Repository.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/Repository.java @@ -6,8 +6,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; + public class Repository { private String _connectionString = "jdbc:mysql://localhost:3306/ServerStatus"; @@ -16,7 +18,10 @@ public class Repository private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS ServerStatus (id INT NOT NULL AUTO_INCREMENT, serverName VARCHAR(256), serverGroup VARCHAR(256), address VARCHAR(256), updated LONG, motd VARCHAR(256), players INT, maxPlayers INT, tps INT, ram INT, maxRam INT, PRIMARY KEY (id));"; private static String RETRIEVE_OLD_SERVER_STATUSES = "SELECT serverName, address, motd, players, maxPlayers FROM ServerStatus WHERE TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) > 10;"; - private static String RETRIEVE_SERVER_STATUSES = "SELECT serverName, address, motd, players, maxPlayers FROM ServerStatus WHERE TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) <= 10;"; + + private static String CREATE_DYNAMIC_TABLE = "CREATE TABLE IF NOT EXISTS DynamicServers (id INT NOT NULL AUTO_INCREMENT, serverName VARCHAR(256), address VARCHAR(256), PRIMARY KEY (id));"; + private static String RETRIEVE_AVAILABLE_SERVERS = "SELECT serverName, address FROM DynamicServers;"; + private static String RETRIEVE_SERVERGROUP_STATUSES = "SELECT serverName, serverGroup, address, players, maxPlayers FROM ServerStatus WHERE TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) <= 10;"; public void initialize() { @@ -63,6 +68,50 @@ public class Repository } } } + + connection = null; + preparedStatement = null; + + try + { + Class.forName("com.mysql.jdbc.Driver"); + + connection = DriverManager.getConnection(_connectionString, _userName, _password); + + // Create table + preparedStatement = connection.prepareStatement(CREATE_DYNAMIC_TABLE); + preparedStatement.execute(); + } + catch (Exception exception) + { + exception.printStackTrace(); + } + finally + { + if (preparedStatement != null) + { + try + { + preparedStatement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + + if (connection != null) + { + try + { + connection.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + } } public List retrieveOldServerStatuses() @@ -141,18 +190,18 @@ public class Repository return serverData; } - public List retrieveGroupStatusData() + public HashMap retrieveGroupStatusData() { Connection connection = null; ResultSet resultSet = null; PreparedStatement preparedStatement = null; - List groupData = new ArrayList(); + HashMap groupData = new HashMap(); try { connection = DriverManager.getConnection(_connectionString, _userName, _password); - preparedStatement = connection.prepareStatement(RETRIEVE_SERVER_STATUSES); + preparedStatement = connection.prepareStatement(RETRIEVE_SERVERGROUP_STATUSES); resultSet = preparedStatement.executeQuery(); while (resultSet.next()) @@ -160,15 +209,89 @@ public class Repository ServerStatusData serverStatusData = new ServerStatusData(); serverStatusData.Name = resultSet.getString(1); - - String addressPortString = resultSet.getString(2); + String serverGroup = resultSet.getString(2); + String addressPortString = resultSet.getString(3); serverStatusData.Address = addressPortString.split(":")[0]; serverStatusData.Port = Integer.parseInt(addressPortString.split(":")[1]); - serverStatusData.Motd = resultSet.getString(3); serverStatusData.Players = resultSet.getInt(4); serverStatusData.MaxPlayers = resultSet.getInt(5); - serverData.add(serverStatusData); + if (!groupData.containsKey(serverGroup)) + { + groupData.put(serverGroup, new GroupStatusData()); + } + + groupData.get(serverGroup).addServer(serverStatusData); + } + } + catch (Exception exception) + { + exception.printStackTrace(); + } + finally + { + if (preparedStatement != null) + { + try + { + preparedStatement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + + if (resultSet != null) + { + try + { + resultSet.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + + if (connection != null) + { + try + { + connection.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + } + + return groupData; + } + + public List retrieveDynamicServers() + { + Connection connection = null; + ResultSet resultSet = null; + PreparedStatement preparedStatement = null; + List serverData = new ArrayList(); + + try + { + connection = DriverManager.getConnection(_connectionString, _userName, _password); + + preparedStatement = connection.prepareStatement(RETRIEVE_AVAILABLE_SERVERS); + resultSet = preparedStatement.executeQuery(); + + while (resultSet.next()) + { + DynamicServerData dynamicServer = new DynamicServerData(); + + dynamicServer.Name = resultSet.getString(1); + dynamicServer.Address = resultSet.getString(2); + + serverData.add(dynamicServer); } } catch (Exception exception) diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java index e2149ce95..dad46b169 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java @@ -2,6 +2,9 @@ package mineplex.servermonitor; import java.io.BufferedReader; import java.io.InputStreamReader; +import java.util.List; +import java.util.Map.Entry; + public class ServerMonitor { @@ -14,6 +17,7 @@ public class ServerMonitor while (true) { + /* if (_count % 20 == 0) { for (ServerStatusData statusData : _repository.retrieveOldServerStatuses()) @@ -51,27 +55,74 @@ public class ServerMonitor System.out.println("Sent restart command to " + key + ""); } } - + */ if (_count % 10 == 0) { - HashMap - for (ServerStatusData statusData : _repository.retrieveGroupStatusData()) + List dynamicServers = _repository.retrieveDynamicServers(); + + for (DynamicServerData dynamicServer : dynamicServers) { - String key = statusData.Address + " " + statusData.Name; - - String cmd = "/home/mineplex/restartServer.sh"; Process process = null; try { - process = new ProcessBuilder(new String[] {"/bin/sh", "-x", cmd, statusData.Address, statusData.Name}).start(); + process = new ProcessBuilder(new String[] {"/bin/sh", "-x", "/home/mineplex/retrieveRemoteFreeMemory.sh", dynamicServer.Address }).start(); + process.waitFor(); + BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); + String line = reader.readLine(); + + if (line != null) + { + dynamicServer.FreeRam = Integer.parseInt(line) / 1024; + System.out.println(dynamicServer.Name + " has " + dynamicServer.FreeRam + "KB of free ram."); + } + + process = new ProcessBuilder(new String[] {"/bin/sh", "-x", "/home/mineplex/retrieveServerCount.sh", dynamicServer.Address }).start(); + process.waitFor(); + reader = new BufferedReader(new InputStreamReader(process.getInputStream())); + line = reader.readLine(); + + int serverCount = 0; + + while (line != null) + { + serverCount++; + line = reader.readLine(); + } + + dynamicServer.ServerCount = serverCount; + System.out.println(dynamicServer.Name + " has " + dynamicServer.ServerCount + " servers running."); + } + catch (Exception e) + { + e.printStackTrace(); + } + finally + { + if (process != null) + { + process.destroy(); + } + } + } + + /* + for (Entry statusEntry : _repository.retrieveGroupStatusData().entrySet()) + { + GroupStatusData groupData = statusEntry.getValue(); + + Process process = null; + + try + { + process = new ProcessBuilder(new String[] {"/bin/sh", "-x", "/home/mineplex/retrieveRemoteFreeMemory.sh", "208.115.216.114" }).start(); process.waitFor(); BufferedReader reader=new BufferedReader(new InputStreamReader(process.getInputStream())); String line = reader.readLine(); while(line != null) { - System.out.println(line); + line=reader.readLine(); } } @@ -87,8 +138,9 @@ public class ServerMonitor } } - System.out.println("Sent restart command to " + key + ""); + //System.out.println("Sent restart command to " + key + ""); } + */ } try