Merge branch 'master' of ssh://dev.mineplex.com:7999/min/mineplex
This commit is contained in:
commit
bfaa138526
Binary file not shown.
Binary file not shown.
@ -3,11 +3,18 @@ package mineplex.bungee;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import mineplex.bungee.lobbyBalancer.LobbyBalancer;
|
||||
import mineplex.bungee.motd.MotdManager;
|
||||
import mineplex.bungee.playerCount.PlayerCount;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.conf.YamlConfig;
|
||||
|
||||
public class Mineplexer extends Plugin
|
||||
{
|
||||
@ -15,40 +22,50 @@ public class Mineplexer extends Plugin
|
||||
public void onEnable()
|
||||
{
|
||||
//_dynamicServers = new GlobalServer(this);
|
||||
|
||||
/*
|
||||
try
|
||||
{
|
||||
Field config = YamlConfig.class.getDeclaredField("config");
|
||||
config.setAccessible(true);
|
||||
Map configMap = (Map)config.get(getProxy().getConfigurationAdapter());
|
||||
|
||||
System.out.println("Printing groups.");
|
||||
for (String playerName : ((HashMap<String, List<String>>)configMap.get("groups")).keySet())
|
||||
{
|
||||
System.out.println(playerName);
|
||||
|
||||
for (String rank : ((HashMap<String, List<String>>)configMap.get("groups")).get(playerName))
|
||||
{
|
||||
System.out.println("-" + rank);
|
||||
}
|
||||
}
|
||||
|
||||
((HashMap<String, List<String>>)configMap.get("groups")).clear();
|
||||
((HashMap<String, List<String>>)configMap.get("groups")).put("defek7", Arrays.asList("admin", "owner"));
|
||||
|
||||
config.set(getProxy().getConfigurationAdapter(), configMap);
|
||||
System.out.println("Printing groups.");
|
||||
for (String playerName : ((HashMap<String, List<String>>)configMap.get("groups")).keySet())
|
||||
{
|
||||
System.out.println(playerName);
|
||||
|
||||
for (String rank : ((HashMap<String, List<String>>)configMap.get("groups")).get(playerName))
|
||||
{
|
||||
System.out.println("-" + rank);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
*/
|
||||
|
||||
new MotdManager(this);
|
||||
new LobbyBalancer(this);
|
||||
new PlayerCount(this);
|
||||
new FileUpdater(this);
|
||||
|
||||
/*
|
||||
Socket socket = null;
|
||||
DataInputStream dataInputStream = null;
|
||||
DataOutputStream dataOutputStream = null;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
socket = new Socket();
|
||||
socket.setSoTimeout(3000);
|
||||
socket.setTcpNoDelay(true);
|
||||
socket.setTrafficClass(18);
|
||||
socket.connect(new InetSocketAddress("192.95.30.130", 4444));
|
||||
dataInputStream = new DataInputStream(socket.getInputStream());
|
||||
dataOutputStream = new DataOutputStream(socket.getOutputStream());
|
||||
|
||||
dataOutputStream.writeShort(71);
|
||||
writeString("defek7", dataOutputStream);
|
||||
|
||||
dataInputStream.read();
|
||||
System.out.println(dataInputStream.readByte());
|
||||
System.out.println(readString(dataInputStream, 16));
|
||||
System.out.println(readString(dataInputStream, 24));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
protected String readString(DataInputStream dataInputStream, int maxLength) throws IOException
|
||||
|
@ -7,7 +7,7 @@ import java.sql.SQLException;
|
||||
|
||||
public class GlobalServerRepository
|
||||
{
|
||||
private String _connectionString = "jdbc:mysql://sql.mineplex.com:3306/BungeeServers";
|
||||
private String _connectionString = "jdbc:mysql://db.mineplex.com:3306/BungeeServers";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
|
@ -22,7 +22,7 @@ public class LobbyBalancer implements Listener, Runnable
|
||||
|
||||
private int _bestServerIndex = 0;
|
||||
private int _playersSentToBestServer = 0;
|
||||
private int _maxPlayersToSendToBestServer = 0;
|
||||
private int _maxPlayersToSendToBestServer = 1;
|
||||
|
||||
public LobbyBalancer(Plugin plugin)
|
||||
{
|
||||
@ -109,6 +109,8 @@ public class LobbyBalancer implements Listener, Runnable
|
||||
Collections.sort(_sortedLobbies, new LobbySorter());
|
||||
|
||||
_bestServerIndex = 0;
|
||||
|
||||
if (_sortedLobbies.size() > 0)
|
||||
_maxPlayersToSendToBestServer = (_sortedLobbies.get(_bestServerIndex).MaxPlayers - _sortedLobbies.get(_bestServerIndex).Players) / 10;
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import java.util.List;
|
||||
public class LobbyBalancerRepository
|
||||
{
|
||||
private Connection _connection = null;
|
||||
private String _connectionString = "jdbc:mysql://sql.mineplex.com:3306/ServerStatus?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _connectionString = "jdbc:mysql://db.mineplex.com:3306/ServerStatus?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
private boolean _us;
|
||||
|
@ -9,7 +9,7 @@ import java.sql.SQLException;
|
||||
public class MotdRepository
|
||||
{
|
||||
private Connection _connection = null;
|
||||
private String _connectionString = "jdbc:mysql://sql.mineplex.com:3306/BungeeServers?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _connectionString = "jdbc:mysql://db.mineplex.com:3306/BungeeServers?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
|
@ -10,7 +10,7 @@ import java.sql.Statement;
|
||||
public class PlayerCountRepository
|
||||
{
|
||||
private Connection _connection = null;
|
||||
private String _connectionString = "jdbc:mysql://sql.mineplex.com:3306/BungeeServers?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _connectionString = "jdbc:mysql://db.mineplex.com:3306/BungeeServers?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
|
@ -8,7 +8,7 @@ import java.sql.SQLException;
|
||||
|
||||
public class PlayerTrackerRepository
|
||||
{
|
||||
private String _connectionString = "jdbc:mysql://sql.mineplex.com:3306/PlayerTracker";
|
||||
private String _connectionString = "jdbc:mysql://db.mineplex.com:3306/PlayerTracker";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
|
@ -19,6 +19,7 @@ import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.craftbukkit.libs.com.google.gson.Gson;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -138,6 +139,19 @@ public class CoreClientManager implements Listener
|
||||
|
||||
event.disallow(Result.KICK_OTHER, "Error retrieving information from web, please retry in a minute.");
|
||||
}
|
||||
|
||||
if (Bukkit.hasWhitelist() && !Get(event.getName()).GetRank().Has(Rank.MODERATOR))
|
||||
{
|
||||
for (OfflinePlayer player : Bukkit.getWhitelistedPlayers())
|
||||
{
|
||||
if (player.getName().equalsIgnoreCase(event.getName()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
event.disallow(Result.KICK_WHITELIST, "You are not whitelisted my friend.");
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadClient(CoreClient client, String ipAddress)
|
||||
|
@ -11,7 +11,7 @@ public class RetrieveClientInformationEvent extends Event
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private static Connection _connection;
|
||||
private String _connectionString = "jdbc:mysql://sql.mineplex.com:3306/Stats?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _connectionString = "jdbc:mysql://db.mineplex.com:3306/Stats?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
|
@ -14,7 +14,7 @@ public class AntiHackRepository
|
||||
private String _serverName;
|
||||
|
||||
private Connection _connection;
|
||||
private String _connectionString = "jdbc:mysql://sql.mineplex.com:3306/Mineplex";
|
||||
private String _connectionString = "jdbc:mysql://db.mineplex.com:3306/Mineplex";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
|
@ -0,0 +1,89 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import org.bukkit.entity.Horse;
|
||||
|
||||
public class DisguiseHorse extends DisguiseAnimal
|
||||
{
|
||||
public DisguiseHorse(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(entity);
|
||||
|
||||
DataWatcher.a(16, Integer.valueOf(0));
|
||||
DataWatcher.a(19, Byte.valueOf((byte) 0));
|
||||
DataWatcher.a(20, Integer.valueOf(0));
|
||||
DataWatcher.a(21, String.valueOf(""));
|
||||
DataWatcher.a(22, Integer.valueOf(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int GetEntityTypeId()
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
public void setType(Horse.Variant horseType)
|
||||
{
|
||||
DataWatcher.watch(19, Byte.valueOf((byte) horseType.ordinal()));
|
||||
}
|
||||
|
||||
public Horse.Variant getType()
|
||||
{
|
||||
return Horse.Variant.values()[DataWatcher.getByte(19)];
|
||||
}
|
||||
|
||||
public void setVariant(Horse.Color color)
|
||||
{
|
||||
DataWatcher.watch(20, Integer.valueOf(color.ordinal()));
|
||||
}
|
||||
|
||||
public Horse.Color getVariant()
|
||||
{
|
||||
return Horse.Color.values()[DataWatcher.getInt(20)];
|
||||
}
|
||||
|
||||
private boolean w(int i)
|
||||
{
|
||||
return (DataWatcher.getInt(16) & i) != 0;
|
||||
}
|
||||
|
||||
public void kick()
|
||||
{
|
||||
b(32, false);
|
||||
b(64, true);
|
||||
}
|
||||
|
||||
public void stopKick()
|
||||
{
|
||||
b(64, false);
|
||||
}
|
||||
|
||||
private void b(int i, boolean flag)
|
||||
{
|
||||
int j = DataWatcher.getInt(16);
|
||||
|
||||
if (flag)
|
||||
DataWatcher.watch(16, Integer.valueOf(j | i));
|
||||
else
|
||||
DataWatcher.watch(16, Integer.valueOf(j & (i ^ 0xFFFFFFFF)));
|
||||
}
|
||||
|
||||
public String getOwnerName()
|
||||
{
|
||||
return DataWatcher.getString(21);
|
||||
}
|
||||
|
||||
public void setOwnerName(String s)
|
||||
{
|
||||
DataWatcher.watch(21, s);
|
||||
}
|
||||
|
||||
public int cf()
|
||||
{
|
||||
return DataWatcher.getInt(22);
|
||||
}
|
||||
|
||||
public void r(int i)
|
||||
{
|
||||
DataWatcher.watch(22, Integer.valueOf(i));
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@ public class Table
|
||||
{
|
||||
private static Connection _connection;
|
||||
|
||||
private String _connectionString = "jdbc:mysql://sql.mineplex.com:3306/Mineplex?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _connectionString = "jdbc:mysql://db.mineplex.com:3306/Mineplex?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
|
@ -68,7 +68,7 @@ public class ServerStatusManager extends MiniPlugin
|
||||
{
|
||||
try
|
||||
{
|
||||
GetPlugin().getConfig().addDefault("serverstatus.connectionurl", "jdbc:mysql://sql.mineplex.com:3306/ServerStatus");
|
||||
GetPlugin().getConfig().addDefault("serverstatus.connectionurl", "jdbc:mysql://db.mineplex.com:3306/ServerStatus");
|
||||
GetPlugin().getConfig().set("serverstatus.connectionurl", GetPlugin().getConfig().getString("serverstatus.connectionurl"));
|
||||
|
||||
GetPlugin().getConfig().addDefault("serverstatus.username", "root");
|
||||
|
@ -67,7 +67,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor
|
||||
String name = args[1];
|
||||
int amount = Integer.parseInt(args[2]);
|
||||
|
||||
_donationManager.RewardGems(null, name, "purchase", amount);
|
||||
_donationManager.RewardGems(null, "purchase", name, amount);
|
||||
System.out.println("enjin gem");
|
||||
}
|
||||
else if (args.length == 4 && args[0].equalsIgnoreCase("rank"))
|
||||
|
@ -15,7 +15,7 @@ public class EnjinTranslator extends JavaPlugin
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
getConfig().addDefault(WEB_CONFIG, "http://api.mineplex.com/");
|
||||
getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/");
|
||||
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
|
||||
saveConfig();
|
||||
|
||||
|
@ -56,7 +56,7 @@ public class Hub extends JavaPlugin implements INautilusPlugin, IRelation
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
getConfig().addDefault(WEB_CONFIG, "http://api.mineplex.com/");
|
||||
getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/");
|
||||
|
||||
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
|
||||
saveConfig();
|
||||
|
@ -21,10 +21,12 @@ import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
@ -35,6 +37,7 @@ import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.common.Rank;
|
||||
@ -282,6 +285,29 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void login(final PlayerLoginEvent event)
|
||||
{
|
||||
CoreClient client = _clientManager.Get(event.getPlayer().getName());
|
||||
|
||||
// Reserved Slot Check
|
||||
if (Bukkit.getOnlinePlayers().length >= Bukkit.getServer().getMaxPlayers())
|
||||
{
|
||||
if (!client.GetRank().Has(Rank.ULTRA))
|
||||
{
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_portal.SendPlayerToServer(event.getPlayer(), "Lobby");
|
||||
}
|
||||
});
|
||||
|
||||
event.allow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void PlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
|
@ -25,4 +25,9 @@ public class DynamicServerData
|
||||
AvailableCPU -= groupData.RequiredCPU * count;
|
||||
AvailableRAM -= groupData.RequiredRAM * count;
|
||||
}
|
||||
|
||||
public void printInfo()
|
||||
{
|
||||
System.out.println("DynamicServerData - Name:" + Name + " Address:" + Address + " RAM:" + AvailableRAM + " CPU:" + AvailableCPU);
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,10 @@ public class ProcessRunner extends Thread
|
||||
{
|
||||
private ProcessBuilder _processBuilder;
|
||||
private Process _process;
|
||||
private Runnable _runnable;
|
||||
private GenericRunnable<Boolean> _runnable;
|
||||
|
||||
boolean _done = false;
|
||||
Boolean _error = false;
|
||||
|
||||
ProcessRunner(String[] args)
|
||||
{
|
||||
@ -29,7 +30,9 @@ public class ProcessRunner extends Thread
|
||||
|
||||
while(line != null)
|
||||
{
|
||||
System.out.println(line);
|
||||
if (line.equals("255"))
|
||||
_error = true;
|
||||
|
||||
line=reader.readLine();
|
||||
}
|
||||
}
|
||||
@ -42,11 +45,11 @@ public class ProcessRunner extends Thread
|
||||
_done = true;
|
||||
|
||||
if (_runnable != null)
|
||||
_runnable.run();
|
||||
_runnable.run(_error);
|
||||
}
|
||||
}
|
||||
|
||||
public void start(Runnable runnable)
|
||||
public void start(GenericRunnable<Boolean> runnable)
|
||||
{
|
||||
super.start();
|
||||
|
||||
|
@ -12,16 +12,16 @@ import java.util.List;
|
||||
|
||||
public class Repository
|
||||
{
|
||||
private String _connectionString = "jdbc:mysql://localhost:3306/ServerStatus";
|
||||
private String _connectionString = "jdbc:mysql://db.mineplex.com:3306/ServerStatus";
|
||||
private String _userName = "root";
|
||||
private String _password = "y2D4atu3Pene2asw";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
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 ServerStatus.serverName, DynamicServers.address, ServerStatus.address, motd, players, maxPlayers FROM ServerStatus INNER JOIN DynamicServers ON ServerStatus.address LIKE CONCAT(DynamicServers.privateAddress, '%') WHERE DynamicServers.US = false AND TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) > 10;";
|
||||
private static String RETRIEVE_OLD_SERVER_STATUSES = "SELECT ServerStatus.serverName, DynamicServers.address, ServerStatus.address, motd, players, maxPlayers FROM ServerStatus INNER JOIN DynamicServers ON ServerStatus.address LIKE CONCAT(DynamicServers.privateAddress, '%') WHERE DynamicServers.US = true AND TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) > 15;";
|
||||
|
||||
private static String CREATE_DYNAMIC_TABLE = "CREATE TABLE IF NOT EXISTS DynamicServers (id INT NOT NULL AUTO_INCREMENT, serverName VARCHAR(256), address VARCHAR(256), privateAddress VARCHAR(256), US BOOLEAN NOT NULL DEFAULT 'true', PRIMARY KEY (id));";
|
||||
private static String RETRIEVE_AVAILABLE_SERVERS = "SELECT DynamicServers.serverName, DynamicServers.address, DynamicServers.privateAddress, DynamicServers.US, DynamicServers.availableCpu, DynamicServers.availableRam, ServerStatus.serverGroup, COUNT(*) As serverCount FROM DynamicServers LEFT JOIN ServerStatus ON ServerStatus.address LIKE CONCAT(DynamicServers.privateAddress, '%') WHERE DynamicServers.US = false GROUP BY DynamicServers.address, ServerStatus.serverGroup;";
|
||||
private static String RETRIEVE_SERVERGROUP_STATUSES = "SELECT ServerStatus.serverName, serverGroup, motd, DynamicServers.address, 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.privateAddress, '%') WHERE DynamicServers.US = false AND TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) <= 10";
|
||||
private static String RETRIEVE_AVAILABLE_SERVERS = "SELECT DynamicServers.serverName, DynamicServers.address, DynamicServers.privateAddress, DynamicServers.US, DynamicServers.availableCpu, DynamicServers.availableRam, ServerStatus.serverGroup, COUNT(*) As serverCount FROM DynamicServers LEFT JOIN ServerStatus ON ServerStatus.address LIKE CONCAT(DynamicServers.privateAddress, '%') WHERE DynamicServers.US = true GROUP BY DynamicServers.address, ServerStatus.serverGroup;";
|
||||
private static String RETRIEVE_SERVERGROUP_STATUSES = "SELECT ServerStatus.serverName, serverGroup, motd, DynamicServers.address, 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.privateAddress, '%') WHERE DynamicServers.US = true AND TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) <= 15";
|
||||
private static String RETRIEVE_SERVER_GROUP_DATA = "SELECT groupName, prefix, scriptName, requiredRam, cpuRequired, requiredTotal, requiredJoinable FROM ServerGroups;";
|
||||
private static String DELETE_SERVER_STATUS = "DELETE FROM ServerStatus WHERE address = ? AND serverName = ?;";
|
||||
|
||||
|
@ -9,4 +9,9 @@ public class ServerGroupData
|
||||
public int RequiredCPU;
|
||||
public int RequiredTotalServers;
|
||||
public int RequiredJoinableServers;
|
||||
|
||||
public void printInfo()
|
||||
{
|
||||
System.out.println("ServerGroupData - Name:" + Name + " Prefix:" + Prefix + " ScriptName:" + ScriptName + " RAM:" + RequiredRAM + " CPU:" + RequiredCPU + " ReqTotal:" + RequiredTotalServers + " ReqJoin:" + RequiredJoinableServers);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.servermonitor;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@ -13,6 +15,7 @@ public class ServerMonitor
|
||||
private static Repository _repository = new Repository();
|
||||
private static int _count = 0;
|
||||
private static HashSet<ProcessRunner> _processes = new HashSet<ProcessRunner>();
|
||||
private static HashMap<String, Boolean> _badServers = new HashMap<String, Boolean>();
|
||||
|
||||
public static void main (String args[])
|
||||
{
|
||||
@ -20,51 +23,6 @@ public class ServerMonitor
|
||||
|
||||
while (true)
|
||||
{
|
||||
while (_processes.size() > 0)
|
||||
{
|
||||
for (Iterator<ProcessRunner> iterator = _processes.iterator(); iterator.hasNext();)
|
||||
{
|
||||
ProcessRunner pr = iterator.next();
|
||||
|
||||
try
|
||||
{
|
||||
pr.join(100);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (pr.isDone())
|
||||
iterator.remove();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
System.out.println("Sleeping while processes run...");
|
||||
Thread.sleep(6000);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (_count >= 10)
|
||||
{
|
||||
System.out.println("Killing stale processes.");
|
||||
|
||||
for (Iterator<ProcessRunner> iterator = _processes.iterator(); iterator.hasNext();)
|
||||
{
|
||||
iterator.next().abort();
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
_count++;
|
||||
}
|
||||
|
||||
_count = 0;
|
||||
|
||||
for (ServerStatusData statusData : _repository.retrieveOldServerStatuses())
|
||||
{
|
||||
System.out.println("----Old Server Status----> " + statusData.Address + ", " + statusData.Name);
|
||||
@ -73,6 +31,31 @@ public class ServerMonitor
|
||||
}
|
||||
|
||||
List<DynamicServerData> dynamicServers = new ArrayList<DynamicServerData>(_repository.retrieveDynamicServers());
|
||||
|
||||
if (_count % 15 == 0)
|
||||
{
|
||||
_badServers.clear();
|
||||
|
||||
for (DynamicServerData serverData : dynamicServers)
|
||||
{
|
||||
if (isServerOffline(serverData))
|
||||
{
|
||||
System.out.println("------=[OFFLINE]=------=[" + serverData.Name + ":" + serverData.Address + "]=------=[OFFLINE]=------");
|
||||
_badServers.put(serverData.Name, true);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(_badServers.size() + " bad servers.");
|
||||
}
|
||||
|
||||
for (Iterator<DynamicServerData> iterator = dynamicServers.iterator(); iterator.hasNext();)
|
||||
{
|
||||
DynamicServerData serverData = iterator.next();
|
||||
|
||||
if (_badServers.containsKey(serverData.Name))
|
||||
iterator.remove();
|
||||
}
|
||||
|
||||
Collection<ServerGroupData> serverGroups = _repository.retrieveServerGroups();
|
||||
HashMap<String, GroupStatusData> groupStatusList = _repository.retrieveGroupStatusData();
|
||||
|
||||
@ -101,6 +84,25 @@ public class ServerMonitor
|
||||
}
|
||||
|
||||
System.out.println("[" + bestServer.Name + ":" + bestServer.Address + "] Adding " + serverGroup.Name + " Req Total: " + serverGroup.RequiredTotalServers + " Req Joinable: " + serverGroup.RequiredJoinableServers + " | Actual Total: " + groupStatus.getTotalServers() + " Actual Joinable: " + groupStatus.getJoinableCount());
|
||||
|
||||
/*
|
||||
// Kill if any previous attempts stack up
|
||||
ServerStatusData newServer = new ServerStatusData();
|
||||
newServer.Address = bestServer.Address;
|
||||
newServer.Name = serverGroup.Prefix + "-" + serverNum;
|
||||
killServer(newServer, false);
|
||||
|
||||
// Delay between kill and start so we don't kill the new process
|
||||
try
|
||||
{
|
||||
Thread.sleep(100);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
*/
|
||||
|
||||
startServer(bestServer, serverGroup, serverNum);
|
||||
|
||||
serversToAdd--;
|
||||
@ -114,6 +116,56 @@ public class ServerMonitor
|
||||
}
|
||||
}
|
||||
|
||||
int processWaits = 0;
|
||||
|
||||
while (_processes.size() > 0)
|
||||
{
|
||||
for (Iterator<ProcessRunner> iterator = _processes.iterator(); iterator.hasNext();)
|
||||
{
|
||||
ProcessRunner pr = iterator.next();
|
||||
|
||||
try
|
||||
{
|
||||
pr.join(100);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (pr.isDone())
|
||||
iterator.remove();
|
||||
}
|
||||
|
||||
if (_processes.size() > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
System.out.println("Sleeping while processes run...");
|
||||
Thread.sleep(6000);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (processWaits >= 10)
|
||||
{
|
||||
System.out.println("Killing stale processes.");
|
||||
|
||||
for (Iterator<ProcessRunner> iterator = _processes.iterator(); iterator.hasNext();)
|
||||
{
|
||||
iterator.next().abort();
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
processWaits++;
|
||||
}
|
||||
|
||||
processWaits = 0;
|
||||
|
||||
try
|
||||
{
|
||||
System.out.println("Natural sleep.");
|
||||
@ -123,9 +175,83 @@ public class ServerMonitor
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
_count++;
|
||||
}
|
||||
}
|
||||
|
||||
private static void killServer(final ServerStatusData serverToKill, final boolean announce)
|
||||
{
|
||||
String cmd = "/home/mineplex/easyRemoteKillServer.sh";
|
||||
|
||||
ProcessRunner pr = new ProcessRunner(new String[] {"/bin/sh", cmd, serverToKill.Address, serverToKill.Name});
|
||||
pr.start(new GenericRunnable<Boolean>()
|
||||
{
|
||||
public void run(Boolean error)
|
||||
{
|
||||
if (!error)
|
||||
_repository.removeServerRecord(serverToKill);
|
||||
|
||||
if (announce)
|
||||
{
|
||||
if (error)
|
||||
System.out.println("[" + serverToKill.Name + ":" + serverToKill.Address + "] Kill errored.");
|
||||
else
|
||||
System.out.println("Sent kill command to " + serverToKill.Address + " for " + serverToKill.Name + " completed");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
pr.join(500);
|
||||
}
|
||||
catch (InterruptedException e1)
|
||||
{
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
if (!pr.isDone())
|
||||
_processes.add(pr);
|
||||
}
|
||||
|
||||
private static boolean isServerOffline(DynamicServerData serverData)
|
||||
{
|
||||
boolean success = false;
|
||||
|
||||
Process process = null;
|
||||
String cmd = "/home/mineplex/isServerOnline.sh";
|
||||
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(new String[] {"/bin/sh", cmd, serverData.Address});
|
||||
|
||||
try
|
||||
{
|
||||
process = processBuilder.start();
|
||||
process.waitFor();
|
||||
|
||||
BufferedReader reader=new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
String line = reader.readLine();
|
||||
|
||||
while(line != null)
|
||||
{
|
||||
success = line.equals("Success");
|
||||
|
||||
line=reader.readLine();
|
||||
}
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
e1.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
process.destroy();
|
||||
}
|
||||
|
||||
return !success;
|
||||
}
|
||||
|
||||
private static DynamicServerData getBestDynamicServer(Collection<DynamicServerData> dynamicServers, ServerGroupData serverGroup)
|
||||
{
|
||||
DynamicServerData bestServer = null;
|
||||
@ -157,10 +283,13 @@ public class ServerMonitor
|
||||
String cmd = "/home/mineplex/restartServer.sh";
|
||||
|
||||
ProcessRunner pr = new ProcessRunner(new String[] {"/bin/sh", cmd, serverToKill.Address, serverToKill.Name});
|
||||
pr.start(new Runnable()
|
||||
pr.start(new GenericRunnable<Boolean>()
|
||||
{
|
||||
public void run()
|
||||
public void run(Boolean error)
|
||||
{
|
||||
if (error)
|
||||
System.out.println("Restart command to " + serverToKill.Address + " for " + serverToKill.Name + " failed");
|
||||
else
|
||||
System.out.println("Restart command to " + serverToKill.Address + " for " + serverToKill.Name + " completed");
|
||||
}
|
||||
});
|
||||
@ -180,30 +309,7 @@ public class ServerMonitor
|
||||
|
||||
private static void killServer(final ServerStatusData serverToKill)
|
||||
{
|
||||
String cmd = "/home/mineplex/easyRemoteKillServer.sh";
|
||||
|
||||
ProcessRunner pr = new ProcessRunner(new String[] {"/bin/sh", cmd, serverToKill.Address, serverToKill.Name});
|
||||
pr.start(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_repository.removeServerRecord(serverToKill);
|
||||
System.out.println("Sent kill command to " + serverToKill.Address + " for " + serverToKill.Name + " completed");
|
||||
}
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
pr.join(500);
|
||||
}
|
||||
catch (InterruptedException e1)
|
||||
{
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
if (!pr.isDone())
|
||||
_processes.add(pr);
|
||||
killServer(serverToKill, true);
|
||||
}
|
||||
|
||||
private static void startServer(final DynamicServerData serverSpace, final ServerGroupData serverGroup, final int serverNum)
|
||||
@ -211,12 +317,14 @@ public class ServerMonitor
|
||||
String cmd = "/home/mineplex/easyRemoteStartServer.sh";
|
||||
|
||||
ProcessRunner pr = new ProcessRunner(new String[] {"/bin/sh", cmd, serverSpace.Address, serverSpace.PrivateAddress, serverGroup.ScriptName, serverGroup.Prefix + "-" + serverNum, "1", serverSpace.US ? "us" : "eu"});
|
||||
pr.start(new Runnable()
|
||||
pr.start(new GenericRunnable<Boolean>()
|
||||
{
|
||||
public void run()
|
||||
public void run(Boolean error)
|
||||
{
|
||||
serverSpace.setServerGroupCount(serverGroup, serverSpace.ServerGroupCount.containsKey(serverGroup.Name) ? (serverSpace.ServerGroupCount.get(serverGroup.Name) + 1) : 1);
|
||||
System.out.println("Start command (" + serverSpace.Address + "," + serverGroup.ScriptName + "," + serverGroup.Prefix + "-" + serverNum + ", 1," + (serverSpace.US ? "us" : "eu") + ") completed");
|
||||
if (error)
|
||||
System.out.println("[" + serverSpace.Name + ":" + serverSpace.Address + "] Errored " + serverGroup.Name + "(" + serverGroup.Prefix + "-" + serverNum + ")");
|
||||
else
|
||||
System.out.println("[" + serverSpace.Name + ":" + serverSpace.Address + "] Added " + serverGroup.Name + "(" + serverGroup.Prefix + "-" + serverNum + ")");
|
||||
}
|
||||
});
|
||||
|
||||
@ -229,6 +337,7 @@ public class ServerMonitor
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
serverSpace.setServerGroupCount(serverGroup, serverSpace.ServerGroupCount.containsKey(serverGroup.Name) ? (serverSpace.ServerGroupCount.get(serverGroup.Name) + 1) : 1);
|
||||
|
||||
if (!pr.isDone())
|
||||
_processes.add(pr);
|
||||
|
@ -90,7 +90,7 @@ public class Arcade extends JavaPlugin implements INautilusPlugin, IPlugin
|
||||
DeleteFolders();
|
||||
|
||||
//Configs
|
||||
getConfig().addDefault(WEB_CONFIG, "http://api.mineplex.com/");
|
||||
getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/");
|
||||
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
|
||||
saveConfig();
|
||||
|
||||
|
@ -159,6 +159,8 @@ public abstract class Game implements Listener
|
||||
|
||||
public boolean RepairWeapons = true;
|
||||
|
||||
public boolean Autobalance = true;
|
||||
|
||||
public boolean AnnounceStay = true;
|
||||
public boolean AnnounceJoinQuit = true;
|
||||
public boolean AnnounceSilence = true;
|
||||
@ -802,7 +804,7 @@ public abstract class Game implements Listener
|
||||
|
||||
public boolean CanJoinTeam(GameTeam team)
|
||||
{
|
||||
return team.GetSize() < Math.max(1, UtilServer.getPlayers().length/GetTeamList().size());
|
||||
return Autobalance ? team.GetSize() < Math.max(1, UtilServer.getPlayers().length/GetTeamList().size()) : true;
|
||||
}
|
||||
|
||||
public GameTeam GetTeamPreference(Player player)
|
||||
|
@ -1,20 +1,136 @@
|
||||
package nautilus.game.arcade.game;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
|
||||
public abstract class TeamGame extends Game
|
||||
{
|
||||
private NautHashMap<String, Long> _rejoinTime = new NautHashMap<String, Long>();
|
||||
protected NautHashMap<String, GameTeam> RejoinTeam = new NautHashMap<String, GameTeam>();
|
||||
|
||||
public TeamGame(ArcadeManager manager, GameType gameType, Kit[] kits, String[] gameDesc)
|
||||
{
|
||||
super(manager, gameType, kits, gameDesc);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void PlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
if (!InProgress())
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
GameTeam team = GetTeam(player);
|
||||
if (team == null) return;
|
||||
|
||||
if (!team.IsAlive(player))
|
||||
return;
|
||||
|
||||
team.RemovePlayer(player);
|
||||
|
||||
if (player.isDead())
|
||||
return;
|
||||
|
||||
if (!QuitOut)
|
||||
{
|
||||
//Store
|
||||
_rejoinTime.put(player.getName(), System.currentTimeMillis());
|
||||
RejoinTeam.put(player.getName(), team);
|
||||
GetLocationStore().put(player.getName(), player.getLocation());
|
||||
|
||||
//Announcement
|
||||
Announce(team.GetColor() + C.Bold + player.getName() + " has disconnected! 3 minutes to reconnect.");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void PlayerLoginAllow(PlayerLoginEvent event)
|
||||
{
|
||||
if (!InProgress() || QuitOut)
|
||||
return;
|
||||
|
||||
//Rejoined
|
||||
GameTeam team = RejoinTeam.remove(event.getPlayer().getName());
|
||||
if (team != null && _rejoinTime.remove(event.getPlayer().getName()) != null)
|
||||
{
|
||||
team.AddPlayer(event.getPlayer());
|
||||
Announce(team.GetColor() + C.Bold + event.getPlayer().getName() + " has reconnected!");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
//Owner Bypass
|
||||
if (Manager.GetClients().Get(event.getPlayer()).GetRank().Has(Rank.OWNER))
|
||||
return;
|
||||
|
||||
//Disallow
|
||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ChatColor.YELLOW + "You cannot join this UHC.");
|
||||
*/
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void PlayerRejoinExpire(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC || QuitOut)
|
||||
return;
|
||||
|
||||
Iterator<String> rejoinIterator = _rejoinTime.keySet().iterator();
|
||||
|
||||
while (rejoinIterator.hasNext())
|
||||
{
|
||||
String name = rejoinIterator.next();
|
||||
|
||||
if (!UtilTime.elapsed(_rejoinTime.get(name), 180000))
|
||||
continue;
|
||||
|
||||
rejoinIterator.remove();
|
||||
|
||||
//Get Team (By Name)
|
||||
GameTeam team = RejoinTeam.remove(name);
|
||||
if (team != null)
|
||||
Announce(team.GetColor() + C.Bold + name + " did not reconnect in time!");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void RejoinCommand(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (!QuitOut && event.getPlayer().isOp() && event.getMessage().startsWith("/allowrejoin"))
|
||||
{
|
||||
String[] toks = event.getMessage().split(" ");
|
||||
|
||||
if (toks.length <= 1)
|
||||
{
|
||||
event.getPlayer().sendMessage("Missing Param!");
|
||||
}
|
||||
else
|
||||
{
|
||||
_rejoinTime.put(toks[1], System.currentTimeMillis());
|
||||
event.getPlayer().sendMessage("Allowed " + toks[1] + " to rejoin!");
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void EndCheck()
|
||||
{
|
||||
if (!IsLive())
|
||||
@ -26,6 +142,14 @@ public abstract class TeamGame extends Game
|
||||
if (team.GetPlayers(true).size() > 0)
|
||||
teamsAlive.add(team);
|
||||
|
||||
if (!QuitOut)
|
||||
{
|
||||
//Offline Player Team
|
||||
for (GameTeam team : RejoinTeam.values())
|
||||
teamsAlive.add(team);
|
||||
}
|
||||
|
||||
|
||||
if (teamsAlive.size() <= 1)
|
||||
{
|
||||
//Announce
|
||||
|
@ -5,6 +5,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -24,6 +25,7 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockFormEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.inventory.PrepareItemCraftEvent;
|
||||
@ -50,6 +52,7 @@ import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.events.PlayerDeathOutEvent;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.TeamGame;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.games.bridge.kits.*;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.ore.OreHider;
|
||||
@ -118,30 +121,30 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
_ore = new OreHider();
|
||||
|
||||
// Flags
|
||||
this.DamageSelf = true;
|
||||
DamageSelf = true;
|
||||
|
||||
this.ItemDrop = true;
|
||||
this.ItemPickup = true;
|
||||
ItemDrop = true;
|
||||
ItemPickup = true;
|
||||
|
||||
this.PrivateBlocks = true;
|
||||
this.BlockBreak = true;
|
||||
this.BlockPlace = true;
|
||||
PrivateBlocks = true;
|
||||
BlockBreak = true;
|
||||
BlockPlace = true;
|
||||
|
||||
this.InventoryOpen = true;
|
||||
InventoryOpen = true;
|
||||
|
||||
this.WorldTimeSet = 2000;
|
||||
WorldTimeSet = 2000;
|
||||
|
||||
this.WorldWaterDamage = 4;
|
||||
WorldWaterDamage = 4;
|
||||
|
||||
this.CompassEnabled = true;
|
||||
CompassEnabled = true;
|
||||
|
||||
this.DeathDropItems = true;
|
||||
DeathDropItems = true;
|
||||
|
||||
this.GemMultiplier = 2.5;
|
||||
GemMultiplier = 2.5;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void PlayerOut(PlayerDeathOutEvent event)
|
||||
public void PlayerOut(final PlayerDeathOutEvent event)
|
||||
{
|
||||
if (_bridgesDown)
|
||||
return;
|
||||
|
@ -14,6 +14,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.disguise.disguises.DisguiseCow;
|
||||
import mineplex.core.disguise.disguises.DisguiseHorse;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
@ -88,7 +89,8 @@ public class KitSkeletalHorse extends SmashKit
|
||||
player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS));
|
||||
|
||||
//Disguise
|
||||
DisguiseCow disguise = new DisguiseCow(player);
|
||||
DisguiseHorse disguise = new DisguiseHorse(player);
|
||||
disguise.setType(Variant.SKELETON_HORSE);
|
||||
disguise.SetName(C.cYellow + player.getName());
|
||||
disguise.SetCustomNameVisible(true);
|
||||
Manager.GetDisguise().disguise(disguise);
|
||||
|
@ -84,10 +84,6 @@ import nautilus.game.arcade.managers.GameLobbyManager;
|
||||
public class UHC extends TeamGame
|
||||
{
|
||||
private NautHashMap<String, Long> _deathTime = new NautHashMap<String, Long>();
|
||||
|
||||
private NautHashMap<String, Long> _rejoinTime = new NautHashMap<String, Long>();
|
||||
private NautHashMap<String, GameTeam> _rejoinTeam = new NautHashMap<String, GameTeam>();
|
||||
|
||||
private NautHashMap<String, Long> _combatTime = new NautHashMap<String, Long>();
|
||||
|
||||
private int _borders = 1000;
|
||||
@ -577,6 +573,7 @@ public class UHC extends TeamGame
|
||||
event.setLeaveMessage(null);
|
||||
}
|
||||
|
||||
/*
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void PlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
@ -590,11 +587,10 @@ public class UHC extends TeamGame
|
||||
|
||||
team.RemovePlayer(player);
|
||||
|
||||
|
||||
if (player.isDead())
|
||||
return;
|
||||
|
||||
/* XXX
|
||||
XXX
|
||||
if (true)
|
||||
{
|
||||
//Announcement
|
||||
@ -603,7 +599,6 @@ public class UHC extends TeamGame
|
||||
player.damage(5000);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
if (_combatTime.containsKey(player.getName()) && !UtilTime.elapsed(_combatTime.get(player.getName()), 15000))
|
||||
{
|
||||
@ -613,15 +608,8 @@ public class UHC extends TeamGame
|
||||
player.damage(5000);
|
||||
return;
|
||||
}
|
||||
|
||||
//Store
|
||||
_rejoinTime.put(player.getName(), System.currentTimeMillis());
|
||||
_rejoinTeam.put(player.getName(), team);
|
||||
GetLocationStore().put(player.getName(), player.getLocation());
|
||||
|
||||
//Announcement
|
||||
Announce(team.GetColor() + C.Bold + player.getName() + " has disconnected! 30 minutes to reconnect.");
|
||||
}
|
||||
*/
|
||||
|
||||
@EventHandler
|
||||
public void DamageRecord(EntityDamageEvent event)
|
||||
@ -723,56 +711,6 @@ public class UHC extends TeamGame
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void PlayerRejoinExpire(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
return;
|
||||
|
||||
Iterator<String> rejoinIterator = _rejoinTime.keySet().iterator();
|
||||
|
||||
while (rejoinIterator.hasNext())
|
||||
{
|
||||
String name = rejoinIterator.next();
|
||||
|
||||
if (!UtilTime.elapsed(_rejoinTime.get(name), 1800000))
|
||||
continue;
|
||||
|
||||
rejoinIterator.remove();
|
||||
|
||||
//Get Team (By Name)
|
||||
GameTeam team = _rejoinTeam.remove(name);
|
||||
if (team != null)
|
||||
Announce(team.GetColor() + C.Bold + name + " did not reconnect in time!");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void PlayerLoginAllow(PlayerLoginEvent event)
|
||||
{
|
||||
if (!InProgress())
|
||||
return;
|
||||
|
||||
//Rejoined
|
||||
GameTeam team = _rejoinTeam.remove(event.getPlayer().getName());
|
||||
if (team != null && _rejoinTime.remove(event.getPlayer().getName()) != null)
|
||||
{
|
||||
team.AddPlayer(event.getPlayer());
|
||||
Announce(team.GetColor() + C.Bold + event.getPlayer().getName() + " has reconnected!");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
//Owner Bypass
|
||||
if (Manager.GetClients().Get(event.getPlayer()).GetRank().Has(Rank.OWNER))
|
||||
return;
|
||||
|
||||
//Disallow
|
||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ChatColor.YELLOW + "You cannot join this UHC.");
|
||||
*/
|
||||
}
|
||||
|
||||
private void CraftRecipes()
|
||||
{
|
||||
ShapelessRecipe goldMelon = new ShapelessRecipe(new ItemStack(Material.SPECKLED_MELON, 1));
|
||||
@ -990,27 +928,6 @@ public class UHC extends TeamGame
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void RejoinCommand(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (event.getMessage().startsWith("/allowrejoin"))
|
||||
{
|
||||
String[] toks = event.getMessage().split(" ");
|
||||
|
||||
if (toks.length <= 1)
|
||||
{
|
||||
event.getPlayer().sendMessage("Missing Param!");
|
||||
}
|
||||
else
|
||||
{
|
||||
_rejoinTime.put(toks[1], System.currentTimeMillis());
|
||||
event.getPlayer().sendMessage("Allowed " + toks[1] + " to rejoin!");
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void clearCreeperExplode(EntityExplodeEvent event)
|
||||
{
|
||||
@ -1217,7 +1134,7 @@ public class UHC extends TeamGame
|
||||
teamsAlive.add(team);
|
||||
|
||||
//Offline Player Team
|
||||
for (GameTeam team : _rejoinTeam.values())
|
||||
for (GameTeam team : RejoinTeam.values())
|
||||
teamsAlive.add(team);
|
||||
|
||||
if (!_dragonMode && teamsAlive.size() == 1)
|
||||
|
@ -22,6 +22,7 @@ import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.disguise.disguises.DisguiseBase;
|
||||
import mineplex.core.disguise.disguises.DisguiseHorse;
|
||||
import mineplex.core.disguise.disguises.DisguisePig;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
@ -67,11 +68,12 @@ public class PerkHorseKick extends Perk
|
||||
return;
|
||||
|
||||
//Horse Animation
|
||||
//DisguiseBase horse = Manager.GetDisguise().getDisguise(player);
|
||||
//if (horse != null && horse instanceof DisguiseHorse)
|
||||
//{
|
||||
//((CraftHorse)player).getHandle().p(true); //XXX MAKE LEGS KICK AIR HERE
|
||||
//}
|
||||
DisguiseBase horse = Manager.GetDisguise().getDisguise(player);
|
||||
if (horse != null && horse instanceof DisguiseHorse)
|
||||
{
|
||||
((DisguiseHorse)horse).kick();
|
||||
Manager.GetDisguise().updateDisguise(horse);
|
||||
}
|
||||
|
||||
//Animation
|
||||
_active.put(player, System.currentTimeMillis());
|
||||
@ -158,11 +160,12 @@ public class PerkHorseKick extends Perk
|
||||
playerIterator.remove();
|
||||
|
||||
//Horse Animation
|
||||
//DisguiseBase horse = Manager.GetDisguise().getDisguise(player);
|
||||
//if (horse != null && horse instanceof DisguiseHorse)
|
||||
//{
|
||||
//((CraftHorse)player).getHandle().p(true); //XXX STOP KICKING AIR HERE
|
||||
//}
|
||||
DisguiseBase horse = Manager.GetDisguise().getDisguise(player);
|
||||
if (horse != null && horse instanceof DisguiseHorse)
|
||||
{
|
||||
((DisguiseHorse)horse).stopKick();
|
||||
Manager.GetDisguise().updateDisguise(horse);
|
||||
}
|
||||
|
||||
Manager.GetCondition().EndCondition(player, null, GetName());
|
||||
}
|
||||
|
@ -375,11 +375,13 @@ public class WorldData
|
||||
int x = event.GetX();
|
||||
int z = event.GetZ();
|
||||
|
||||
|
||||
if (x >= MinX >> 4 && x <= MaxX >> 4 && z >= MinZ >> 4 && z <= MaxZ >> 4)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,7 @@ import mineplex.minecraft.game.core.mechanics.PistonJump;
|
||||
import mineplex.minecraft.game.core.mechanics.Weapon;
|
||||
import nautilus.game.core.util.NullChunkGenerator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -83,7 +84,9 @@ public abstract class GamePlugin extends JavaPlugin implements IRelation
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
getConfig().addDefault(WEB_CONFIG, "http://api.mineplex.com/");
|
||||
try
|
||||
{
|
||||
getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/");
|
||||
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
|
||||
saveConfig();
|
||||
|
||||
@ -146,6 +149,19 @@ public abstract class GamePlugin extends JavaPlugin implements IRelation
|
||||
new ClassCombatPurchaseShop(shopManager, ClientManager, DonationManager, "Skill Shop");
|
||||
new ClassCombatCustomBuildShop(shopManager, ClientManager, DonationManager, "Class Setup");
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
System.out.println("Exception during startup. Restarting in 15 seconds.");
|
||||
|
||||
getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
Bukkit.shutdown();
|
||||
}
|
||||
}, 300L);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract String GetServerName();
|
||||
|
||||
|
@ -99,7 +99,6 @@ public class ArenaManager<ArenaType extends IArena> implements Listener, Runnabl
|
||||
String name = directory + _arenaCount;
|
||||
|
||||
new File(name).mkdir();
|
||||
new File(name + File.separator + "region").mkdir();
|
||||
|
||||
// TODO Queue/Optimize unzip - currently 50ms on production server.
|
||||
ZipUtil.UnzipToDirectory(key, name);
|
||||
|
@ -1088,7 +1088,7 @@ public abstract class GameEngine<GameType extends IGame<ArenaType, PlayerType>,
|
||||
GameType game = GetGameForPlayer(player);
|
||||
PlayerType gamePlayer = game.GetPlayer(player);
|
||||
|
||||
if (ActiveGames.contains(game) || GamesInSetup.contains(game))
|
||||
if (game.IsActive() || GamesInSetup.contains(game))
|
||||
{
|
||||
GamePlayerQuitEvent<GameType, PlayerType> customEvent = new GamePlayerQuitEvent<GameType, PlayerType>(game, gamePlayer);
|
||||
Plugin.getServer().getPluginManager().callEvent(customEvent);
|
||||
@ -1109,7 +1109,7 @@ public abstract class GameEngine<GameType extends IGame<ArenaType, PlayerType>,
|
||||
}
|
||||
}
|
||||
|
||||
if (!online)
|
||||
if (!online || Bukkit.getOnlinePlayers().length <= 1)
|
||||
Plugin.getServer().shutdown();
|
||||
}
|
||||
else
|
||||
|
@ -526,12 +526,18 @@ public abstract class TeamGameEngine<GameType extends ITeamGame<ArenaType, Playe
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onGameFinished(TeamGameFinishedEvent<GameType, PlayerTeamType, PlayerType> event)
|
||||
public void onGameFinished(final TeamGameFinishedEvent<GameType, PlayerTeamType, PlayerType> event)
|
||||
{
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Plugin, new GenericRunnable<GameType>(event.GetGame())
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
for (PlayerType player : event.GetGame().GetPlayers())
|
||||
{
|
||||
Portal.SendPlayerToServer(player.GetPlayer(), "Lobby");
|
||||
}
|
||||
}
|
||||
}, 100L);
|
||||
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Plugin, new GenericRunnable<GameType>(event.GetGame())
|
||||
{
|
||||
|
@ -33,6 +33,7 @@ public class DominateGameEngine extends TeamGameEngine<IDominateGame, IDominateS
|
||||
_notifier = notifier;
|
||||
new DominateStatsReporter(plugin, donationManager, webServerAddress);
|
||||
|
||||
MinQueuePlayersToStart = 4;
|
||||
TeamSize = 5;
|
||||
AddToActiveGame = true;
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public class MineKart extends JavaPlugin implements INautilusPlugin, Listener
|
||||
{
|
||||
ClearRaceFolders();
|
||||
|
||||
getConfig().addDefault(WEB_CONFIG, "http:/api.mineplex.com/");
|
||||
getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/");
|
||||
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
|
||||
saveConfig();
|
||||
|
||||
|
@ -61,6 +61,5 @@
|
||||
public List<CaptureThePigPlayerStats> CaptureThePigStats { get; set; }
|
||||
|
||||
public List<AccountTransaction> AccountTransactions { get; set; }
|
||||
public List<GemTransaction> GemTransactions { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,8 @@ namespace LOC.Website.Common.Contexts
|
||||
public DbSet<DominatePlayerStats> DominatePlayerStats { get; set; }
|
||||
public DbSet<CaptureThePigPlayerStats> CaptureThePigPlayerStats { get; set; }
|
||||
|
||||
public DbSet<GemTransaction> GemTransactions { get; set; }
|
||||
|
||||
public DbSet<MineKart> MineKarts { get; set; }
|
||||
|
||||
public DbSet<Clan> Clans { get; set; }
|
||||
|
@ -49,7 +49,7 @@
|
||||
{
|
||||
using (var repository = _repositoryFactory.CreateRepository())
|
||||
{
|
||||
return repository.GetAll<Account>().Where(c => c.Name.ToUpper().Contains(name.ToUpper())).Include(x => x.Rank).ToList();
|
||||
return repository.GetAll<Account>().Where(c => c.Name == name).Include(x => x.Rank).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@
|
||||
{
|
||||
using (var repository = _repositoryFactory.CreateRepository())
|
||||
{
|
||||
return repository.GetAll<Account>().Where(c => c.Name.ToUpper().Contains(name.ToUpper())).Select(y => y.Name).ToList();
|
||||
return repository.GetAll<Account>().Where(c => c.Name == name).Select(y => y.Name).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
@ -160,6 +160,8 @@
|
||||
|
||||
account.Gems += token.Amount;
|
||||
|
||||
if (!token.Source.Contains("Earned") && !token.Source.Contains("Tutorial") && !token.Source.Contains("Parkour"))
|
||||
{
|
||||
var gemTransaction = new GemTransaction
|
||||
{
|
||||
Source = token.Source,
|
||||
@ -167,10 +169,8 @@
|
||||
Amount = token.Amount
|
||||
};
|
||||
|
||||
if (account.GemTransactions == null)
|
||||
account.GemTransactions = new List<GemTransaction>();
|
||||
|
||||
account.GemTransactions.Add(gemTransaction);
|
||||
repository.Add<GemTransaction>(gemTransaction);
|
||||
}
|
||||
|
||||
repository.Edit(account);
|
||||
repository.CommitChanges();
|
||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Loading…
Reference in New Issue
Block a user