Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex
This commit is contained in:
commit
558f79fe34
@ -1,16 +0,0 @@
|
||||
package mineplex.core;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public interface INautilusPlugin
|
||||
{
|
||||
JavaPlugin GetPlugin();
|
||||
|
||||
String GetWebServerAddress();
|
||||
|
||||
Server GetRealServer();
|
||||
|
||||
PluginManager GetPluginManager();
|
||||
}
|
@ -5,6 +5,8 @@ import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.command.UpdateRank;
|
||||
import mineplex.core.account.event.AsyncClientLoadEvent;
|
||||
import mineplex.core.account.event.ClientUnloadEvent;
|
||||
import mineplex.core.account.event.ClientWebResponseEvent;
|
||||
@ -24,7 +26,6 @@ import org.bukkit.craftbukkit.libs.com.google.gson.Gson;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
@ -32,10 +33,8 @@ import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class CoreClientManager implements Listener
|
||||
public class CoreClientManager extends MiniPlugin
|
||||
{
|
||||
private static CoreClientManager _instance;
|
||||
|
||||
private JavaPlugin _plugin;
|
||||
private AccountRepository _repository;
|
||||
private NautHashMap<String, CoreClient> _clientList;
|
||||
@ -43,26 +42,25 @@ public class CoreClientManager implements Listener
|
||||
|
||||
private Object _clientLock = new Object();
|
||||
|
||||
protected CoreClientManager(JavaPlugin plugin, String webServer)
|
||||
public CoreClientManager(JavaPlugin plugin, String webServer)
|
||||
{
|
||||
_instance = this;
|
||||
super("Client Manager", plugin);
|
||||
|
||||
_plugin = plugin;
|
||||
_repository = new AccountRepository(webServer);
|
||||
_clientList = new NautHashMap<String, CoreClient>();
|
||||
_duplicateLoginGlitchPreventionList = new HashSet<String>();
|
||||
|
||||
_plugin.getServer().getPluginManager().registerEvents(this, _plugin);
|
||||
}
|
||||
|
||||
public static CoreClientManager Initialize(JavaPlugin plugin, String webServer)
|
||||
public AccountRepository getRepository()
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new CoreClientManager(plugin, webServer);
|
||||
}
|
||||
|
||||
return _instance;
|
||||
return _repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void AddCommands()
|
||||
{
|
||||
AddCommand(new UpdateRank(this));
|
||||
}
|
||||
|
||||
public CoreClient Add(String name)
|
||||
@ -155,7 +153,7 @@ public class CoreClientManager implements Listener
|
||||
|
||||
client.SetAccountId(token.AccountId);
|
||||
client.SetRank(Rank.valueOf(token.Rank));
|
||||
|
||||
|
||||
// JSON sql response
|
||||
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response));
|
||||
|
||||
@ -198,14 +196,14 @@ public class CoreClientManager implements Listener
|
||||
// Reserved Slot Check
|
||||
if (Bukkit.getOnlinePlayers().length >= Bukkit.getServer().getMaxPlayers())
|
||||
{
|
||||
if (client.GetRank().Has(event.getPlayer(), Rank.ULTRA, false))
|
||||
if (client.GetRank().Has(event.getPlayer(), Rank.HELPER, false))
|
||||
{
|
||||
event.allow();
|
||||
event.setResult(PlayerLoginEvent.Result.ALLOWED);
|
||||
return;
|
||||
}
|
||||
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server Full > Purchase Ultra at www.mineplex.com/shop");
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "This server is full and no longer accepts players.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,104 @@
|
||||
package mineplex.core.account.command;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
public class UpdateRank extends CommandBase<CoreClientManager>
|
||||
{
|
||||
public UpdateRank(CoreClientManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "updateRank");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(final Player caller, String[] args)
|
||||
{
|
||||
if (args == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), "/" + AliasUsed + " joeschmo MODERATOR"));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), "Player argument missing."));
|
||||
return;
|
||||
}
|
||||
|
||||
final String playerName = args[0];
|
||||
Rank tempRank = null;
|
||||
|
||||
try
|
||||
{
|
||||
tempRank = Rank.valueOf(args[1]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), ChatColor.RED + "" + ChatColor.BOLD + "Invalid rank!"));
|
||||
return;
|
||||
}
|
||||
|
||||
final Rank rank = tempRank;
|
||||
|
||||
if (rank == Rank.MODERATOR || rank == Rank.HELPER || rank == Rank.ALL || rank == Rank.MAPDEV)
|
||||
{
|
||||
Plugin.getRepository().MatchPlayerName(new Callback<List<String>>()
|
||||
{
|
||||
public void run(List<String> matches)
|
||||
{
|
||||
boolean matchedExact = false;
|
||||
|
||||
for (String match : matches)
|
||||
{
|
||||
if (match.equalsIgnoreCase(playerName))
|
||||
{
|
||||
matchedExact = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (matchedExact)
|
||||
{
|
||||
for (Iterator<String> matchIterator = matches.iterator(); matchIterator.hasNext();)
|
||||
{
|
||||
if (!matchIterator.next().equalsIgnoreCase(playerName))
|
||||
{
|
||||
matchIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UtilPlayer.searchOffline(matches, new Callback<String>()
|
||||
{
|
||||
public void run(final String target)
|
||||
{
|
||||
if (target == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Plugin.getRepository().SaveRank(new Callback<Rank>()
|
||||
{
|
||||
public void run(Rank rank)
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.GetName(), target + "'s rank has been updated to " + rank.Name + "!"));
|
||||
}
|
||||
}, target, rank, true);
|
||||
|
||||
}
|
||||
}, caller, playerName, true);
|
||||
}
|
||||
}, playerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,10 @@
|
||||
package mineplex.core.account.repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
|
||||
|
||||
import mineplex.core.account.repository.token.LoginToken;
|
||||
import mineplex.core.account.repository.token.RankUpdateToken;
|
||||
import mineplex.core.common.Rank;
|
||||
@ -37,4 +40,18 @@ public class AccountRepository
|
||||
|
||||
new AsyncJsonWebCall(_webAddress + "PlayerAccount/RankUpdate").Execute(Rank.class, callback, token);
|
||||
}
|
||||
|
||||
public void MatchPlayerName(final Callback<List<String>> callback, final String userName)
|
||||
{
|
||||
Thread asyncThread = new Thread(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
List<String> tokenList = new JsonWebCall(_webAddress + "PlayerAccount/GetMatches").Execute(new TypeToken<List<String>>(){}.getType(), userName);
|
||||
callback.run(tokenList);
|
||||
}
|
||||
});
|
||||
|
||||
asyncThread.start();
|
||||
}
|
||||
}
|
||||
|
@ -8,4 +8,5 @@ public class ClientToken
|
||||
public int EconomyBalance;
|
||||
|
||||
public AccountToken AccountToken;
|
||||
public long LastLogin;
|
||||
}
|
||||
|
@ -18,10 +18,10 @@ public class CommandCenter implements Listener
|
||||
protected CoreClientManager ClientManager;
|
||||
protected NautHashMap<String, ICommand> Commands;
|
||||
|
||||
public static void Initialize(JavaPlugin plugin, CoreClientManager clientManager)
|
||||
public static void Initialize(JavaPlugin plugin)
|
||||
{
|
||||
if (Instance == null)
|
||||
Instance = new CommandCenter(plugin, clientManager);
|
||||
Instance = new CommandCenter(plugin);
|
||||
}
|
||||
|
||||
public CoreClientManager GetClientManager()
|
||||
@ -29,14 +29,18 @@ public class CommandCenter implements Listener
|
||||
return ClientManager;
|
||||
}
|
||||
|
||||
private CommandCenter(JavaPlugin instance, CoreClientManager manager)
|
||||
private CommandCenter(JavaPlugin instance)
|
||||
{
|
||||
Plugin = instance;
|
||||
ClientManager = manager;
|
||||
Commands = new NautHashMap<String, ICommand>();
|
||||
Plugin.getServer().getPluginManager().registerEvents(this, Plugin);
|
||||
}
|
||||
|
||||
public void setClientManager(CoreClientManager clientManager)
|
||||
{
|
||||
ClientManager = clientManager;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
|
@ -0,0 +1,62 @@
|
||||
package mineplex.core.message.Commands;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.message.MessageManager;
|
||||
import mineplex.core.portal.Portal;
|
||||
|
||||
public class SendCommand extends CommandBase<MessageManager>
|
||||
{
|
||||
private Portal _portal;
|
||||
|
||||
public SendCommand(MessageManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "send");
|
||||
|
||||
_portal = new Portal(Plugin.GetPlugin());
|
||||
}
|
||||
|
||||
private void SendPlayerToServerWithMessage(Player player, String serverName)
|
||||
{
|
||||
_portal.AddTransferRecord(player.getName(), serverName);
|
||||
|
||||
player.playSound(player.getLocation(), Sound.CHEST_OPEN, 0.5f, 2f);
|
||||
|
||||
UtilPlayer.message(player, F.main(Plugin.GetName(), C.cYellow + "You are being sent to server: " + C.cGold + serverName + C.cYellow + "!"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player player, String[] args)
|
||||
{
|
||||
Rank playerRank = Plugin.GetClientManager().Get(player).GetRank();
|
||||
|
||||
if(args == null || args.length == 0)
|
||||
{
|
||||
UtilPlayer.message(player, F.main(Plugin.GetName(), C.cDPurple + "Your arguments are inappropriate for this command!"));
|
||||
return;
|
||||
}
|
||||
else if(args.length == 2)
|
||||
{
|
||||
if((playerRank == Rank.OWNER) || (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN))
|
||||
{
|
||||
Player sendPlayer = Plugin.GetClientManager().Get(args[0]).GetPlayer();
|
||||
SendPlayerToServerWithMessage(sendPlayer, args[1]);
|
||||
UtilPlayer.message(player, F.main(Plugin.GetName(), C.cYellow + "You have sent player: " + C.cGold + args[0] + " " + C.cYellow + "to server: " + C.cGold + args[1] + C.cYellow + "!"));
|
||||
return;
|
||||
}
|
||||
UtilPlayer.message(player, F.main(Plugin.GetName(), C.cDPurple + "Your arguments are not allowed for this command!"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(player, F.main(Plugin.GetName(), C.cDPurple + "Your arguments are inappropriate for this command!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package mineplex.core.message.Commands;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.message.MessageManager;
|
||||
import mineplex.core.portal.Portal;
|
||||
|
||||
public class ServerCommand extends CommandBase<MessageManager>
|
||||
{
|
||||
private Portal _portal;
|
||||
|
||||
public ServerCommand(MessageManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "server");
|
||||
|
||||
_portal = new Portal(Plugin.GetPlugin());
|
||||
}
|
||||
|
||||
private void SendPlayerToServerWithMessage(Player player, String serverName)
|
||||
{
|
||||
_portal.SendPlayerToServer(player, serverName);
|
||||
|
||||
player.playSound(player.getLocation(), Sound.CHEST_OPEN, 0.5f, 2f);
|
||||
|
||||
UtilPlayer.message(player, F.main(Plugin.GetName(), C.cYellow + "You have been sent to server: " + C.cGold + serverName + C.cYellow + "!"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player player, String[] args)
|
||||
{
|
||||
Rank playerRank = Plugin.GetClientManager().Get(player).GetRank();
|
||||
|
||||
if(args == null || args.length == 0)
|
||||
{
|
||||
UtilPlayer.message(player, F.main(Plugin.GetName(), C.cYellow + "You are currently on server: " + C.cGold + Plugin.GetPlugin().getConfig().getString("serverstatus.name")));
|
||||
return;
|
||||
}
|
||||
else if(args.length == 1)
|
||||
{
|
||||
String servUp = args[0].toUpperCase();
|
||||
if(!(servUp.contains("HERO") || servUp.contains("ULTRA") || servUp.contains("BETA")
|
||||
|| servUp.contains("STAFF") || servUp.contains("TEST")))
|
||||
{
|
||||
SendPlayerToServerWithMessage(player, args[0]);
|
||||
return;
|
||||
}
|
||||
if(servUp.contains("HERO") && ((playerRank == Rank.OWNER)
|
||||
|| (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN) || (playerRank == Rank.MODERATOR)
|
||||
|| (playerRank == Rank.HELPER) || (playerRank == Rank.MAPDEV) || (playerRank == Rank.YOUTUBE)
|
||||
|| (playerRank == Rank.ULTRA) || (playerRank == Rank.HERO)))
|
||||
{
|
||||
SendPlayerToServerWithMessage(player, args[0]);
|
||||
return;
|
||||
}
|
||||
if((servUp.contains("ULTRA") || servUp.contains("BETA")) && ((playerRank == Rank.OWNER)
|
||||
|| (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN) || (playerRank == Rank.MODERATOR)
|
||||
|| (playerRank == Rank.HELPER) || (playerRank == Rank.MAPDEV) || (playerRank == Rank.YOUTUBE)
|
||||
|| (playerRank == Rank.ULTRA)))
|
||||
{
|
||||
SendPlayerToServerWithMessage(player, args[0]);
|
||||
return;
|
||||
}
|
||||
if(servUp.contains("STAFF") && ((playerRank == Rank.OWNER)
|
||||
|| (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN) || (playerRank == Rank.MODERATOR)
|
||||
|| (playerRank == Rank.HELPER)))
|
||||
{
|
||||
SendPlayerToServerWithMessage(player, args[0]);
|
||||
return;
|
||||
}
|
||||
if(servUp.contains("TEST") && ((playerRank == Rank.OWNER)
|
||||
|| (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN) || (playerRank == Rank.MODERATOR)))
|
||||
{
|
||||
SendPlayerToServerWithMessage(player, args[0]);
|
||||
return;
|
||||
}
|
||||
UtilPlayer.message(player, F.main(Plugin.GetName(), C.cDPurple + "Your arguments are not allowed for this command!"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(player, F.main(Plugin.GetName(), C.cDPurple + "Your arguments are inappropriate for this command!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -86,6 +86,9 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
||||
|
||||
|
||||
AddCommand(new AdminCommand(this));
|
||||
|
||||
AddCommand(new ServerCommand(this));
|
||||
AddCommand(new SendCommand(this));
|
||||
}
|
||||
|
||||
public void Help(Player caller, String message)
|
||||
|
@ -0,0 +1,33 @@
|
||||
package mineplex.core.playerTracker;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.event.ClientUnloadEvent;
|
||||
|
||||
public class PlayerTracker extends MiniPlugin
|
||||
{
|
||||
private PlayerTrackerRepository _repository = null;
|
||||
|
||||
public PlayerTracker(JavaPlugin plugin, String serverName, boolean us)
|
||||
{
|
||||
super("Player Tracker", plugin);
|
||||
|
||||
_repository = new PlayerTrackerRepository();
|
||||
_repository.initialize(serverName, us);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void trackPlayer(PlayerJoinEvent event)
|
||||
{
|
||||
_repository.updatePlayerServer(event.getPlayer().getName());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void untrackPlayer(ClientUnloadEvent event)
|
||||
{
|
||||
_repository.deleteServerTransfers(event.GetName());
|
||||
}
|
||||
}
|
@ -0,0 +1,206 @@
|
||||
package mineplex.core.playerTracker;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class PlayerTrackerRepository
|
||||
{
|
||||
private static Object _connectionLock = new Object();
|
||||
|
||||
private String _connectionString = "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
private String _serverName = "";
|
||||
private boolean _us = true;
|
||||
|
||||
private static String CREATE_PLAYERMAP_TABLE = "CREATE TABLE IF NOT EXISTS playerMap (id INT NOT NULL AUTO_INCREMENT, playerName VARCHAR(256), serverName VARCHAR(256), us BOOLEAN NOT NULL DEFAULT 1, PRIMARY KEY (id), UNIQUE INDEX playerIndex (playerName));";
|
||||
private static String RETRIEVE_PLAYERMAP = "SELECT playerName, serverName FROM playerMap WHERE playerName = ? AND us = ?;";
|
||||
private static String INSERT_PLAYERMAP = "INSERT INTO playerMap (playerName, serverName, us) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE serverName = VALUES(serverName), us = VALUES(us);";
|
||||
private static String DELETE_PLAYERMAP = "DELETE FROM playerMap WHERE playerName = ? AND serverName = ? AND us = ?;";
|
||||
|
||||
private Connection _connection = null;
|
||||
|
||||
public void initialize(String serverName, boolean us)
|
||||
{
|
||||
_serverName = serverName;
|
||||
_us = us;
|
||||
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
// Create table
|
||||
preparedStatement = _connection.prepareStatement(CREATE_PLAYERMAP_TABLE);
|
||||
preparedStatement.execute();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String retrievePlayerServer(String playerName)
|
||||
{
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
String server = "N/A";
|
||||
|
||||
try
|
||||
{
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
if (_connection.isClosed())
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
|
||||
preparedStatement = _connection.prepareStatement(RETRIEVE_PLAYERMAP);
|
||||
preparedStatement.setString(1, playerName);
|
||||
preparedStatement.setBoolean(2, _us);
|
||||
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
server = resultSet.getString(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
public void deleteServerTransfers(String playerName)
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
if (_connection.isClosed())
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
|
||||
preparedStatement = _connection.prepareStatement(DELETE_PLAYERMAP);
|
||||
preparedStatement.setString(1, playerName);
|
||||
preparedStatement.setString(2, _serverName);
|
||||
preparedStatement.setBoolean(3, _us);
|
||||
|
||||
preparedStatement.executeUpdate();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updatePlayerServer(String playerName)
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
if (_connection.isClosed())
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
|
||||
preparedStatement = _connection.prepareStatement(INSERT_PLAYERMAP);
|
||||
preparedStatement.setString(1, playerName);
|
||||
preparedStatement.setString(2, _serverName);
|
||||
preparedStatement.setBoolean(3, _us);
|
||||
|
||||
preparedStatement.executeUpdate();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
package mineplex.core.portal;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@ -11,22 +9,17 @@ import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class Portal extends MiniPlugin implements PluginMessageListener
|
||||
public class Portal extends MiniPlugin
|
||||
{
|
||||
private static Object _transferLock = new Object();
|
||||
|
||||
@ -36,18 +29,13 @@ public class Portal extends MiniPlugin implements PluginMessageListener
|
||||
private List<String> _transfers = new ArrayList<String>();
|
||||
private boolean _retrieve = true;
|
||||
|
||||
private CoreClientManager _clientier;
|
||||
private String serverName = "";
|
||||
|
||||
public Portal(JavaPlugin plugin)
|
||||
{
|
||||
super("Portal", plugin);
|
||||
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(GetPlugin(), "BungeeCord");
|
||||
Bukkit.getMessenger().registerIncomingPluginChannel(GetPlugin(), "BungeeCord", this);
|
||||
|
||||
_repository.initialize(plugin.getConfig().getBoolean("serverstatus.us"));
|
||||
_clientier = CoreClientManager.Initialize(plugin, plugin.getConfig().getString("webServer"));
|
||||
}
|
||||
|
||||
public void SendAllPlayers(String serverName)
|
||||
@ -98,39 +86,19 @@ public class Portal extends MiniPlugin implements PluginMessageListener
|
||||
}
|
||||
}, 20L);
|
||||
}
|
||||
|
||||
private void ProcessServerName(final Player player)
|
||||
{
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(b);
|
||||
|
||||
try
|
||||
{
|
||||
out.writeUTF("GetServer");
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Can never happen
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
out.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
player.sendPluginMessage(GetPlugin(), "BungeeCord", b.toByteArray());
|
||||
}
|
||||
|
||||
private void SendPlayerToServerWithMessage(Player player, String serverName)
|
||||
{
|
||||
SendPlayerToServer(player, serverName);
|
||||
player.sendMessage(ChatColor.YELLOW + "You have been sent to server: " + ChatColor.GOLD + serverName + ChatColor.YELLOW + "!");
|
||||
public void AddTransferRecord(final String playerName, final String serverName)
|
||||
{
|
||||
synchronized (_transferLock)
|
||||
{
|
||||
Bukkit.getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_repository.addServerTransfer(playerName, serverName);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -192,138 +160,4 @@ public class Portal extends MiniPlugin implements PluginMessageListener
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPreCommand(PlayerCommandPreprocessEvent e)
|
||||
{
|
||||
String[] baseArgs = e.getMessage().split(" ");
|
||||
String command = baseArgs[0];
|
||||
String[] args = new String[baseArgs.length - 1];
|
||||
for (int i = 0; i < args.length; i++)
|
||||
{
|
||||
args[i] = baseArgs[i + 1];
|
||||
}
|
||||
|
||||
Player player = e.getPlayer();
|
||||
Rank playerRank = _clientier.Get(player).GetRank();
|
||||
|
||||
if (command.equalsIgnoreCase("/server"))
|
||||
{
|
||||
e.setCancelled(true);
|
||||
|
||||
if(args.length == 0)
|
||||
{
|
||||
ProcessServerName(player);
|
||||
player.sendMessage(ChatColor.YELLOW + "You are currently on server: " + ChatColor.GOLD + serverName);
|
||||
return;
|
||||
}
|
||||
else if(args.length == 1)
|
||||
{
|
||||
String servUp = args[0].toUpperCase();
|
||||
if(!(servUp.contains("HERO") || servUp.contains("ULTRA") || servUp.contains("BETA")
|
||||
|| servUp.contains("STAFF") || servUp.contains("TEST")))
|
||||
{
|
||||
SendPlayerToServerWithMessage(player, args[0]);
|
||||
return;
|
||||
}
|
||||
if(servUp.contains("HERO") && ((playerRank == Rank.OWNER)
|
||||
|| (playerRank == Rank.MAPDEV) || (playerRank == Rank.DEVELOPER) || (playerRank == Rank.YOUTUBE)
|
||||
|| (playerRank == Rank.ADMIN) || (playerRank == Rank.MODERATOR) || (playerRank == Rank.HELPER)
|
||||
|| (playerRank == Rank.ULTRA) || (playerRank == Rank.HERO)))
|
||||
{
|
||||
SendPlayerToServerWithMessage(player, args[0]);
|
||||
return;
|
||||
}
|
||||
if((servUp.contains("ULTRA") || servUp.contains("BETA")) && ((playerRank == Rank.OWNER)
|
||||
|| (playerRank == Rank.MAPDEV) || (playerRank == Rank.DEVELOPER) || (playerRank == Rank.YOUTUBE)
|
||||
|| (playerRank == Rank.ADMIN) || (playerRank == Rank.MODERATOR) || (playerRank == Rank.HELPER)
|
||||
|| (playerRank == Rank.ULTRA)))
|
||||
{
|
||||
SendPlayerToServerWithMessage(player, args[0]);
|
||||
return;
|
||||
}
|
||||
if(servUp.contains("STAFF") && ((playerRank == Rank.OWNER)
|
||||
|| (playerRank == Rank.MAPDEV) || (playerRank == Rank.DEVELOPER) || (playerRank == Rank.YOUTUBE)
|
||||
|| (playerRank == Rank.ADMIN) || (playerRank == Rank.MODERATOR) || (playerRank == Rank.HELPER)))
|
||||
{
|
||||
SendPlayerToServerWithMessage(player, args[0]);
|
||||
return;
|
||||
}
|
||||
if(servUp.contains("TEST") && ((playerRank == Rank.OWNER)
|
||||
|| (playerRank == Rank.MAPDEV) || (playerRank == Rank.DEVELOPER) || (playerRank == Rank.YOUTUBE)
|
||||
|| (playerRank == Rank.ADMIN) || (playerRank == Rank.MODERATOR)))
|
||||
{
|
||||
SendPlayerToServerWithMessage(player, args[0]);
|
||||
return;
|
||||
}
|
||||
player.sendMessage(ChatColor.DARK_PURPLE + "Your arrrguments are not allowed for this command!");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendMessage(ChatColor.DARK_PURPLE + "Your arrrguments are inappropriate for this command!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (command.equalsIgnoreCase("/send"))
|
||||
{
|
||||
e.setCancelled(true);
|
||||
|
||||
if(args.length == 2)
|
||||
{
|
||||
if((playerRank == Rank.OWNER) || (playerRank == Rank.MAPDEV) || (playerRank == Rank.DEVELOPER)
|
||||
|| (playerRank == Rank.YOUTUBE) || (playerRank == Rank.ADMIN))
|
||||
{
|
||||
Player sendPlayer = _clientier.Get(args[0]).GetPlayer();
|
||||
SendPlayerToServerWithMessage(sendPlayer, args[1]);
|
||||
player.sendMessage(ChatColor.YELLOW + "You have sent player: " + ChatColor.GOLD + args[0] + " " + ChatColor.YELLOW + "to server: " + ChatColor.GOLD + args[1] + ChatColor.YELLOW + "!");
|
||||
return;
|
||||
}
|
||||
player.sendMessage(ChatColor.DARK_PURPLE + "Your arrrguments are not allowed for this command!");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendMessage(ChatColor.DARK_PURPLE + "Your arrrguments are inappropriate for this command!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] message)
|
||||
{
|
||||
if (!channel.equals("BungeeCord"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DataInputStream in = new DataInputStream(new ByteArrayInputStream(message));
|
||||
|
||||
try
|
||||
{
|
||||
String subchannel = in.readUTF();
|
||||
|
||||
if (subchannel.equals("GetServer"))
|
||||
{
|
||||
serverName = in.readUTF();
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Should never happen
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ public class PortalRepository
|
||||
private static String CREATE_TRANSFER_TABLE = "CREATE TABLE IF NOT EXISTS playerServerTransfer (id INT NOT NULL AUTO_INCREMENT, playerName VARCHAR(256), serverName VARCHAR(256), PRIMARY KEY (id));";
|
||||
private static String RETRIEVE_TRANSFER_RECORDS = "SELECT playerName, serverName FROM playerServerTransfer WHERE playerName IN ";
|
||||
private static String DELETE_TRANSFER_RECORDS = "DELETE FROM playerServerTransfer WHERE playerName = ?;";
|
||||
private static String ADD_TRANSFER_RECORD = "INSERT INTO playerServerTransfer (playerName,serverName) VALUES(?,?);";
|
||||
|
||||
private Connection _connection = null;
|
||||
|
||||
@ -172,4 +173,44 @@ public class PortalRepository
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addServerTransfer(String playerName, String serverName)
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
if (_connection.isClosed())
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
|
||||
preparedStatement = _connection.prepareStatement(ADD_TRANSFER_RECORD);
|
||||
preparedStatement.setString(1, playerName);
|
||||
preparedStatement.setString(2, serverName);
|
||||
|
||||
preparedStatement.executeUpdate();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,49 +58,6 @@ public class Punish extends MiniPlugin
|
||||
@EventHandler
|
||||
public void OnClientWebResponse(ClientWebResponseEvent event)
|
||||
{
|
||||
/*
|
||||
JsonReader reader = null;
|
||||
|
||||
try
|
||||
{
|
||||
while (reader.hasNext())
|
||||
{
|
||||
if (reader.nextName().equalsIgnoreCase("Punish"))
|
||||
{
|
||||
reader.beginObject();
|
||||
|
||||
// TODO Parse infractions/punishments here
|
||||
// PunishClient client = new PunishClient();
|
||||
// client.AddInfraction(token.Category, new Infraction(token.Reason, token.Admin, token.Time));
|
||||
// client.AddPunishment(token.Category, new Punishment(token.PunishmentSentence, token.Reason, token.Admin, token.Hours, token.Time));
|
||||
// _punishClients.put(event.GetClient().GetPlayerName(), client);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
reader.endObject();
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (reader != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
PunishClientToken token = new Gson().fromJson(event.GetResponse(), PunishClientToken.class);
|
||||
LoadClient(token);
|
||||
}
|
||||
@ -121,7 +78,7 @@ public class Punish extends MiniPlugin
|
||||
if (client.IsBanned())
|
||||
{
|
||||
Punishment punishment = client.GetPunishment(PunishmentSentence.Ban);
|
||||
String time = F.time(UtilTime.convertString((long)(punishment.GetHours() * 3600000), 0, TimeUnit.FIT));
|
||||
String time = F.time(UtilTime.convertString(punishment.GetRemaining(), 0, TimeUnit.FIT));
|
||||
|
||||
if (punishment.GetHours() == -1)
|
||||
time = C.cRed + "Permanent";
|
||||
@ -234,16 +191,20 @@ public class Punish extends MiniPlugin
|
||||
}
|
||||
}
|
||||
}
|
||||
}, playerName, category.toString(), sentence, reason, duration, caller == null ? "Mineplex Anti-Cheat" : caller.getName(), severity, System.currentTimeMillis());
|
||||
}, playerName, category.toString(), sentence, reason, duration, caller == null ? "Mineplex Anti-Cheat" : caller.getName(), severity);
|
||||
}
|
||||
|
||||
public void LoadClient(PunishClientToken token)
|
||||
{
|
||||
PunishClient client = new PunishClient();
|
||||
|
||||
long timeDifference = System.currentTimeMillis() - token.Time;
|
||||
|
||||
System.out.println("TimeDifference : " + timeDifference);
|
||||
|
||||
for (PunishmentToken punishment : token.Punishments)
|
||||
{
|
||||
client.AddPunishment(Category.valueOf(punishment.Category), new Punishment(punishment.PunishmentId, PunishmentSentence.valueOf(punishment.Sentence), Category.valueOf(punishment.Category), punishment.Reason, punishment.Admin, punishment.Duration, punishment.Severity, punishment.Time, punishment.Active, punishment.Removed, punishment.RemoveAdmin, punishment.RemoveReason));
|
||||
client.AddPunishment(Category.valueOf(punishment.Category), new Punishment(punishment.PunishmentId, PunishmentSentence.valueOf(punishment.Sentence), Category.valueOf(punishment.Category), punishment.Reason, punishment.Admin, punishment.Duration, punishment.Severity, punishment.Time + timeDifference, punishment.Active, punishment.Removed, punishment.RemoveAdmin, punishment.RemoveReason));
|
||||
}
|
||||
|
||||
_punishClients.put(token.Name.toLowerCase(), client);
|
||||
|
@ -20,7 +20,7 @@ public class PunishRepository
|
||||
_webAddress = webServerAddress;
|
||||
}
|
||||
|
||||
public void Punish(Callback<String> callback, String target, String category, PunishmentSentence punishment, String reason, double duration, String admin, int severity, long time)
|
||||
public void Punish(Callback<String> callback, String target, String category, PunishmentSentence punishment, String reason, double duration, String admin, int severity)
|
||||
{
|
||||
PunishToken token = new PunishToken();
|
||||
token.Target = target;
|
||||
@ -29,7 +29,6 @@ public class PunishRepository
|
||||
token.Reason = reason;
|
||||
token.Duration = duration;
|
||||
token.Admin = admin;
|
||||
token.Time = time;
|
||||
token.Severity = severity;
|
||||
|
||||
new AsyncJsonWebCall(_webAddress + "PlayerAccount/Punish").Execute(String.class, callback, token);
|
||||
|
@ -5,5 +5,6 @@ import java.util.List;
|
||||
public class PunishClientToken
|
||||
{
|
||||
public String Name;
|
||||
public long Time;
|
||||
public List<PunishmentToken> Punishments;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ public class ServerStatusManager extends MiniPlugin
|
||||
private LagMeter _lagMeter;
|
||||
|
||||
private String _name;
|
||||
private boolean _us;
|
||||
|
||||
private boolean _alternateSeconds;
|
||||
private boolean _enabled = true;
|
||||
@ -42,6 +43,7 @@ public class ServerStatusManager extends MiniPlugin
|
||||
String address = Bukkit.getServer().getIp().isEmpty() ? "localhost" : Bukkit.getServer().getIp();
|
||||
|
||||
_name = plugin.getConfig().getString("serverstatus.name");
|
||||
_us = plugin.getConfig().getBoolean("serverstatus.us");
|
||||
|
||||
try
|
||||
{
|
||||
@ -49,7 +51,7 @@ public class ServerStatusManager extends MiniPlugin
|
||||
plugin.getConfig().getString("serverstatus.connectionurl"),
|
||||
plugin.getConfig().getString("serverstatus.username"),
|
||||
plugin.getConfig().getString("serverstatus.password"),
|
||||
plugin.getConfig().getBoolean("serverstatus.us"),
|
||||
_us,
|
||||
_name,
|
||||
plugin.getConfig().getString("serverstatus.group"),
|
||||
address,
|
||||
@ -144,4 +146,9 @@ public class ServerStatusManager extends MiniPlugin
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public boolean getUs()
|
||||
{
|
||||
return _us;
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,13 @@ public class EnjinTranslator extends JavaPlugin
|
||||
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
|
||||
saveConfig();
|
||||
|
||||
//Core Modules
|
||||
CoreClientManager clientManager = CoreClientManager.Initialize(this, GetWebServerAddress());
|
||||
|
||||
//Static Modules
|
||||
CommandCenter.Initialize(this, clientManager);
|
||||
CommandCenter.Initialize(this);
|
||||
|
||||
//Core Modules
|
||||
CoreClientManager clientManager = new CoreClientManager(this, GetWebServerAddress());
|
||||
CommandCenter.Instance.setClientManager(clientManager);
|
||||
|
||||
DonationManager donationManager = new DonationManager(this, GetWebServerAddress());
|
||||
//Other Modules
|
||||
Punish punish = new Punish(this, GetWebServerAddress(), clientManager);
|
||||
|
@ -11,6 +11,7 @@
|
||||
<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=""/>
|
||||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="true"/>
|
||||
<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,clean"/>
|
||||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
|
||||
|
@ -1,6 +1,5 @@
|
||||
package mineplex.hub;
|
||||
|
||||
import mineplex.core.INautilusPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.antistack.AntiStack;
|
||||
@ -20,6 +19,7 @@ import mineplex.core.monitor.LagMeter;
|
||||
import mineplex.core.movement.Movement;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
import mineplex.core.playerTracker.PlayerTracker;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
@ -48,12 +48,10 @@ import mineplex.minecraft.game.core.condition.ConditionManager;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
import mineplex.minecraft.game.core.fire.Fire;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Hub extends JavaPlugin implements INautilusPlugin, IRelation
|
||||
public class Hub extends JavaPlugin implements IRelation
|
||||
{
|
||||
private String WEB_CONFIG = "webServer";
|
||||
|
||||
@ -61,39 +59,41 @@ public class Hub extends JavaPlugin implements INautilusPlugin, IRelation
|
||||
public void onEnable()
|
||||
{
|
||||
getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/");
|
||||
|
||||
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
|
||||
saveConfig();
|
||||
|
||||
String webServerAddress = getConfig().getString(WEB_CONFIG);
|
||||
|
||||
Logger.initialize(this);
|
||||
|
||||
//Core Modules
|
||||
CoreClientManager clientManager = CoreClientManager.Initialize(this, GetWebServerAddress());
|
||||
|
||||
//Static Modules
|
||||
CommandCenter.Initialize(this, clientManager);
|
||||
CommandCenter.Initialize(this);
|
||||
CoreClientManager clientManager = new CoreClientManager(this, webServerAddress);
|
||||
CommandCenter.Instance.setClientManager(clientManager);
|
||||
|
||||
ItemStackFactory.Initialize(this, false);
|
||||
Recharge.Initialize(this);
|
||||
Punish punish = new Punish(this, GetWebServerAddress(), clientManager);
|
||||
Portal portal = new Portal(this);
|
||||
Punish punish = new Punish(this, webServerAddress, clientManager);
|
||||
Portal portal = new Portal(this);
|
||||
AntiHack.Initialize(this, punish, portal);
|
||||
|
||||
DonationManager donationManager = new DonationManager(this, GetWebServerAddress());
|
||||
DonationManager donationManager = new DonationManager(this, webServerAddress);
|
||||
|
||||
//Other Modules
|
||||
PreferencesManager preferenceManager = new PreferencesManager(this, clientManager, donationManager);
|
||||
preferenceManager.GiveItem = true;
|
||||
new MessageManager(this, clientManager, preferenceManager);
|
||||
Creature creature = new Creature(this);
|
||||
Creature creature = new Creature(this);
|
||||
NpcManager npcManager = new NpcManager(this, creature);
|
||||
PetManager petManager = new PetManager(this, clientManager, donationManager, creature, GetWebServerAddress());
|
||||
PetManager petManager = new PetManager(this, clientManager, donationManager, creature, webServerAddress);
|
||||
new AntiStack(this);
|
||||
|
||||
//Main Modules
|
||||
PacketHandler packetHandler = new PacketHandler(this);
|
||||
PartyManager partyManager = new PartyManager(this, clientManager, preferenceManager);
|
||||
HubManager hubManager = new HubManager(this, new BlockRestore(this), clientManager, donationManager, new ConditionManager(this), new DisguiseManager(this, packetHandler), new TaskManager(this, GetWebServerAddress()), portal, partyManager, preferenceManager, petManager);
|
||||
HubManager hubManager = new HubManager(this, new BlockRestore(this), clientManager, donationManager, new ConditionManager(this), new DisguiseManager(this, packetHandler), new TaskManager(this, webServerAddress), portal, partyManager, preferenceManager, petManager);
|
||||
ServerStatusManager serverStatusManager = new ServerStatusManager(this, new LagMeter(this, clientManager));
|
||||
PlayerTracker tracker = new PlayerTracker(this, serverStatusManager.getCurrentServerName(), serverStatusManager.getUs());
|
||||
|
||||
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this), partyManager);
|
||||
|
||||
@ -112,9 +112,9 @@ public class Hub extends JavaPlugin implements INautilusPlugin, IRelation
|
||||
Teleport teleport = new Teleport(this, clientManager, new Spawn(this));
|
||||
Energy energy = new Energy(this);
|
||||
|
||||
ItemFactory itemFactory = new ItemFactory(this, blockRestore, conditionManager, damage, energy, fire, throwManager, GetWebServerAddress());
|
||||
SkillFactory skillManager = new SkillFactory(this, damage, this, combatManager, conditionManager, throwManager, blockRestore, fire, new Movement(this), teleport, energy, GetWebServerAddress());
|
||||
ClassManager classManager = new ClassManager(this, clientManager, donationManager, skillManager, itemFactory, GetWebServerAddress());
|
||||
ItemFactory itemFactory = new ItemFactory(this, blockRestore, conditionManager, damage, energy, fire, throwManager, webServerAddress);
|
||||
SkillFactory skillManager = new SkillFactory(this, damage, this, combatManager, conditionManager, throwManager, blockRestore, fire, new Movement(this), teleport, energy, webServerAddress);
|
||||
ClassManager classManager = new ClassManager(this, clientManager, donationManager, skillManager, itemFactory, webServerAddress);
|
||||
|
||||
ClassShopManager shopManager = new ClassShopManager(this, classManager, skillManager, itemFactory);
|
||||
|
||||
@ -133,32 +133,6 @@ public class Hub extends JavaPlugin implements INautilusPlugin, IRelation
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaPlugin GetPlugin()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetWebServerAddress()
|
||||
{
|
||||
String webServerAddress = getConfig().getString(WEB_CONFIG);
|
||||
|
||||
return webServerAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Server GetRealServer()
|
||||
{
|
||||
return getServer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginManager GetPluginManager()
|
||||
{
|
||||
return GetRealServer().getPluginManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean CanHurt(Player a, Player b)
|
||||
|
@ -44,7 +44,7 @@ public class GroupStatusData
|
||||
// Lobby joinable checking
|
||||
if (existingServer.Motd.isEmpty() || existingServer.Motd.equals(""))
|
||||
{
|
||||
if (existingServer.Players / existingServer.MaxPlayers < 10)
|
||||
if (serverStatusData.MaxPlayers - serverStatusData.Players > 15)
|
||||
_joinableCount--;
|
||||
}
|
||||
else
|
||||
@ -66,8 +66,10 @@ public class GroupStatusData
|
||||
// Lobby joinable checking
|
||||
if (serverStatusData.Motd.isEmpty() || serverStatusData.Motd.equals(""))
|
||||
{
|
||||
if (serverStatusData.Players / serverStatusData.MaxPlayers < 10)
|
||||
if (serverStatusData.MaxPlayers - serverStatusData.Players > 15)
|
||||
{
|
||||
_joinableCount++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -15,6 +15,7 @@ import java.util.Map.Entry;
|
||||
|
||||
public class ServerMonitor
|
||||
{
|
||||
private static boolean _us = true;
|
||||
private static Repository _repository = new Repository();
|
||||
private static int _count = 0;
|
||||
private static HashSet<ProcessRunner> _processes = new HashSet<ProcessRunner>();
|
||||
@ -22,9 +23,9 @@ public class ServerMonitor
|
||||
|
||||
public static void main (String args[])
|
||||
{
|
||||
boolean us = !new File("eu.dat").exists();
|
||||
_us = !new File("eu.dat").exists();
|
||||
|
||||
_repository.initialize(us);
|
||||
_repository.initialize(_us);
|
||||
HashMap<String, Entry<String, Long>> serverTracker = new HashMap<String, Entry<String, Long>>();
|
||||
|
||||
while (true)
|
||||
@ -34,6 +35,7 @@ public class ServerMonitor
|
||||
|
||||
for (ServerStatusData statusData : _repository.retrieveOldServerStatuses())
|
||||
{
|
||||
/*
|
||||
if (us)
|
||||
{
|
||||
if (!serverTracker.containsKey(statusData.Name))
|
||||
@ -48,9 +50,12 @@ public class ServerMonitor
|
||||
}
|
||||
}
|
||||
else
|
||||
killServer(statusData);
|
||||
*/
|
||||
|
||||
killServer(statusData);
|
||||
}
|
||||
|
||||
/*
|
||||
if (us)
|
||||
{
|
||||
// Remove successfully restarted US servers
|
||||
@ -65,6 +70,7 @@ public class ServerMonitor
|
||||
}
|
||||
else
|
||||
{
|
||||
*/
|
||||
List<DynamicServerData> dynamicServers = new ArrayList<DynamicServerData>(_repository.retrieveDynamicServers());
|
||||
|
||||
if (_count % 15 == 0)
|
||||
@ -165,7 +171,7 @@ public class ServerMonitor
|
||||
serversToKill--;
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
||||
int processWaits = 0;
|
||||
|
||||
|
@ -8,7 +8,6 @@ import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import mineplex.core.INautilusPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.antistack.AntiStack;
|
||||
@ -39,12 +38,10 @@ import mineplex.minecraft.game.core.combat.CombatManager;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
import nautilus.game.arcade.game.GameServerConfig;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Arcade extends JavaPlugin implements INautilusPlugin
|
||||
public class Arcade extends JavaPlugin
|
||||
{
|
||||
private String WEB_CONFIG = "webServer";
|
||||
|
||||
@ -64,28 +61,31 @@ public class Arcade extends JavaPlugin implements INautilusPlugin
|
||||
//Configs
|
||||
getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/");
|
||||
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
|
||||
saveConfig();
|
||||
saveConfig();
|
||||
|
||||
String webServerAddress = getConfig().getString(WEB_CONFIG);
|
||||
|
||||
Logger.initialize(this);
|
||||
|
||||
_clientManager = CoreClientManager.Initialize(this, GetWebServerAddress());
|
||||
|
||||
CommandCenter.Initialize(this, _clientManager);
|
||||
//Static Modules
|
||||
CommandCenter.Initialize(this);
|
||||
_clientManager = new CoreClientManager(this, webServerAddress);
|
||||
CommandCenter.Instance.setClientManager(_clientManager);
|
||||
|
||||
ItemStackFactory.Initialize(this, false);
|
||||
Recharge.Initialize(this);
|
||||
|
||||
_donationManager = new DonationManager(this, GetWebServerAddress());
|
||||
_donationManager = new DonationManager(this, webServerAddress);
|
||||
|
||||
PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager);
|
||||
new MessageManager(this, _clientManager, preferenceManager);
|
||||
|
||||
AntiStack antistack = new AntiStack(this);
|
||||
|
||||
Portal portal = new Portal(this);
|
||||
Creature creature = new Creature(this);
|
||||
Spawn spawn = new Spawn(this);
|
||||
Teleport teleport = new Teleport(this, _clientManager, spawn);
|
||||
new FileUpdater(this, new Portal(this));
|
||||
new FileUpdater(this, portal);
|
||||
ServerStatusManager serverStatusManager = new ServerStatusManager(this, new LagMeter(this, _clientManager));
|
||||
|
||||
PacketHandler packetHandler = new PacketHandler(this);
|
||||
@ -93,12 +93,11 @@ public class Arcade extends JavaPlugin implements INautilusPlugin
|
||||
|
||||
_damageManager = new DamageManager(this, new CombatManager(this), new NpcManager(this, creature), disguiseManager);
|
||||
|
||||
Portal portal = new Portal(this);
|
||||
Punish punish = new Punish(this, GetWebServerAddress(), _clientManager);
|
||||
Punish punish = new Punish(this, webServerAddress, _clientManager);
|
||||
AntiHack.Initialize(this, punish, portal);
|
||||
|
||||
//Arcade Manager
|
||||
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), antistack, portal, packetHandler, preferenceManager, GetWebServerAddress());
|
||||
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), antistack, portal, packetHandler, preferenceManager, webServerAddress);
|
||||
|
||||
new MemoryFix(this);
|
||||
|
||||
@ -250,30 +249,4 @@ public class Arcade extends JavaPlugin implements INautilusPlugin
|
||||
System.out.println("Deleted Old Game: " + file.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaPlugin GetPlugin()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetWebServerAddress()
|
||||
{
|
||||
String webServerAddress = getConfig().getString(WEB_CONFIG);
|
||||
|
||||
return webServerAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Server GetRealServer()
|
||||
{
|
||||
return getServer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginManager GetPluginManager()
|
||||
{
|
||||
return GetRealServer().getPluginManager();
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
[StringLength(40)]
|
||||
public string Name { get; set; }
|
||||
|
||||
[StringLength(100)]
|
||||
public string Uuid { get; set; }
|
||||
|
||||
public Rank Rank { get; set; }
|
||||
|
@ -20,6 +20,7 @@
|
||||
Name = account.Name;
|
||||
Uuid = account.Uuid;
|
||||
Rank = account.Rank.Name;
|
||||
Time = (long)TimeUtil.GetCurrentMilliseconds();
|
||||
|
||||
EconomyBalance = account.EconomyBalance;
|
||||
|
||||
@ -118,6 +119,8 @@
|
||||
|
||||
public string Rank { get; set; }
|
||||
|
||||
public long Time { get; set; }
|
||||
|
||||
public int EconomyBalance { get; set; }
|
||||
|
||||
public List<Punishment> Punishments { get; set; }
|
||||
|
@ -69,7 +69,7 @@
|
||||
{
|
||||
var account = repository.Where<Account>(x => x.Uuid == loginToken.Uuid).FirstOrDefault() ?? CreateAccount(loginToken, repository);
|
||||
account.LoadNavigationProperties(repository.Context);
|
||||
var edited = false;
|
||||
bool edited = false;
|
||||
|
||||
// Expire punishments
|
||||
if (account.Punishments != null)
|
||||
@ -97,9 +97,7 @@
|
||||
}
|
||||
|
||||
if (edited)
|
||||
{
|
||||
repository.CommitChanges();
|
||||
}
|
||||
|
||||
return account;
|
||||
}
|
||||
@ -268,7 +266,7 @@
|
||||
Admin = punish.Admin,
|
||||
Category = punish.Category,
|
||||
Sentence = punish.Sentence,
|
||||
Time = punish.Time,
|
||||
Time = (long)TimeUtil.GetCurrentMilliseconds(),
|
||||
Reason = punish.Reason,
|
||||
Duration = punish.Duration,
|
||||
Severity = punish.Severity,
|
||||
@ -308,7 +306,7 @@
|
||||
punishment.Active = false;
|
||||
punishment.Removed = true;
|
||||
punishment.RemoveAdmin = token.Admin;
|
||||
punishment.RemoveTime = DateTime.Now.Ticks;
|
||||
punishment.RemoveTime = (long)TimeUtil.GetCurrentMilliseconds();
|
||||
punishment.RemoveReason = token.Reason;
|
||||
|
||||
repository.Edit(punishment);
|
||||
@ -517,7 +515,7 @@
|
||||
|
||||
repository.CommitChanges();
|
||||
|
||||
return rank.ToString();
|
||||
return rank.Name.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Loading…
Reference in New Issue
Block a user