Merge branch 'master' of ssh://dev.mineplex.com:7999/min/mineplex
This commit is contained in:
commit
9f11352f10
@ -293,4 +293,19 @@
|
|||||||
</jar>
|
</jar>
|
||||||
<copy file="../bin/Mineplexer.jar" todir="../../Testing/Proxy/plugins"/>
|
<copy file="../bin/Mineplexer.jar" todir="../../Testing/Proxy/plugins"/>
|
||||||
</target>
|
</target>
|
||||||
|
<target name ="ServerMonitor" description="ServerMonitor">
|
||||||
|
<jar jarfile="../bin/ServerMonitor.jar">
|
||||||
|
<fileset dir="../Mineplex.ServerMonitor/bin">
|
||||||
|
<include name="**/*.class"/>
|
||||||
|
</fileset>
|
||||||
|
|
||||||
|
<zipfileset src="../Libraries/mysql.zip" />
|
||||||
|
|
||||||
|
<manifest>
|
||||||
|
<attribute name="Main-Class"
|
||||||
|
value="mineplex.servermonitor.ServerMonitor"/>
|
||||||
|
</manifest>
|
||||||
|
</jar>
|
||||||
|
<copy file="../bin/ServerMonitor.jar" todir="../../Testing/ServerMonitor/"/>
|
||||||
|
</target>
|
||||||
</project>
|
</project>
|
@ -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<Object> implements IClientClass
|
|
||||||
{
|
|
||||||
//Class and Skills
|
|
||||||
private IPvpClass _gameClass;
|
|
||||||
private HashMap<SkillType, Entry<ISkill, Integer>> _skillMap;
|
|
||||||
|
|
||||||
//Temp
|
|
||||||
private IPvpClass _lastClass;
|
|
||||||
private ItemStack[] _lastArmor;
|
|
||||||
private HashMap<Integer, ItemStack> _lastItems;
|
|
||||||
private HashMap<SkillType, Entry<ISkill, Integer>> _lastSkillMap;
|
|
||||||
|
|
||||||
public ClientClass(CoreClient client)
|
|
||||||
{
|
|
||||||
super(client, "Class", null);
|
|
||||||
|
|
||||||
_lastItems = new HashMap<Integer, ItemStack>();
|
|
||||||
_lastArmor = new ItemStack[4];
|
|
||||||
_lastSkillMap = new HashMap<SkillType, Entry<ISkill, Integer>>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@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<Integer, ItemStack> defaultItem : _lastItems.entrySet())
|
|
||||||
{
|
|
||||||
GetInventory().setItem(defaultItem.getKey(), (defaultItem.getValue() == null ? new ItemStack(Material.AIR) : defaultItem.getValue().clone()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SetGameClass(_lastClass, false);
|
|
||||||
|
|
||||||
NewSkills();
|
|
||||||
for (Entry<SkillType, Entry<ISkill, Integer>> 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<Entry<ISkill, Integer>> skills = Client.Manager.Classes().GetRestore().GetBuild(Client.GetPlayerName(), gameClass);
|
|
||||||
|
|
||||||
if (skills != null)
|
|
||||||
{
|
|
||||||
for (Entry<ISkill, Integer> 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<SkillType, Entry<ISkill, Integer>>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ClearSkills()
|
|
||||||
{
|
|
||||||
if (_skillMap != null)
|
|
||||||
for (Entry<ISkill, Integer> 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<SkillType, Entry<ISkill, Integer>>();
|
|
||||||
|
|
||||||
if (_skillMap.get(skill.GetSkillType()) != null)
|
|
||||||
_skillMap.get(skill.GetSkillType()).getKey().RemoveUser(Client.GetPlayer());
|
|
||||||
|
|
||||||
_skillMap.put(skill.GetSkillType(), new AbstractMap.SimpleEntry<ISkill, Integer>(skill, level));
|
|
||||||
_lastSkillMap.put(skill.GetSkillType(), new AbstractMap.SimpleEntry<ISkill, Integer>(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<Entry<ISkill, Integer>> GetSkills()
|
|
||||||
{
|
|
||||||
if (_skillMap == null)
|
|
||||||
_skillMap = new HashMap<SkillType, Entry<ISkill, Integer>>();
|
|
||||||
|
|
||||||
return _skillMap.values();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<Entry<ISkill, Integer>> GetDefaultSkills()
|
|
||||||
{
|
|
||||||
return _lastSkillMap.values();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ResetSkills()
|
|
||||||
{
|
|
||||||
for (Entry<ISkill, Integer> entry : GetSkills())
|
|
||||||
{
|
|
||||||
entry.getKey().Reset(Client.GetPlayer());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ClearDefaultSkills()
|
|
||||||
{
|
|
||||||
_lastSkillMap = new HashMap<SkillType, Entry<ISkill, Integer>>();
|
|
||||||
}
|
|
||||||
|
|
||||||
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<SkillType, Entry<ISkill, Integer>>();
|
|
||||||
|
|
||||||
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<ISkill, Integer>(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<Integer, ItemStack> 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) + "."));
|
|
||||||
}
|
|
||||||
}
|
|
BIN
Plugins/Libraries/mysql.zip
Normal file
BIN
Plugins/Libraries/mysql.zip
Normal file
Binary file not shown.
@ -43,7 +43,6 @@ public class LobbyBalancer implements Listener, Runnable
|
|||||||
|
|
||||||
synchronized (_serverLock)
|
synchronized (_serverLock)
|
||||||
{
|
{
|
||||||
long timeStart = System.currentTimeMillis();
|
|
||||||
if (_playersSentToBestServer >= _maxPlayersToSendToBestServer)
|
if (_playersSentToBestServer >= _maxPlayersToSendToBestServer)
|
||||||
{
|
{
|
||||||
_playersSentToBestServer = 0;
|
_playersSentToBestServer = 0;
|
||||||
|
@ -15,9 +15,10 @@ public class ServerStatusRepository
|
|||||||
private String _userName;
|
private String _userName;
|
||||||
private String _password;
|
private String _password;
|
||||||
|
|
||||||
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 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, lastTimeWithPlayers LONG, motd VARCHAR(256), players INT, maxPlayers INT, tps INT, ram INT, maxRam INT, PRIMARY KEY (id));";
|
||||||
private static String INSERT_PLAYER_COUNT = "INSERT INTO ServerStatus values(default, ?, ?, ?, now(), 'Configuring server.', ?, ?, 0, ?, ?);";
|
private static String INSERT_PLAYER_COUNT = "INSERT INTO ServerStatus (serverName, serverGroup, address, updated, motd, players, maxPlayers, tps, ram, maxRam) values(default, ?, ?, ?, now(), 'Configuring server.', ?, ?, 0, ?, ?);";
|
||||||
private static String UPDATE_PLAYER_COUNT = "UPDATE ServerStatus SET updated = now(), serverName = ?, serverGroup = ?, motd = ?, players = ?, maxPlayers = ?, tps = ?, ram = ?, maxRam = ? WHERE id = ?;";
|
private static String UPDATE_PLAYER_COUNT_WITH_PLAYERS = "UPDATE ServerStatus SET updated = now(), serverName = ?, serverGroup = ?, motd = ?, players = ?, maxPlayers = ?, tps = ?, ram = ?, maxRam = ?, lastTimeWithPlayers = now() WHERE id = ?;";
|
||||||
|
private static String UPDATE_PLAYER_COUNT_WITHOUT_PLAYERS = "UPDATE ServerStatus SET updated = now(), serverName = ?, serverGroup = ?, motd = ?, players = ?, maxPlayers = ?, tps = ?, ram = ?, maxRam = ? WHERE id = ?;";
|
||||||
private static String RETRIEVE_ID = "SELECT id FROM ServerStatus WHERE address = ?;";
|
private static String RETRIEVE_ID = "SELECT id FROM ServerStatus WHERE address = ?;";
|
||||||
private static String RETRIEVE_SERVER_STATUSES = "SELECT serverName, motd, players, maxPlayers FROM ServerStatus WHERE TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) < 10;";
|
private static String RETRIEVE_SERVER_STATUSES = "SELECT serverName, motd, players, maxPlayers FROM ServerStatus WHERE TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) < 10;";
|
||||||
|
|
||||||
@ -173,7 +174,7 @@ public class ServerStatusRepository
|
|||||||
{
|
{
|
||||||
connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||||
|
|
||||||
preparedStatement = connection.prepareStatement(UPDATE_PLAYER_COUNT, Statement.RETURN_GENERATED_KEYS);
|
preparedStatement = connection.prepareStatement(players != 0 ? UPDATE_PLAYER_COUNT_WITH_PLAYERS : UPDATE_PLAYER_COUNT_WITHOUT_PLAYERS, Statement.RETURN_GENERATED_KEYS);
|
||||||
|
|
||||||
preparedStatement.setString(1, _serverName);
|
preparedStatement.setString(1, _serverName);
|
||||||
preparedStatement.setString(2, _serverGroup);
|
preparedStatement.setString(2, _serverGroup);
|
||||||
|
@ -55,7 +55,7 @@ public class LobbyMenu extends ShopPageBase<ServerManager, LobbyShop> implements
|
|||||||
Material status = Material.IRON_BLOCK;
|
Material status = Material.IRON_BLOCK;
|
||||||
List<String> lore = new ArrayList<String>();
|
List<String> lore = new ArrayList<String>();
|
||||||
|
|
||||||
if (slot >= 27)
|
if (slot >= 36)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (serverInfo.Name.equalsIgnoreCase(Plugin.getStatusManager().getCurrentServerName()))
|
if (serverInfo.Name.equalsIgnoreCase(Plugin.getStatusManager().getCurrentServerName()))
|
||||||
@ -83,7 +83,7 @@ public class LobbyMenu extends ShopPageBase<ServerManager, LobbyShop> implements
|
|||||||
slot += 1;
|
slot += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (slot < 27)
|
while (slot < 36)
|
||||||
{
|
{
|
||||||
setItem(slot, null);
|
setItem(slot, null);
|
||||||
slot++;
|
slot++;
|
||||||
|
@ -102,7 +102,7 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
|||||||
ChatColor.RESET + "One in the Quiver",
|
ChatColor.RESET + "One in the Quiver",
|
||||||
ChatColor.RESET + "Dragon Escape",
|
ChatColor.RESET + "Dragon Escape",
|
||||||
ChatColor.RESET + "Milk the Cow",
|
ChatColor.RESET + "Milk the Cow",
|
||||||
ChatColor.RESET + "A Barbarian's Life",
|
ChatColor.RESET + "Super Paintball",
|
||||||
ChatColor.RESET + "Turf Forts",
|
ChatColor.RESET + "Turf Forts",
|
||||||
ChatColor.RESET + "Death Tag",
|
ChatColor.RESET + "Death Tag",
|
||||||
ChatColor.RESET + "Bacon Brawl",
|
ChatColor.RESET + "Bacon Brawl",
|
||||||
@ -120,7 +120,7 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
|||||||
ChatColor.RESET + "One in the Quiver",
|
ChatColor.RESET + "One in the Quiver",
|
||||||
ChatColor.RESET + "Dragon Escape",
|
ChatColor.RESET + "Dragon Escape",
|
||||||
ChatColor.RESET + "Milk the Cow",
|
ChatColor.RESET + "Milk the Cow",
|
||||||
ChatColor.RESET + "A Barbarian's Life",
|
ChatColor.RESET + "Super Paintball",
|
||||||
ChatColor.RESET + "Turf Forts",
|
ChatColor.RESET + "Turf Forts",
|
||||||
ChatColor.RESET + "Death Tag",
|
ChatColor.RESET + "Death Tag",
|
||||||
ChatColor.RESET + "Bacon Brawl",
|
ChatColor.RESET + "Bacon Brawl",
|
||||||
@ -138,7 +138,7 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
|||||||
ChatColor.RESET + "One in the Quiver",
|
ChatColor.RESET + "One in the Quiver",
|
||||||
ChatColor.RESET + "Dragon Escape",
|
ChatColor.RESET + "Dragon Escape",
|
||||||
ChatColor.RESET + "Milk the Cow",
|
ChatColor.RESET + "Milk the Cow",
|
||||||
ChatColor.RESET + "A Barbarian's Life",
|
ChatColor.RESET + "Super Paintball",
|
||||||
ChatColor.RESET + "Turf Forts",
|
ChatColor.RESET + "Turf Forts",
|
||||||
ChatColor.RESET + "Death Tag",
|
ChatColor.RESET + "Death Tag",
|
||||||
ChatColor.RESET + "Bacon Brawl",
|
ChatColor.RESET + "Bacon Brawl",
|
||||||
@ -156,7 +156,7 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
|||||||
ChatColor.RESET + C.Bold + ChatColor.GREEN + "One in the Quiver",
|
ChatColor.RESET + C.Bold + ChatColor.GREEN + "One in the Quiver",
|
||||||
ChatColor.RESET + "Dragon Escape",
|
ChatColor.RESET + "Dragon Escape",
|
||||||
ChatColor.RESET + "Milk the Cow",
|
ChatColor.RESET + "Milk the Cow",
|
||||||
ChatColor.RESET + "A Barbarian's Life",
|
ChatColor.RESET + "Super Paintball",
|
||||||
ChatColor.RESET + "Turf Forts",
|
ChatColor.RESET + "Turf Forts",
|
||||||
ChatColor.RESET + "Death Tag",
|
ChatColor.RESET + "Death Tag",
|
||||||
ChatColor.RESET + "Bacon Brawl",
|
ChatColor.RESET + "Bacon Brawl",
|
||||||
@ -174,7 +174,7 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
|||||||
ChatColor.RESET + "One in the Quiver",
|
ChatColor.RESET + "One in the Quiver",
|
||||||
ChatColor.RESET + C.Bold + ChatColor.GREEN + "Dragon Escape",
|
ChatColor.RESET + C.Bold + ChatColor.GREEN + "Dragon Escape",
|
||||||
ChatColor.RESET + "Milk the Cow",
|
ChatColor.RESET + "Milk the Cow",
|
||||||
ChatColor.RESET + "A Barbarian's Life",
|
ChatColor.RESET + "Super Paintball",
|
||||||
ChatColor.RESET + "Turf Forts",
|
ChatColor.RESET + "Turf Forts",
|
||||||
ChatColor.RESET + "Death Tag",
|
ChatColor.RESET + "Death Tag",
|
||||||
ChatColor.RESET + "Bacon Brawl",
|
ChatColor.RESET + "Bacon Brawl",
|
||||||
@ -192,14 +192,14 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
|||||||
ChatColor.RESET + "One in the Quiver",
|
ChatColor.RESET + "One in the Quiver",
|
||||||
ChatColor.RESET + "Dragon Escape",
|
ChatColor.RESET + "Dragon Escape",
|
||||||
ChatColor.RESET + C.Bold + ChatColor.GREEN + "Milk the Cow",
|
ChatColor.RESET + C.Bold + ChatColor.GREEN + "Milk the Cow",
|
||||||
ChatColor.RESET + "A Barbarian's Life",
|
ChatColor.RESET + "Super Paintball",
|
||||||
ChatColor.RESET + "Turf Forts",
|
ChatColor.RESET + "Turf Forts",
|
||||||
ChatColor.RESET + "Death Tag",
|
ChatColor.RESET + "Death Tag",
|
||||||
ChatColor.RESET + "Bacon Brawl",
|
ChatColor.RESET + "Bacon Brawl",
|
||||||
ChatColor.RESET + "Squid Sauce"
|
ChatColor.RESET + "Squid Sauce"
|
||||||
}));
|
}));
|
||||||
|
|
||||||
_minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String []
|
_minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_BARDING.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String []
|
||||||
{
|
{
|
||||||
ChatColor.RESET + "",
|
ChatColor.RESET + "",
|
||||||
ChatColor.RESET + "Play all of these fun minigames:",
|
ChatColor.RESET + "Play all of these fun minigames:",
|
||||||
@ -210,7 +210,7 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
|||||||
ChatColor.RESET + "One in the Quiver",
|
ChatColor.RESET + "One in the Quiver",
|
||||||
ChatColor.RESET + "Dragon Escape",
|
ChatColor.RESET + "Dragon Escape",
|
||||||
ChatColor.RESET + "Milk the Cow",
|
ChatColor.RESET + "Milk the Cow",
|
||||||
ChatColor.RESET + C.Bold + ChatColor.GREEN + "A Barbarian's Life",
|
ChatColor.RESET + C.Bold + ChatColor.GREEN + "Super Paintball",
|
||||||
ChatColor.RESET + "Turf Forts",
|
ChatColor.RESET + "Turf Forts",
|
||||||
ChatColor.RESET + "Death Tag",
|
ChatColor.RESET + "Death Tag",
|
||||||
ChatColor.RESET + "Bacon Brawl",
|
ChatColor.RESET + "Bacon Brawl",
|
||||||
@ -228,7 +228,7 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
|||||||
ChatColor.RESET + "One in the Quiver",
|
ChatColor.RESET + "One in the Quiver",
|
||||||
ChatColor.RESET + "Dragon Escape",
|
ChatColor.RESET + "Dragon Escape",
|
||||||
ChatColor.RESET + "Milk the Cow",
|
ChatColor.RESET + "Milk the Cow",
|
||||||
ChatColor.RESET + "A Barbarian's Life",
|
ChatColor.RESET + "Super Paintball",
|
||||||
ChatColor.RESET + C.Bold + ChatColor.GREEN + "Turf Forts",
|
ChatColor.RESET + C.Bold + ChatColor.GREEN + "Turf Forts",
|
||||||
ChatColor.RESET + "Death Tag",
|
ChatColor.RESET + "Death Tag",
|
||||||
ChatColor.RESET + "Bacon Brawl",
|
ChatColor.RESET + "Bacon Brawl",
|
||||||
@ -246,7 +246,7 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
|||||||
ChatColor.RESET + "One in the Quiver",
|
ChatColor.RESET + "One in the Quiver",
|
||||||
ChatColor.RESET + "Dragon Escape",
|
ChatColor.RESET + "Dragon Escape",
|
||||||
ChatColor.RESET + "Milk the Cow",
|
ChatColor.RESET + "Milk the Cow",
|
||||||
ChatColor.RESET + "A Barbarian's Life",
|
ChatColor.RESET + "Super Paintball",
|
||||||
ChatColor.RESET + "Turf Forts",
|
ChatColor.RESET + "Turf Forts",
|
||||||
ChatColor.RESET + C.Bold + ChatColor.GREEN + "Death Tag",
|
ChatColor.RESET + C.Bold + ChatColor.GREEN + "Death Tag",
|
||||||
ChatColor.RESET + "Bacon Brawl",
|
ChatColor.RESET + "Bacon Brawl",
|
||||||
@ -264,7 +264,7 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
|||||||
ChatColor.RESET + "One in the Quiver",
|
ChatColor.RESET + "One in the Quiver",
|
||||||
ChatColor.RESET + "Dragon Escape",
|
ChatColor.RESET + "Dragon Escape",
|
||||||
ChatColor.RESET + "Milk the Cow",
|
ChatColor.RESET + "Milk the Cow",
|
||||||
ChatColor.RESET + "A Barbarian's Life",
|
ChatColor.RESET + "Super Paintball",
|
||||||
ChatColor.RESET + "Turf Forts",
|
ChatColor.RESET + "Turf Forts",
|
||||||
ChatColor.RESET + "Death Tag",
|
ChatColor.RESET + "Death Tag",
|
||||||
ChatColor.RESET + C.Bold + ChatColor.GREEN + "Bacon Brawl",
|
ChatColor.RESET + C.Bold + ChatColor.GREEN + "Bacon Brawl",
|
||||||
@ -282,7 +282,7 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
|||||||
ChatColor.RESET + "One in the Quiver",
|
ChatColor.RESET + "One in the Quiver",
|
||||||
ChatColor.RESET + "Dragon Escape",
|
ChatColor.RESET + "Dragon Escape",
|
||||||
ChatColor.RESET + "Milk the Cow",
|
ChatColor.RESET + "Milk the Cow",
|
||||||
ChatColor.RESET + "A Barbarian's Life",
|
ChatColor.RESET + "Super Paintball",
|
||||||
ChatColor.RESET + "Turf Forts",
|
ChatColor.RESET + "Turf Forts",
|
||||||
ChatColor.RESET + "Death Tag",
|
ChatColor.RESET + "Death Tag",
|
||||||
ChatColor.RESET + "Bacon Brawl",
|
ChatColor.RESET + "Bacon Brawl",
|
||||||
|
@ -11,6 +11,7 @@ import mineplex.core.shop.page.ShopPageBase;
|
|||||||
import mineplex.core.common.CurrencyType;
|
import mineplex.core.common.CurrencyType;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.minecraft.game.classcombat.Class.ClientClass;
|
import mineplex.minecraft.game.classcombat.Class.ClientClass;
|
||||||
|
import mineplex.minecraft.game.classcombat.shop.page.ArmorPage;
|
||||||
import mineplex.minecraft.game.classcombat.shop.page.CustomBuildPage;
|
import mineplex.minecraft.game.classcombat.shop.page.CustomBuildPage;
|
||||||
|
|
||||||
public class ClassCombatShop extends ShopBase<ClassShopManager>
|
public class ClassCombatShop extends ShopBase<ClassShopManager>
|
||||||
@ -29,13 +30,13 @@ public class ClassCombatShop extends ShopBase<ClassShopManager>
|
|||||||
@Override
|
@Override
|
||||||
protected ShopPageBase<ClassShopManager, ClassCombatShop> BuildPagesFor(Player player)
|
protected ShopPageBase<ClassShopManager, ClassCombatShop> BuildPagesFor(Player player)
|
||||||
{
|
{
|
||||||
return new CustomBuildPage(Plugin, this, ClientManager, DonationManager, player);
|
return new ArmorPage(Plugin, this, ClientManager, DonationManager, player, Purchasing);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ShopPageBase<ClassShopManager, ? extends ShopBase<ClassShopManager>> GetOpeningPageForPlayer(Player player)
|
protected ShopPageBase<ClassShopManager, ? extends ShopBase<ClassShopManager>> GetOpeningPageForPlayer(Player player)
|
||||||
{
|
{
|
||||||
return new CustomBuildPage(Plugin, this, ClientManager, DonationManager, player);
|
return new ArmorPage(Plugin, this, ClientManager, DonationManager, player, Purchasing);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre7"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
|
||||||
|
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AFTER_CLEAN_TARGETS" value="ServerMonitor,"/>
|
||||||
|
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="ServerMonitor,"/>
|
||||||
|
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="ServerMonitor,"/>
|
||||||
|
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
|
||||||
|
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
|
||||||
|
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/>
|
||||||
|
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
|
||||||
|
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
|
||||||
|
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
|
||||||
|
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value=""/>
|
||||||
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${BUILD_FILES}/common.xml"/>
|
||||||
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/>
|
||||||
|
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
|
||||||
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/Mineplex.ServerMonitor}"/>
|
||||||
|
</launchConfiguration>
|
@ -1,6 +0,0 @@
|
|||||||
package mineplex.servermonitor;
|
|
||||||
|
|
||||||
public class DynamicMonitor
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,26 @@
|
|||||||
|
package mineplex.servermonitor;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class DynamicServerData
|
||||||
|
{
|
||||||
|
public String Name;
|
||||||
|
public String Address;
|
||||||
|
public int AvailableCPU = 32;
|
||||||
|
public int AvailableRAM = 26624;
|
||||||
|
|
||||||
|
public HashMap<String, Integer> ServerGroupCount = new HashMap<String, Integer>();
|
||||||
|
|
||||||
|
public void setServerGroupCount(ServerGroupData groupData, int count)
|
||||||
|
{
|
||||||
|
if (ServerGroupCount.containsKey(groupData.Name))
|
||||||
|
{
|
||||||
|
AvailableCPU += groupData.RequiredCPU * ServerGroupCount.get(groupData.Name);
|
||||||
|
AvailableRAM += groupData.RequiredRAM * ServerGroupCount.get(groupData.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
ServerGroupCount.put(groupData.Name, count);
|
||||||
|
AvailableCPU -= groupData.RequiredCPU * count;
|
||||||
|
AvailableRAM -= groupData.RequiredRAM * count;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package mineplex.servermonitor;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
public class DynamicServerSorter implements Comparator<DynamicServerData>
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public int compare(DynamicServerData first, DynamicServerData second)
|
||||||
|
{
|
||||||
|
if (second.AvailableRAM <= 1024)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (first.AvailableRAM <= 1024)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (first.AvailableRAM > second.AvailableRAM)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (second.AvailableRAM > first.AvailableRAM)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (first.AvailableCPU > second.AvailableCPU)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (second.AvailableCPU < first.AvailableCPU)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
@ -5,9 +5,54 @@ import java.util.List;
|
|||||||
|
|
||||||
public class GroupStatusData
|
public class GroupStatusData
|
||||||
{
|
{
|
||||||
public String Name;
|
private int _totalCount = 0;
|
||||||
|
private int _joinableCount = 0;
|
||||||
|
|
||||||
public int Players;
|
public int Players;
|
||||||
public int MaxPlayers;
|
public int MaxPlayers;
|
||||||
|
|
||||||
|
public List<ServerStatusData> EmptyServers = new ArrayList<ServerStatusData>();
|
||||||
public List<ServerStatusData> Servers = new ArrayList<ServerStatusData>();
|
public List<ServerStatusData> Servers = new ArrayList<ServerStatusData>();
|
||||||
|
|
||||||
|
public void addServer(ServerStatusData serverStatusData)
|
||||||
|
{
|
||||||
|
Players += serverStatusData.Players;
|
||||||
|
MaxPlayers += serverStatusData.MaxPlayers;
|
||||||
|
|
||||||
|
if (serverStatusData.Motd.contains("Starting") || serverStatusData.Motd.contains("Recruiting") || serverStatusData.Motd.contains("Waiting") || serverStatusData.Motd.contains("Cup") || serverStatusData.Motd.isEmpty() || serverStatusData.Motd.equals(""))
|
||||||
|
{
|
||||||
|
if (serverStatusData.Players < serverStatusData.MaxPlayers)
|
||||||
|
{
|
||||||
|
// Lobby joinable checking
|
||||||
|
if (serverStatusData.Motd.isEmpty() || serverStatusData.Motd.equals(""))
|
||||||
|
{
|
||||||
|
if (serverStatusData.Players / serverStatusData.MaxPlayers < .9)
|
||||||
|
_joinableCount++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_joinableCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_totalCount++;
|
||||||
|
|
||||||
|
if (serverStatusData.Empty)
|
||||||
|
{
|
||||||
|
EmptyServers.add(serverStatusData);
|
||||||
|
}
|
||||||
|
|
||||||
|
Servers.add(serverStatusData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTotalServers()
|
||||||
|
{
|
||||||
|
return _totalCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getJoinableCount()
|
||||||
|
{
|
||||||
|
return _joinableCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,10 @@ import java.sql.DriverManager;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Repository
|
public class Repository
|
||||||
@ -14,9 +17,14 @@ public class Repository
|
|||||||
private String _userName = "root";
|
private String _userName = "root";
|
||||||
private String _password = "y2D4atu3Pene2asw";
|
private String _password = "y2D4atu3Pene2asw";
|
||||||
|
|
||||||
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 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, lastTimeWithPlayers 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_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), US BOOLEAN NOT NULL DEFAULT 'true', PRIMARY KEY (id));";
|
||||||
|
private static String RETRIEVE_AVAILABLE_SERVERS = "SELECT DynamicServers.serverName, DynamicServers.address, ServerStatus.serverGroup, COUNT(*) As serverCount FROM DynamicServers LEFT JOIN ServerStatus ON ServerStatus.address LIKE CONCAT(DynamicServers.address, '%') WHERE DynamicServers.US = 'false' GROUP BY DynamicServers.address, ServerStatus.serverGroup;";
|
||||||
|
private static String RETRIEVE_SERVERGROUP_STATUSES = "SELECT ServerStatus.serverName, serverGroup, ServerStatus.address, players, maxPlayers, case when TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.lastTimeWithPlayers)) > 300 then 1 else 0 end as empty FROM ServerStatus INNER JOIN DynamicServers ON ServerStatus.address LIKE CONCAT(DynamicServers.address, '%') WHERE DynamicServers.US = 'false' AND TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) <= 10";
|
||||||
|
private static String RETRIEVE_SERVER_GROUP_DATA = "SELECT groupName, prefix, scriptName, requiredRam, cpuRequired, requiredTotal, requiredJoinable FROM ServerGroups;";
|
||||||
|
|
||||||
|
|
||||||
public void initialize()
|
public void initialize()
|
||||||
{
|
{
|
||||||
@ -63,6 +71,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<ServerStatusData> retrieveOldServerStatuses()
|
public List<ServerStatusData> retrieveOldServerStatuses()
|
||||||
@ -141,18 +193,18 @@ public class Repository
|
|||||||
return serverData;
|
return serverData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<GroupStatusData> retrieveGroupStatusData()
|
public HashMap<String, GroupStatusData> retrieveGroupStatusData()
|
||||||
{
|
{
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
PreparedStatement preparedStatement = null;
|
PreparedStatement preparedStatement = null;
|
||||||
List<GroupStatusData> groupData = new ArrayList<GroupStatusData>();
|
HashMap<String, GroupStatusData> groupData = new HashMap<String, GroupStatusData>();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||||
|
|
||||||
preparedStatement = connection.prepareStatement(RETRIEVE_SERVER_STATUSES);
|
preparedStatement = connection.prepareStatement(RETRIEVE_SERVERGROUP_STATUSES);
|
||||||
resultSet = preparedStatement.executeQuery();
|
resultSet = preparedStatement.executeQuery();
|
||||||
|
|
||||||
while (resultSet.next())
|
while (resultSet.next())
|
||||||
@ -160,15 +212,20 @@ public class Repository
|
|||||||
ServerStatusData serverStatusData = new ServerStatusData();
|
ServerStatusData serverStatusData = new ServerStatusData();
|
||||||
|
|
||||||
serverStatusData.Name = resultSet.getString(1);
|
serverStatusData.Name = resultSet.getString(1);
|
||||||
|
String serverGroup = resultSet.getString(2);
|
||||||
String addressPortString = resultSet.getString(2);
|
String addressPortString = resultSet.getString(3);
|
||||||
serverStatusData.Address = addressPortString.split(":")[0];
|
serverStatusData.Address = addressPortString.split(":")[0];
|
||||||
serverStatusData.Port = Integer.parseInt(addressPortString.split(":")[1]);
|
serverStatusData.Port = Integer.parseInt(addressPortString.split(":")[1]);
|
||||||
serverStatusData.Motd = resultSet.getString(3);
|
|
||||||
serverStatusData.Players = resultSet.getInt(4);
|
serverStatusData.Players = resultSet.getInt(4);
|
||||||
serverStatusData.MaxPlayers = resultSet.getInt(5);
|
serverStatusData.MaxPlayers = resultSet.getInt(5);
|
||||||
|
serverStatusData.Empty = resultSet.getBoolean(7);
|
||||||
|
|
||||||
serverData.add(serverStatusData);
|
if (!groupData.containsKey(serverGroup))
|
||||||
|
{
|
||||||
|
groupData.put(serverGroup, new GroupStatusData());
|
||||||
|
}
|
||||||
|
|
||||||
|
groupData.get(serverGroup).addServer(serverStatusData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
@ -214,6 +271,177 @@ public class Repository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return serverData;
|
return groupData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<DynamicServerData> retrieveDynamicServers()
|
||||||
|
{
|
||||||
|
Connection connection = null;
|
||||||
|
ResultSet resultSet = null;
|
||||||
|
PreparedStatement preparedStatement = null;
|
||||||
|
HashMap<String, DynamicServerData> serverMap = new HashMap<String, DynamicServerData>();
|
||||||
|
HashMap<String, ServerGroupData> serverGroupMap = new HashMap<String, ServerGroupData>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||||
|
|
||||||
|
preparedStatement = connection.prepareStatement(RETRIEVE_SERVER_GROUP_DATA);
|
||||||
|
resultSet = preparedStatement.executeQuery();
|
||||||
|
|
||||||
|
while (resultSet.next())
|
||||||
|
{
|
||||||
|
ServerGroupData serverGroupData = new ServerGroupData();
|
||||||
|
|
||||||
|
serverGroupData.Name = resultSet.getString(1);
|
||||||
|
serverGroupData.Prefix = resultSet.getString(2);
|
||||||
|
serverGroupData.ScriptName = resultSet.getString(3);
|
||||||
|
serverGroupData.RequiredRAM = resultSet.getInt(4);
|
||||||
|
serverGroupData.RequiredCPU = resultSet.getInt(5);
|
||||||
|
serverGroupData.RequiredTotalServers = resultSet.getInt(6);
|
||||||
|
serverGroupData.RequiredJoinableServers = resultSet.getInt(7);
|
||||||
|
|
||||||
|
if (!serverGroupMap.containsKey(serverGroupData.Name))
|
||||||
|
serverGroupMap.put(serverGroupData.Name, serverGroupData);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
if (!serverMap.containsKey(dynamicServer.Name))
|
||||||
|
serverMap.put(dynamicServer.Name, dynamicServer);
|
||||||
|
|
||||||
|
String serverGroupName = resultSet.getString(3);
|
||||||
|
if (serverGroupMap.containsKey(serverGroupName))
|
||||||
|
serverMap.get(dynamicServer.Name).setServerGroupCount(serverGroupMap.get(serverGroupName), resultSet.getInt(4));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 serverMap.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<ServerGroupData> retrieveServerGroups()
|
||||||
|
{
|
||||||
|
Connection connection = null;
|
||||||
|
ResultSet resultSet = null;
|
||||||
|
PreparedStatement preparedStatement = null;
|
||||||
|
HashMap<String, ServerGroupData> serverGroupMap = new HashMap<String, ServerGroupData>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||||
|
|
||||||
|
preparedStatement = connection.prepareStatement(RETRIEVE_SERVER_GROUP_DATA);
|
||||||
|
resultSet = preparedStatement.executeQuery();
|
||||||
|
|
||||||
|
while (resultSet.next())
|
||||||
|
{
|
||||||
|
ServerGroupData serverGroupData = new ServerGroupData();
|
||||||
|
|
||||||
|
serverGroupData.Name = resultSet.getString(1);
|
||||||
|
serverGroupData.Prefix = resultSet.getString(2);
|
||||||
|
serverGroupData.ScriptName = resultSet.getString(3);
|
||||||
|
serverGroupData.RequiredRAM = resultSet.getInt(4);
|
||||||
|
serverGroupData.RequiredCPU = resultSet.getInt(5);
|
||||||
|
serverGroupData.RequiredTotalServers = resultSet.getInt(6);
|
||||||
|
serverGroupData.RequiredJoinableServers = resultSet.getInt(7);
|
||||||
|
|
||||||
|
if (!serverGroupMap.containsKey(serverGroupData.Name))
|
||||||
|
serverGroupMap.put(serverGroupData.Name, serverGroupData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 serverGroupMap.values();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
package mineplex.servermonitor;
|
||||||
|
|
||||||
|
public class ServerGroupData
|
||||||
|
{
|
||||||
|
public String Name;
|
||||||
|
public String Prefix;
|
||||||
|
public String ScriptName;
|
||||||
|
public int RequiredRAM;
|
||||||
|
public int RequiredCPU;
|
||||||
|
public int RequiredTotalServers;
|
||||||
|
public int RequiredJoinableServers;
|
||||||
|
}
|
@ -2,6 +2,13 @@ package mineplex.servermonitor;
|
|||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
|
||||||
public class ServerMonitor
|
public class ServerMonitor
|
||||||
{
|
{
|
||||||
@ -14,6 +21,7 @@ public class ServerMonitor
|
|||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if (_count % 20 == 0)
|
if (_count % 20 == 0)
|
||||||
{
|
{
|
||||||
for (ServerStatusData statusData : _repository.retrieveOldServerStatuses())
|
for (ServerStatusData statusData : _repository.retrieveOldServerStatuses())
|
||||||
@ -51,20 +59,46 @@ public class ServerMonitor
|
|||||||
System.out.println("Sent restart command to " + key + "");
|
System.out.println("Sent restart command to " + key + "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
if (_count % 10 == 0)
|
if (_count % 10 == 0)
|
||||||
{
|
{
|
||||||
HashMap<String, GroupStatusData>
|
List<DynamicServerData> dynamicServers = new ArrayList<DynamicServerData>(_repository.retrieveDynamicServers());
|
||||||
for (ServerStatusData statusData : _repository.retrieveGroupStatusData())
|
Collection<ServerGroupData> serverGroups = _repository.retrieveServerGroups();
|
||||||
{
|
HashMap<String, GroupStatusData> groupStatusList = _repository.retrieveGroupStatusData();
|
||||||
String key = statusData.Address + " " + statusData.Name;
|
|
||||||
|
|
||||||
String cmd = "/home/mineplex/restartServer.sh";
|
for (ServerGroupData serverGroup : serverGroups)
|
||||||
|
{
|
||||||
|
System.out.println("Checking Server Group " + serverGroup.Name);
|
||||||
|
|
||||||
|
if (!groupStatusList.containsKey(serverGroup.Name))
|
||||||
|
{
|
||||||
|
groupStatusList.put(serverGroup.Name, new GroupStatusData());
|
||||||
|
}
|
||||||
|
|
||||||
|
GroupStatusData groupStatus = groupStatusList.get(serverGroup.Name);
|
||||||
|
|
||||||
|
int serversToAdd = Math.max(serverGroup.RequiredTotalServers - groupStatus.getTotalServers(), serverGroup.RequiredJoinableServers - groupStatus.getJoinableCount());
|
||||||
|
int serversToKill = groupStatus.EmptyServers.size() - serverGroup.RequiredJoinableServers;
|
||||||
|
|
||||||
|
if (serversToAdd > 0)
|
||||||
|
{
|
||||||
|
while (serversToAdd > 0)
|
||||||
|
{
|
||||||
|
Collections.sort(dynamicServers, new DynamicServerSorter());
|
||||||
|
DynamicServerData bestServer = getBestDynamicServer(dynamicServers, serverGroup);
|
||||||
|
|
||||||
|
if (bestServer == null)
|
||||||
|
{
|
||||||
|
System.out.println("No best dynamic server available for group " + serverGroup.Name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
String cmd = "/home/mineplex/easyRemoteStartServer.sh";
|
||||||
Process process = null;
|
Process process = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
process = new ProcessBuilder(new String[] {"/bin/sh", "-x", cmd, statusData.Address, statusData.Name}).start();
|
process = new ProcessBuilder(new String[] {"/bin/sh", "-x", cmd, bestServer.Address, serverGroup.Prefix + "-" + (groupStatus.getTotalServers() + 1)}).start();
|
||||||
process.waitFor();
|
process.waitFor();
|
||||||
BufferedReader reader=new BufferedReader(new InputStreamReader(process.getInputStream()));
|
BufferedReader reader=new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||||
String line = reader.readLine();
|
String line = reader.readLine();
|
||||||
@ -87,7 +121,49 @@ public class ServerMonitor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Sent restart command to " + key + "");
|
bestServer.setServerGroupCount(serverGroup, bestServer.ServerGroupCount.containsKey(serverGroup.Name) ? (bestServer.ServerGroupCount.get(serverGroup.Name) + 1) : 1);
|
||||||
|
System.out.println("Sent start command to " + bestServer.Address + " for " + serverGroup.Prefix + "-" + (groupStatus.getTotalServers() + 1));
|
||||||
|
serversToAdd--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (serversToKill > 0)
|
||||||
|
{
|
||||||
|
while (serversToKill > 0)
|
||||||
|
{
|
||||||
|
String cmd = "/home/mineplex/easyRemoteKillServer.sh";
|
||||||
|
Process process = null;
|
||||||
|
|
||||||
|
ServerStatusData serverToKill = groupStatus.EmptyServers.get(0);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
process = new ProcessBuilder(new String[] {"/bin/sh", "-x", cmd, serverToKill.Address, serverToKill.Name}).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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (process != null)
|
||||||
|
{
|
||||||
|
process.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Sent start command to " + serverToKill.Address + " for " + serverToKill.Name);
|
||||||
|
serversToKill--;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,4 +180,32 @@ public class ServerMonitor
|
|||||||
_count %= 20;
|
_count %= 20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static DynamicServerData getBestDynamicServer(Collection<DynamicServerData> dynamicServers, ServerGroupData serverGroup)
|
||||||
|
{
|
||||||
|
DynamicServerData bestServer = null;
|
||||||
|
|
||||||
|
for (DynamicServerData serverData : dynamicServers)
|
||||||
|
{
|
||||||
|
System.out.println("Checking Dynamic Server " + serverData.Name);
|
||||||
|
|
||||||
|
if (serverData.AvailableRAM > serverGroup.RequiredRAM && serverData.AvailableCPU > serverGroup.RequiredCPU)
|
||||||
|
{
|
||||||
|
if (bestServer == null)
|
||||||
|
{
|
||||||
|
bestServer = serverData;
|
||||||
|
|
||||||
|
if (!serverData.ServerGroupCount.containsKey(serverGroup.Name))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (serverData.ServerGroupCount.containsKey(serverGroup.Name))
|
||||||
|
{
|
||||||
|
if (serverData.ServerGroupCount.get(serverGroup.Name) < bestServer.ServerGroupCount.get(serverGroup.Name))
|
||||||
|
bestServer = serverData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return bestServer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,4 +8,5 @@ public class ServerStatusData
|
|||||||
public int MaxPlayers;
|
public int MaxPlayers;
|
||||||
public String Address;
|
public String Address;
|
||||||
public int Port;
|
public int Port;
|
||||||
|
public boolean Empty = false;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
package mineplex.servermonitor;
|
||||||
|
|
||||||
|
public class ServerTargetData
|
||||||
|
{
|
||||||
|
public DynamicServerData DedicatedServer;
|
||||||
|
public int ServerNumber;
|
||||||
|
public String ServerGroup;
|
||||||
|
}
|
@ -479,7 +479,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
|
|
||||||
public ArrayList<String> LoadFiles(String gameName)
|
public ArrayList<String> LoadFiles(String gameName)
|
||||||
{
|
{
|
||||||
File folder = new File("../../update/maps" + File.separatorChar + gameName);
|
File folder = new File(".." + File.separatorChar + ".." + File.separatorChar + "update" + File.separatorChar + "maps" + File.separatorChar + gameName);
|
||||||
if (!folder.exists()) folder.mkdirs();
|
if (!folder.exists()) folder.mkdirs();
|
||||||
|
|
||||||
ArrayList<String> maps = new ArrayList<String>();
|
ArrayList<String> maps = new ArrayList<String>();
|
||||||
|
@ -64,8 +64,8 @@ public class Paintball extends TeamGame
|
|||||||
new Kit[]
|
new Kit[]
|
||||||
{
|
{
|
||||||
new KitRifle(manager),
|
new KitRifle(manager),
|
||||||
new KitMachineGun(manager),
|
|
||||||
new KitShotgun(manager),
|
new KitShotgun(manager),
|
||||||
|
new KitMachineGun(manager),
|
||||||
},
|
},
|
||||||
|
|
||||||
new String[]
|
new String[]
|
||||||
@ -203,11 +203,6 @@ public class Paintball extends TeamGame
|
|||||||
if (damagerTeam.equals(damageeTeam))
|
if (damagerTeam.equals(damageeTeam))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//Color
|
|
||||||
Color color = Color.RED;
|
|
||||||
if (event.GetProjectile() instanceof Snowball)
|
|
||||||
color = Color.AQUA;
|
|
||||||
|
|
||||||
//Count
|
//Count
|
||||||
int count = 1;
|
int count = 1;
|
||||||
if (GetKit(damager) != null)
|
if (GetKit(damager) != null)
|
||||||
|
@ -19,7 +19,7 @@ public class KitMachineGun extends Kit
|
|||||||
{
|
{
|
||||||
public KitMachineGun(ArcadeManager manager)
|
public KitMachineGun(ArcadeManager manager)
|
||||||
{
|
{
|
||||||
super(manager, "Machine Gun", KitAvailability.Free,
|
super(manager, "Machine Gun", KitAvailability.Blue,
|
||||||
|
|
||||||
new String[]
|
new String[]
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package nautilus.game.arcade.game.games.paintball.kits;
|
package nautilus.game.arcade.game.games.paintball.kits;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
@ -20,7 +19,7 @@ public class KitShotgun extends Kit
|
|||||||
{
|
{
|
||||||
public KitShotgun(ArcadeManager manager)
|
public KitShotgun(ArcadeManager manager)
|
||||||
{
|
{
|
||||||
super(manager, "Shotgun", KitAvailability.Free,
|
super(manager, "Shotgun", KitAvailability.Green,
|
||||||
|
|
||||||
new String[]
|
new String[]
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user