Merge branch 'master' of ssh://dev1.mineplex.com:7999/min/mineplex
Conflicts: Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java
This commit is contained in:
commit
8240101d60
@ -45,6 +45,6 @@ public class PlayerCount implements Listener, Runnable
|
||||
{
|
||||
net.md_5.bungee.api.ServerPing serverPing = event.getResponse();
|
||||
|
||||
event.setResponse(new net.md_5.bungee.api.ServerPing(serverPing.getVersion(), new Players(_totalMaxPlayers, _totalPlayers, null), serverPing.getDescription(), serverPing.getFavicon()));
|
||||
event.setResponse(new net.md_5.bungee.api.ServerPing(serverPing.getVersion(), new Players(_totalMaxPlayers, _totalPlayers, null), serverPing.getDescription(), serverPing.getFaviconObject()));
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +1,18 @@
|
||||
package mineplex.core.account;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.account.event.AsyncClientLoadEvent;
|
||||
import mineplex.core.account.event.ClientUnloadEvent;
|
||||
import mineplex.core.account.event.ClientWebResponseEvent;
|
||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
||||
//import mineplex.core.account.event.RetrieveClientInformationEvent;
|
||||
import mineplex.core.account.repository.AccountRepository;
|
||||
import mineplex.core.account.repository.token.ClientToken;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.logger.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -33,10 +28,6 @@ import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import sun.jdbc.odbc.ee.ConnectionPoolFactory;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
public class CoreClientManager implements Listener
|
||||
{
|
||||
private static CoreClientManager _instance;
|
||||
@ -129,14 +120,7 @@ public class CoreClientManager implements Listener
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
System.out.println("Error logging '" + event.getName() + "' in.");
|
||||
|
||||
System.out.println(exception.getMessage());
|
||||
|
||||
for (StackTraceElement element : exception.getStackTrace())
|
||||
{
|
||||
System.out.println(element);
|
||||
}
|
||||
Logger.Instance.log(exception);
|
||||
|
||||
event.disallow(Result.KICK_OTHER, "Error retrieving information from web, please retry in a minute.");
|
||||
}
|
||||
@ -174,8 +158,16 @@ public class CoreClientManager implements Listener
|
||||
// Load client in miniplugins
|
||||
Bukkit.getServer().getPluginManager().callEvent(new AsyncClientLoadEvent(token, client));
|
||||
|
||||
// Mysql
|
||||
// Bukkit.getServer().getPluginManager().callEvent(new RetrieveClientInformationEvent(client.GetPlayerName()));
|
||||
try
|
||||
{
|
||||
// Mysql
|
||||
Bukkit.getServer().getPluginManager().callEvent(new RetrieveClientInformationEvent(client.GetPlayerName(), uuid));
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Logger.Instance.log(exception);
|
||||
System.out.println("Error running RetrieveClientInformationEvent" + exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
|
@ -2,6 +2,7 @@ package mineplex.core.account.event;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@ -15,11 +16,13 @@ public class RetrieveClientInformationEvent extends Event
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
private String _clientName;
|
||||
private String _playerName;
|
||||
private UUID _uuid;
|
||||
|
||||
public RetrieveClientInformationEvent(String playerName)
|
||||
public RetrieveClientInformationEvent(String playerName, UUID uuid)
|
||||
{
|
||||
_clientName = playerName;
|
||||
_playerName = playerName;
|
||||
_uuid = uuid;
|
||||
|
||||
try
|
||||
{
|
||||
@ -47,8 +50,13 @@ public class RetrieveClientInformationEvent extends Event
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public String getClientName()
|
||||
public String getPlayerName()
|
||||
{
|
||||
return _playerName;
|
||||
}
|
||||
|
||||
public UUID getUniqueId()
|
||||
{
|
||||
return _clientName;
|
||||
return _uuid;
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,7 @@ import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.antihack.types.*;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
@ -22,6 +20,7 @@ import mineplex.core.punish.Punish;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -31,13 +30,15 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
||||
import org.bukkit.event.player.PlayerVelocityEvent;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class AntiHack extends MiniPlugin
|
||||
{
|
||||
private static Object _antiHackLock = new Object();
|
||||
|
||||
public static AntiHack Instance;
|
||||
|
||||
public CoreClientManager ClientManager;
|
||||
public Punish Punish;
|
||||
public Portal Portal;
|
||||
|
||||
@ -66,7 +67,7 @@ public class AntiHack extends MiniPlugin
|
||||
|
||||
public ArrayList<Detector> _detectors;
|
||||
|
||||
//private AntiHackRepository _repository;
|
||||
private AntiHackRepository _repository;
|
||||
|
||||
protected AntiHack(JavaPlugin plugin, Punish punish, Portal portal)
|
||||
{
|
||||
@ -75,8 +76,8 @@ public class AntiHack extends MiniPlugin
|
||||
Punish = punish;
|
||||
Portal = portal;
|
||||
|
||||
//_repository = new AntiHackRepository(plugin.getConfig().getString("serverstatus.name"));
|
||||
//_repository.initialize();
|
||||
_repository = new AntiHackRepository(plugin.getConfig().getString("serverstatus.name"));
|
||||
_repository.initialize();
|
||||
|
||||
_detectors = new ArrayList<Detector>();
|
||||
|
||||
@ -93,19 +94,28 @@ public class AntiHack extends MiniPlugin
|
||||
@EventHandler
|
||||
public void playerMove(PlayerMoveEvent event)
|
||||
{
|
||||
_lastMoveEvent.put(event.getPlayer(), System.currentTimeMillis());
|
||||
synchronized (_antiHackLock)
|
||||
{
|
||||
_lastMoveEvent.put(event.getPlayer(), System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerTeleport(PlayerTeleportEvent event)
|
||||
{
|
||||
_ignore.put(event.getPlayer(), System.currentTimeMillis() + 2000);
|
||||
synchronized (_antiHackLock)
|
||||
{
|
||||
_ignore.put(event.getPlayer(), System.currentTimeMillis() + 2000);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerVelocity(PlayerVelocityEvent event)
|
||||
{
|
||||
_velocityEvent.add(event.getPlayer());
|
||||
synchronized (_antiHackLock)
|
||||
{
|
||||
_velocityEvent.add(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -113,20 +123,23 @@ public class AntiHack extends MiniPlugin
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!_suspicion.containsKey(player))
|
||||
return;
|
||||
|
||||
//Remove all infractions within last 2 seconds.
|
||||
for (ArrayList<Long> offenseList : _suspicion.get(player).values())
|
||||
synchronized (_antiHackLock)
|
||||
{
|
||||
Iterator<Long> offenseIterator = offenseList.iterator();
|
||||
|
||||
while (offenseIterator.hasNext())
|
||||
if (!_suspicion.containsKey(player))
|
||||
return;
|
||||
|
||||
//Remove all infractions within last 2 seconds.
|
||||
for (ArrayList<Long> offenseList : _suspicion.get(player).values())
|
||||
{
|
||||
long time = offenseIterator.next();
|
||||
|
||||
if (!UtilTime.elapsed(time, FlightTriggerCancel))
|
||||
offenseIterator.remove();
|
||||
Iterator<Long> offenseIterator = offenseList.iterator();
|
||||
|
||||
while (offenseIterator.hasNext())
|
||||
{
|
||||
long time = offenseIterator.next();
|
||||
|
||||
if (!UtilTime.elapsed(time, FlightTriggerCancel))
|
||||
offenseIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -142,19 +155,22 @@ public class AntiHack extends MiniPlugin
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (_velocityEvent.remove(player))
|
||||
synchronized (_antiHackLock)
|
||||
{
|
||||
setIgnore(player, 2000);
|
||||
}
|
||||
|
||||
//Initial Move (or Lag) Ignore
|
||||
if (_lastMoveEvent.containsKey(player))
|
||||
{
|
||||
long timeBetweenPackets = System.currentTimeMillis() - _lastMoveEvent.get(player);
|
||||
|
||||
if (timeBetweenPackets > 500)
|
||||
if (_velocityEvent.remove(player))
|
||||
{
|
||||
setIgnore(player, 5000);
|
||||
setIgnore(player, 1500);
|
||||
}
|
||||
|
||||
//Initial Move (or Lag) Ignore
|
||||
if (_lastMoveEvent.containsKey(player))
|
||||
{
|
||||
long timeBetweenPackets = System.currentTimeMillis() - _lastMoveEvent.get(player);
|
||||
|
||||
if (timeBetweenPackets > 1000)
|
||||
{
|
||||
setIgnore(player, 1500);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -165,12 +181,15 @@ public class AntiHack extends MiniPlugin
|
||||
for (Detector detector : _detectors)
|
||||
detector.Reset(player);
|
||||
|
||||
//Already ignoring for a longer period
|
||||
if (_ignore.containsKey(player) && _ignore.get(player) > System.currentTimeMillis() + time)
|
||||
return;
|
||||
|
||||
//Add Ignore
|
||||
_ignore.put(player, System.currentTimeMillis() + time);
|
||||
synchronized (_antiHackLock)
|
||||
{
|
||||
//Already ignoring for a longer period
|
||||
if (_ignore.containsKey(player) && _ignore.get(player) > System.currentTimeMillis() + time)
|
||||
return;
|
||||
|
||||
//Add Ignore
|
||||
_ignore.put(player, System.currentTimeMillis() + time);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isValid(Player player, boolean groundValid)
|
||||
@ -193,15 +212,18 @@ public class AntiHack extends MiniPlugin
|
||||
|
||||
public void addSuspicion(Player player, String type)
|
||||
{
|
||||
//Add Offense
|
||||
if (!_suspicion.containsKey(player))
|
||||
_suspicion.put(player, new HashMap<String, ArrayList<Long>>());
|
||||
|
||||
if (!_suspicion.get(player).containsKey(type))
|
||||
_suspicion.get(player).put(type, new ArrayList<Long>());
|
||||
|
||||
_suspicion.get(player).get(type).add(System.currentTimeMillis());
|
||||
|
||||
synchronized (_antiHackLock)
|
||||
{
|
||||
//Add Offense
|
||||
if (!_suspicion.containsKey(player))
|
||||
_suspicion.put(player, new HashMap<String, ArrayList<Long>>());
|
||||
|
||||
if (!_suspicion.get(player).containsKey(type))
|
||||
_suspicion.get(player).put(type, new ArrayList<Long>());
|
||||
|
||||
_suspicion.get(player).get(type).add(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
for (Player admin : UtilServer.getPlayers())
|
||||
if (admin.isOp() && UtilGear.isMat(admin.getItemInHand(), Material.PAPER))
|
||||
UtilPlayer.message(admin, C.cRed + C.Bold + player.getName() + " suspected for " + type + ".");
|
||||
@ -216,27 +238,30 @@ public class AntiHack extends MiniPlugin
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
return;
|
||||
|
||||
for (Player player : _suspicion.keySet())
|
||||
synchronized (_antiHackLock)
|
||||
{
|
||||
if (!_offense.containsKey(player))
|
||||
_offense.put(player, new HashMap<String, ArrayList<Long>>());
|
||||
|
||||
for (String type : _suspicion.get(player).keySet())
|
||||
for (Player player : _suspicion.keySet())
|
||||
{
|
||||
if (!_offense.get(player).containsKey(type))
|
||||
_offense.get(player).put(type, new ArrayList<Long>());
|
||||
|
||||
Iterator<Long> offenseIterator = _suspicion.get(player).get(type).iterator();
|
||||
|
||||
while (offenseIterator.hasNext())
|
||||
if (!_offense.containsKey(player))
|
||||
_offense.put(player, new HashMap<String, ArrayList<Long>>());
|
||||
|
||||
for (String type : _suspicion.get(player).keySet())
|
||||
{
|
||||
long time = offenseIterator.next();
|
||||
|
||||
//Suspicion turns into Offense
|
||||
if (UtilTime.elapsed(time, FlightTriggerCancel))
|
||||
if (!_offense.get(player).containsKey(type))
|
||||
_offense.get(player).put(type, new ArrayList<Long>());
|
||||
|
||||
Iterator<Long> offenseIterator = _suspicion.get(player).get(type).iterator();
|
||||
|
||||
while (offenseIterator.hasNext())
|
||||
{
|
||||
offenseIterator.remove();
|
||||
_offense.get(player).get(type).add(time);
|
||||
long time = offenseIterator.next();
|
||||
|
||||
//Suspicion turns into Offense
|
||||
if (UtilTime.elapsed(time, FlightTriggerCancel))
|
||||
{
|
||||
offenseIterator.remove();
|
||||
_offense.get(player).get(type).add(time);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -249,41 +274,44 @@ public class AntiHack extends MiniPlugin
|
||||
if (event.getType() != UpdateType.SLOW)
|
||||
return;
|
||||
|
||||
for (Player player : _offense.keySet())
|
||||
synchronized (_antiHackLock)
|
||||
{
|
||||
String out = "";
|
||||
int total = 0;
|
||||
|
||||
for (String type : _offense.get(player).keySet())
|
||||
for (Player player : _offense.keySet())
|
||||
{
|
||||
//Remove Old Offenses
|
||||
Iterator<Long> offenseIterator = _suspicion.get(player).get(type).iterator();
|
||||
while (offenseIterator.hasNext())
|
||||
{
|
||||
long time = offenseIterator.next();
|
||||
|
||||
if (UtilTime.elapsed(time, 300000))
|
||||
offenseIterator.remove();
|
||||
}
|
||||
|
||||
//Count
|
||||
int count = _offense.get(player).get(type).size();
|
||||
total += count;
|
||||
|
||||
out += count + " " + type + ", ";
|
||||
}
|
||||
|
||||
if (out.length() > 0)
|
||||
out = out.substring(0, out.length() - 2);
|
||||
|
||||
String severity = "";
|
||||
if (total > 12) severity = "Extreme";
|
||||
else if (total > 8) severity = "High";
|
||||
else if (total > 4) severity = "Medium";
|
||||
else severity = "Low";
|
||||
String out = "";
|
||||
int total = 0;
|
||||
|
||||
//Send Report
|
||||
sendReport(player, out, severity);
|
||||
for (String type : _offense.get(player).keySet())
|
||||
{
|
||||
//Remove Old Offenses
|
||||
Iterator<Long> offenseIterator = _suspicion.get(player).get(type).iterator();
|
||||
while (offenseIterator.hasNext())
|
||||
{
|
||||
long time = offenseIterator.next();
|
||||
|
||||
if (UtilTime.elapsed(time, 300000))
|
||||
offenseIterator.remove();
|
||||
}
|
||||
|
||||
//Count
|
||||
int count = _offense.get(player).get(type).size();
|
||||
total += count;
|
||||
|
||||
out += count + " " + type + ", ";
|
||||
}
|
||||
|
||||
if (out.length() > 0)
|
||||
out = out.substring(0, out.length() - 2);
|
||||
|
||||
String severity = "";
|
||||
if (total > 6) severity = "Extreme";
|
||||
else if (total > 4) severity = "High";
|
||||
else if (total > 2) severity = "Medium";
|
||||
else severity = "Low";
|
||||
|
||||
//Send Report
|
||||
sendReport(player, out, severity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -291,37 +319,51 @@ public class AntiHack extends MiniPlugin
|
||||
{
|
||||
if (severity.equals("Extreme"))
|
||||
{
|
||||
if (ClientManager.Get(player).GetRank().Has(Rank.HELPER))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
player.kickPlayer(
|
||||
C.cGold + "Mineplex Anti-Cheat" + "\n" +
|
||||
C.cWhite + "You were kicked for suspicious movement." + "\n" +
|
||||
"\n" +
|
||||
C.cWhite + "This may have been caused by lag." + "\n" +
|
||||
C.cWhite + "Cheating will result in a " + C.cRed + "Permanent Ban" + C.cWhite + "."
|
||||
);
|
||||
|
||||
UtilServer.broadcast(F.main("MAC", player.getName() + " was kicked for suspicious movement."));
|
||||
}
|
||||
|
||||
|
||||
//_repository.saveOffense(player, report, severity);
|
||||
ServerListPingEvent event = new ServerListPingEvent(null, Bukkit.getServer().getMotd(), Bukkit.getServer().getOnlinePlayers().length, Bukkit.getServer().getMaxPlayers());
|
||||
GetPluginManager().callEvent(event);
|
||||
|
||||
String motd = event.getMotd();
|
||||
String game = "N/A";
|
||||
String map = "N/A";
|
||||
|
||||
String[] args = motd.split("\\|");
|
||||
|
||||
if (args.length > 0)
|
||||
motd = args[0];
|
||||
|
||||
if (args.length > 2)
|
||||
game = args[2];
|
||||
|
||||
if (args.length > 3)
|
||||
map = args[3];
|
||||
|
||||
_repository.saveOffense(player, motd, game, map, report);
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetAll(Player player)
|
||||
{
|
||||
_ignore.remove(player);
|
||||
_velocityEvent.remove(player);
|
||||
_lastMoveEvent.remove(player);
|
||||
|
||||
_offense.remove(player);
|
||||
_suspicion.remove(player);
|
||||
|
||||
for (Detector detector : _detectors)
|
||||
detector.Reset(player);
|
||||
synchronized (_antiHackLock)
|
||||
{
|
||||
_ignore.remove(player);
|
||||
_velocityEvent.remove(player);
|
||||
_lastMoveEvent.remove(player);
|
||||
|
||||
|
||||
_offense.remove(player);
|
||||
_suspicion.remove(player);
|
||||
|
||||
for (Detector detector : _detectors)
|
||||
detector.Reset(player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -354,19 +396,4 @@ public class AntiHack extends MiniPlugin
|
||||
{
|
||||
return _offense;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void antiFlyingLag(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (player.getGameMode() != GameMode.SURVIVAL)
|
||||
continue;
|
||||
|
||||
player.setFlying(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,9 @@ import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import mineplex.core.logger.Logger;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AntiHackRepository
|
||||
@ -12,12 +15,12 @@ public class AntiHackRepository
|
||||
private String _serverName;
|
||||
|
||||
private static Connection _connection;
|
||||
private String _connectionString = "jdbc:mysql://sqlstats.mineplex.com:3306/Mineplex";
|
||||
private String _connectionString = "jdbc:mysql://sqlstats.mineplex.com:3306/Mineplex?autoReconnect=true";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS AntiHack (id INT NOT NULL AUTO_INCREMENT, serverName VARCHAR(256) NOT NULL, hackType VARCHAR(256) NOT NULL, playerName VARCHAR(256) NOT NULL, hackCount INT, updated LONG, PRIMARY KEY (id), UNIQUE KEY serverName_hackType_playerName (serverName, hackType, playerName));";
|
||||
private static String UPDATE_PLAYER_OFFENSES = "REPLACE INTO AntiHack (serverName, playerName, hackType, hackCount, updated) VALUES (?, ?, ?, ?, now());";
|
||||
private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS AntiHack_Kick_Log (id INT NOT NULL AUTO_INCREMENT, updated LONG, playerName VARCHAR(256), motd VARCHAR(56), gameType VARCHAR(56), map VARCHAR(256), serverName VARCHAR(256), report VARCHAR(256), ping VARCHAR(25), PRIMARY KEY (id));";
|
||||
private static String UPDATE_PLAYER_OFFENSES = "INSERT INTO AntiHack_Kick_Log (updated, playerName, motd, gameType, map, serverName, report, ping) VALUES (now(), ?, ?, ?, ?, ?, ?, ?);";
|
||||
|
||||
public AntiHackRepository(String serverName)
|
||||
{
|
||||
@ -40,6 +43,7 @@ public class AntiHackRepository
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
Logger.Instance.log(exception);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -57,7 +61,7 @@ public class AntiHackRepository
|
||||
}
|
||||
}
|
||||
|
||||
public void saveOffense(final Player player, final String report, final String severity)
|
||||
public void saveOffense(final Player player, final String motd, final String game, final String map, final String report)
|
||||
{
|
||||
new Thread(new Runnable()
|
||||
{
|
||||
@ -71,17 +75,22 @@ public class AntiHackRepository
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(UPDATE_PLAYER_OFFENSES);
|
||||
|
||||
preparedStatement.setString(1, _serverName);
|
||||
preparedStatement.setString(2, player.getName());
|
||||
preparedStatement.setString(3, report);
|
||||
preparedStatement.setString(4, severity);
|
||||
|
||||
|
||||
preparedStatement.setString(1, player.getName());
|
||||
preparedStatement.setString(2, motd);
|
||||
preparedStatement.setString(3, game);
|
||||
preparedStatement.setString(4, map);
|
||||
preparedStatement.setString(5, _serverName);
|
||||
preparedStatement.setString(6, report);
|
||||
preparedStatement.setString(7, ((CraftPlayer)player).getHandle().ping + "ms");
|
||||
|
||||
preparedStatement.execute();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
Logger.Instance.log(exception);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -1,18 +1,30 @@
|
||||
package mineplex.core.chat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
//import mineplex.core.account.event.RetrieveClientInformationEvent;
|
||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
||||
import mineplex.core.chat.command.BroadcastCommand;
|
||||
import mineplex.core.chat.command.FilterChatCommand;
|
||||
import mineplex.core.chat.command.SilenceCommand;
|
||||
import mineplex.core.chat.repository.ChatRepository;
|
||||
//import mineplex.core.chat.repository.ChatRepository;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
@ -20,6 +32,10 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -27,71 +43,103 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
|
||||
public class Chat extends MiniClientPlugin<ChatClient>
|
||||
{
|
||||
private static Object _messageLock = new Object();
|
||||
private CoreClientManager _clientManager;
|
||||
private ChatRepository _repository;
|
||||
|
||||
//private List<ChatMessage> _messages = new ArrayList<ChatMessage>();
|
||||
|
||||
|
||||
private String _filterUrl = "https://mp9wbhy6.pottymouthfilter.com/v1/";
|
||||
private String _apiKey = "38SMwIOeymi8V3r2MVtJ";
|
||||
private String _authName = "";
|
||||
private String _serverName;
|
||||
|
||||
private long _silenced = 0;
|
||||
|
||||
|
||||
private NautHashMap<String, String> _playerLastMessage = new NautHashMap<String, String>();
|
||||
|
||||
|
||||
public Chat(JavaPlugin plugin, CoreClientManager clientManager, String serverName)
|
||||
{
|
||||
super("Chat", plugin);
|
||||
|
||||
|
||||
_clientManager = clientManager;
|
||||
//_repository = new ChatRepository(serverName, plugin.getConfig().getBoolean("serverstatus.us"));
|
||||
_serverName = serverName;
|
||||
setupConfigValues();
|
||||
|
||||
_repository = new ChatRepository(plugin.getConfig().getString("chat.connectionurl"));
|
||||
|
||||
try
|
||||
{
|
||||
trustCert();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupConfigValues()
|
||||
{
|
||||
try
|
||||
{
|
||||
GetPlugin().getConfig().addDefault("chat.connectionurl", "jdbc:mysql://db.mineplex.com:3306/Account");
|
||||
GetPlugin().getConfig().set("chat.connectionurl", GetPlugin().getConfig().getString("chat.connectionurl"));
|
||||
GetPlugin().saveConfig();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void AddCommands()
|
||||
public void AddCommands()
|
||||
{
|
||||
AddCommand(new SilenceCommand(this));
|
||||
AddCommand(new BroadcastCommand(this));
|
||||
AddCommand(new FilterChatCommand(this));
|
||||
}
|
||||
|
||||
/*
|
||||
@EventHandler
|
||||
public void retrieveClientInformation(RetrieveClientInformationEvent event)
|
||||
{
|
||||
_repository.loadClientInformation(event.getConnection());
|
||||
}
|
||||
*/
|
||||
* @EventHandler public void
|
||||
* retrieveClientInformation(RetrieveClientInformationEvent event) {
|
||||
* _repository.loadClientInformation(event.getConnection()); }
|
||||
*/
|
||||
public void Silence(long duration, boolean inform)
|
||||
{
|
||||
//Set Silenced
|
||||
// Set Silenced
|
||||
if (duration > 0)
|
||||
_silenced = System.currentTimeMillis() + duration;
|
||||
else
|
||||
_silenced = duration;
|
||||
|
||||
|
||||
if (!inform)
|
||||
return;
|
||||
|
||||
//Announce
|
||||
|
||||
// Announce
|
||||
if (duration == -1)
|
||||
UtilServer.broadcast(F.main("Chat", "Chat has been silenced for " + F.time("Permanent") + "."));
|
||||
else if (duration == 0)
|
||||
UtilServer.broadcast(F.main("Chat", "Chat is no longer silenced."));
|
||||
else
|
||||
UtilServer.broadcast(F.main("Chat", "Chat has been silenced for " + F.time(UtilTime.MakeStr(duration, 1)) + "."));
|
||||
UtilServer.broadcast(F.main("Chat", "Chat has been silenced for " + F.time(UtilTime.MakeStr(duration, 1))
|
||||
+ "."));
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void preventMe(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (event.getMessage().toLowerCase().startsWith("/me") || event.getMessage().toLowerCase().startsWith("/bukkit:me"))
|
||||
if (event.getMessage().toLowerCase().startsWith("/me")
|
||||
|| event.getMessage().toLowerCase().startsWith("/bukkit"))
|
||||
{
|
||||
event.getPlayer().sendMessage(F.main(GetName(), "No, you!"));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void lagTest(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
@ -101,51 +149,130 @@ public class Chat extends MiniClientPlugin<ChatClient>
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void SilenceUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
|
||||
SilenceEnd();
|
||||
}
|
||||
|
||||
|
||||
public void SilenceEnd()
|
||||
{
|
||||
if (_silenced <= 0)
|
||||
return;
|
||||
|
||||
|
||||
if (System.currentTimeMillis() > _silenced)
|
||||
Silence(0, true);
|
||||
}
|
||||
|
||||
|
||||
public boolean SilenceCheck(Player player)
|
||||
{
|
||||
SilenceEnd();
|
||||
|
||||
|
||||
if (_silenced == 0)
|
||||
return false;
|
||||
|
||||
|
||||
if (_clientManager.Get(player).GetRank().Has(player, Rank.MODERATOR, false))
|
||||
return false;
|
||||
|
||||
|
||||
if (_silenced == -1)
|
||||
UtilPlayer.message(player, F.main(GetName(), "Chat is silenced permanently."));
|
||||
else
|
||||
UtilPlayer.message(player, F.main(GetName(), "Chat is silenced for " + F.time(UtilTime.MakeStr(_silenced - System.currentTimeMillis(), 1)) + "."));
|
||||
|
||||
UtilPlayer.message(
|
||||
player,
|
||||
F.main(GetName(),
|
||||
"Chat is silenced for "
|
||||
+ F.time(UtilTime.MakeStr(_silenced - System.currentTimeMillis(), 1)) + "."));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void loadClientPrefence(RetrieveClientInformationEvent event)
|
||||
{
|
||||
ChatClient chatClient = new ChatClient();
|
||||
chatClient.SetFilterChat(_repository.loadClientInformation(event.getUniqueId()));
|
||||
|
||||
Set(event.getPlayerName(), chatClient);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void filterChat(AsyncPlayerChatEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
if (event.isAsynchronous())
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
final String plyrname = player.toString();
|
||||
final String msg = event.getMessage();
|
||||
final String filtertype = "chat";
|
||||
final String dname = player.getPlayerListName();
|
||||
|
||||
JSONObject message = buildJsonChatObject(filtertype, dname, plyrname, msg, _serverName, 1);
|
||||
String response = getResponseFromTwoHat(message, filtertype);
|
||||
|
||||
if (response == null)
|
||||
{
|
||||
System.out.println("[ERROR] Unable to filter chat message...thanks a lot TwoHat.");
|
||||
return;
|
||||
}
|
||||
|
||||
int risk = Integer.parseInt(((JSONObject) JSONValue.parse(response)).get("risk").toString());
|
||||
|
||||
if (risk >= 5)
|
||||
{
|
||||
String filteredMessage = event.getMessage();
|
||||
|
||||
if (parseHashes(response) == null)
|
||||
event.setMessage(ChatColor.RED + msg);
|
||||
else
|
||||
{
|
||||
JSONArray hashindex = parseHashes(response);
|
||||
String newmessage = hasher(hashindex, msg);
|
||||
String badmessage = (new StringBuilder().append(newmessage)).toString();
|
||||
|
||||
if (newmessage.contains("*"))
|
||||
{
|
||||
filteredMessage = badmessage;
|
||||
}
|
||||
}
|
||||
|
||||
for (Player onlinePlayer : event.getRecipients())
|
||||
{
|
||||
if (Get(onlinePlayer).GetFilterChat())
|
||||
{
|
||||
onlinePlayer.sendMessage(String.format(event.getFormat(), event.getPlayer().getDisplayName(), filteredMessage));
|
||||
|
||||
if (onlinePlayer == event.getPlayer())
|
||||
{
|
||||
onlinePlayer.playSound(onlinePlayer.getLocation(), Sound.NOTE_PIANO, 2f, 2f);
|
||||
onlinePlayer.sendMessage(F.main("Chat", "You have chat filtering turned on, type /filter to turn it off."));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
onlinePlayer.sendMessage(String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void HandleChat(AsyncPlayerChatEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
|
||||
Player sender = event.getPlayer();
|
||||
|
||||
|
||||
if (SilenceCheck(sender))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
@ -156,7 +283,8 @@ public class Chat extends MiniClientPlugin<ChatClient>
|
||||
UtilPlayer.message(sender, F.main("Chat", "You are sending messages too fast."));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (_playerLastMessage.containsKey(sender.getName()) && _playerLastMessage.get(sender.getName()).equalsIgnoreCase(event.getMessage()))
|
||||
else if (_playerLastMessage.containsKey(sender.getName())
|
||||
&& _playerLastMessage.get(sender.getName()).equalsIgnoreCase(event.getMessage()))
|
||||
{
|
||||
UtilPlayer.message(sender, F.main("Chat", "You can't repeat the same message."));
|
||||
event.setCancelled(true);
|
||||
@ -164,16 +292,208 @@ public class Chat extends MiniClientPlugin<ChatClient>
|
||||
else
|
||||
{
|
||||
_playerLastMessage.put(sender.getName(), event.getMessage());
|
||||
|
||||
//_repository.saveChatMessage(sender.getName(), event.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public String hasher(JSONArray hasharray, String message)
|
||||
{
|
||||
StringBuilder newmsg = new StringBuilder(message);
|
||||
|
||||
for (int i = 0; i < hasharray.size(); i++)
|
||||
{
|
||||
Long charindex = ((Long) hasharray.get(i));
|
||||
int charidx = charindex.intValue();
|
||||
newmsg.setCharAt(charidx, '*');
|
||||
}
|
||||
|
||||
return newmsg.toString();
|
||||
}
|
||||
|
||||
public JSONArray parseHashes(String response)
|
||||
{
|
||||
JSONObject checkhash = (JSONObject) JSONValue.parse(response);
|
||||
JSONArray hasharray;
|
||||
hasharray = (JSONArray) checkhash.get("hashes");
|
||||
|
||||
return hasharray;
|
||||
}
|
||||
|
||||
private JSONObject buildJsonChatObject(String filtertype, String name, String player, String msg, String server, int rule)
|
||||
{
|
||||
JSONObject message = new JSONObject();
|
||||
switch (filtertype)
|
||||
{
|
||||
case "chat":
|
||||
message.put("player_display_name", name);
|
||||
message.put("player", player);
|
||||
message.put("text", msg);
|
||||
message.put("server", "gamma");
|
||||
message.put("room", server);
|
||||
message.put("language", "en");
|
||||
message.put("rule", rule);
|
||||
break;
|
||||
case "username":
|
||||
message.put("player_id", name);
|
||||
message.put("username", name);
|
||||
message.put("language", "en");
|
||||
message.put("rule", rule);
|
||||
break;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
private String getResponseFromTwoHat(JSONObject message, String filtertype)
|
||||
{
|
||||
String authString = _authName + ":" + _apiKey;
|
||||
byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
|
||||
String authStringEnc = new String(authEncBytes);
|
||||
String url = _filterUrl + filtertype;
|
||||
|
||||
StringBuffer response = null;
|
||||
|
||||
HttpsURLConnection connection = null;
|
||||
DataOutputStream outputStream = null;
|
||||
BufferedReader bufferedReader = null;
|
||||
InputStreamReader inputStream = null;
|
||||
|
||||
try
|
||||
{
|
||||
URL obj = new URL(url);
|
||||
|
||||
connection = (HttpsURLConnection) obj.openConnection();
|
||||
|
||||
// add request header con.setRequestMethod("POST");
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
connection.setRequestProperty("Authorization", "Basic " + authStringEnc);
|
||||
connection.setRequestProperty("Connection", "Keep-Alive");
|
||||
|
||||
String urlParameters = message.toString();
|
||||
|
||||
// Send post request
|
||||
connection.setDoOutput(true);
|
||||
outputStream = new DataOutputStream(connection.getOutputStream());
|
||||
outputStream.writeBytes(urlParameters);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
|
||||
inputStream = new InputStreamReader(connection.getInputStream(), Charset.forName("UTF-8"));
|
||||
bufferedReader = new BufferedReader(inputStream);
|
||||
String inputLine;
|
||||
response = new StringBuffer();
|
||||
|
||||
while ((inputLine = bufferedReader.readLine()) != null)
|
||||
{
|
||||
response.append(inputLine);
|
||||
}
|
||||
|
||||
bufferedReader.close();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
System.out.println("Error getting response from TwoHat : " + exception.getMessage());
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (connection != null)
|
||||
{
|
||||
connection.disconnect();
|
||||
}
|
||||
|
||||
if (outputStream != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
outputStream.flush();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
outputStream.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (bufferedReader != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
bufferedReader.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (inputStream != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
inputStream.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String pmresponse = null;
|
||||
|
||||
if (response != null)
|
||||
pmresponse = response.toString();
|
||||
|
||||
return pmresponse;
|
||||
}
|
||||
|
||||
public static void trustCert() throws Exception
|
||||
{
|
||||
TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager()
|
||||
{
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public void checkClientTrusted(X509Certificate[] certs, String authType)
|
||||
{
|
||||
}
|
||||
|
||||
public void checkServerTrusted(X509Certificate[] certs, String authType)
|
||||
{
|
||||
}
|
||||
|
||||
} };
|
||||
|
||||
SSLContext sc = SSLContext.getInstance("SSL");
|
||||
sc.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
|
||||
|
||||
// Create all-trusting host name verifier
|
||||
HostnameVerifier allHostsValid = new HostnameVerifier()
|
||||
{
|
||||
public boolean verify(String hostname, SSLSession session)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// Install the all-trusting host verifier
|
||||
HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
|
||||
}
|
||||
|
||||
public long Silenced()
|
||||
{
|
||||
return _silenced;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void playerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
@ -185,4 +505,17 @@ public class Chat extends MiniClientPlugin<ChatClient>
|
||||
{
|
||||
return new ChatClient();
|
||||
}
|
||||
|
||||
public void toggleFilterChat(Player caller)
|
||||
{
|
||||
_repository.saveFilterChat(caller.getUniqueId().toString(), !Get(caller).GetFilterChat());
|
||||
Get(caller).SetFilterChat(!Get(caller).GetFilterChat());
|
||||
|
||||
if (Get(caller).GetFilterChat())
|
||||
caller.playSound(caller.getLocation(), Sound.NOTE_PIANO, 2f, 2f);
|
||||
else
|
||||
caller.playSound(caller.getLocation(), Sound.NOTE_PIANO, 1f, 1f);
|
||||
|
||||
caller.sendMessage(F.main("Chat", "You have turned chat filtering " + ChatColor.YELLOW + (Get(caller).GetFilterChat() ? "ON" : "OFF") + ChatColor.GRAY + "."));
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,6 @@ public class FilterChatCommand extends CommandBase<Chat>
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
//Plugin.Get(caller).ToggleFilterChat();
|
||||
Plugin.toggleFilterChat(caller);
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package mineplex.core.chat.repository;
|
||||
|
||||
public class ChatEvent
|
||||
{
|
||||
public String id;
|
||||
public String message;
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package mineplex.core.chat.repository;
|
||||
|
||||
public class ChatMessage
|
||||
{
|
||||
public String PlayerName;
|
||||
public String Message;
|
||||
}
|
@ -5,35 +5,28 @@ import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.mysql.AccountPreferenceRepository;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ChatRepository
|
||||
{
|
||||
private String _connectionString = "jdbc:mysql://sqlstats.mineplex.com:3306/PlayerStats?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private static Object _connectionLock = new Object();
|
||||
|
||||
private String _connectionString;
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
// private static String ALTER_ACCOUNT_PREFERENCE_TABLE = "SET @s = (SELECT IF((SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'accountPreferences' AND table_schema = DATABASE() AND column_name = 'filterChat') > 0, 'SELECT 1', 'ALTER TABLE accountPreferences ADD filterChat BOOL')); PREPARE stmt FROM @s; EXECUTE stmt;";
|
||||
|
||||
private static String CREATE_CHATLOG_TABLE = "CREATE TABLE IF NOT EXISTS chatLog (id INT NOT NULL AUTO_INCREMENT, serverName VARCHAR(255), playerName VARCHAR(16), message VARCHAR(255), day VARCHAR(100), PRIMARY KEY (id));";
|
||||
private static String INSERT_CHATWORDS = "INSERT INTO chatLog (serverName, playerName, message, day) VALUES (?, ?, ?, now());";
|
||||
//private static String SAVE_FILTER_VALUE = "REPLACE INTO accountPreferences (filterChat) VALUES (?) WHERE playerName = ?;";
|
||||
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), filterChat BOOL, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));";
|
||||
private static String SAVE_FILTER_VALUE = "UPDATE accountPreferences SET filterChat = ? WHERE uuid = ?;";
|
||||
private static String INSERT_ACCOUNT = "INSERT INTO accountPreferences (uuid, filterChat) VALUES (?, '1') ON DUPLICATE KEY UPDATE uuid=uuid;";
|
||||
private static String RETRIEVE_FILTER_VALUE = "SELECT filterChat FROM accountPreferences WHERE uuid = ?;";
|
||||
|
||||
private Connection _connection = null;
|
||||
|
||||
private String _serverName;
|
||||
|
||||
public ChatRepository(String serverName, boolean us)
|
||||
public ChatRepository(String connectionUrl)
|
||||
{
|
||||
initialize();
|
||||
_connectionString = connectionUrl;
|
||||
|
||||
_serverName = (us ? "US " : "EU ") + serverName;
|
||||
initialize();
|
||||
}
|
||||
|
||||
public void initialize()
|
||||
@ -45,7 +38,7 @@ public class ChatRepository
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
// Create table
|
||||
preparedStatement = _connection.prepareStatement(CREATE_CHATLOG_TABLE);
|
||||
preparedStatement = _connection.prepareStatement(CREATE_ACCOUNT_TABLE);
|
||||
preparedStatement.execute();
|
||||
}
|
||||
catch (Exception exception)
|
||||
@ -74,92 +67,34 @@ public class ChatRepository
|
||||
super.update();
|
||||
executeQuery(ALTER_ACCOUNT_PREFERENCE_TABLE);
|
||||
}
|
||||
|
||||
public List<String> retrieveFilteredWords()
|
||||
{
|
||||
List<String> filteredWords = new ArrayList<String>();
|
||||
|
||||
Connection connection = null;
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
connection = getConnection();
|
||||
|
||||
preparedStatement = connection.prepareStatement(RETRIEVE_FILTERED_WORDS);
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
filteredWords.add(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();
|
||||
}
|
||||
}
|
||||
|
||||
if (connection != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return filteredWords;
|
||||
}
|
||||
*/
|
||||
|
||||
public void saveFilterChat(String playerName, boolean filterChat)
|
||||
public void saveFilterChat(String uuid, boolean filterChat)
|
||||
{
|
||||
Connection connection = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
int affectedRows = 0;
|
||||
|
||||
try
|
||||
{
|
||||
connection = getConnection();
|
||||
preparedStatement = connection.prepareStatement(SAVE_FILTER_VALUE);
|
||||
|
||||
preparedStatement.setString(1, playerName);
|
||||
|
||||
affectedRows = preparedStatement.executeUpdate();
|
||||
|
||||
if (affectedRows == 0)
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
System.out.println("Error saving FilterChat option.");
|
||||
if (_connection.isClosed())
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
|
||||
preparedStatement = _connection.prepareStatement(SAVE_FILTER_VALUE);
|
||||
|
||||
preparedStatement.setBoolean(1, filterChat);
|
||||
preparedStatement.setString(2, uuid);
|
||||
|
||||
affectedRows = preparedStatement.executeUpdate();
|
||||
|
||||
if (affectedRows == 0)
|
||||
{
|
||||
System.out.println("Error saving FilterChat option.");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
@ -179,44 +114,44 @@ public class ChatRepository
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (connection != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadClientInformation(Connection connection)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
*/
|
||||
|
||||
public void saveChatMessage(String playerName, String message)
|
||||
public boolean loadClientInformation(UUID uuid)
|
||||
{
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection.isClosed())
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
if (_connection.isClosed())
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
|
||||
preparedStatement = _connection.prepareStatement(RETRIEVE_FILTER_VALUE);
|
||||
preparedStatement.setString(1, uuid.toString());
|
||||
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
|
||||
if (!resultSet.next())
|
||||
{
|
||||
preparedStatement.close();
|
||||
preparedStatement = _connection.prepareStatement(INSERT_ACCOUNT);
|
||||
preparedStatement.setString(1, uuid.toString());
|
||||
|
||||
preparedStatement.execute();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
return resultSet.getBoolean(1);
|
||||
}
|
||||
}
|
||||
|
||||
preparedStatement = _connection.prepareStatement(INSERT_CHATWORDS, Statement.RETURN_GENERATED_KEYS);
|
||||
preparedStatement.setString(1, _serverName);
|
||||
preparedStatement.setString(2, playerName);
|
||||
preparedStatement.setString(3, message);
|
||||
|
||||
preparedStatement.executeUpdate();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -235,6 +170,20 @@ public class ChatRepository
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (resultSet != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
package mineplex.core.chat.repository;
|
||||
|
||||
public class ChatSubmitToken
|
||||
{
|
||||
public String player_display_name;
|
||||
public String player;
|
||||
public String text;
|
||||
public String server;
|
||||
public String room;
|
||||
public String language = "en";
|
||||
public String rule;
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
package mineplex.core.command;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -47,11 +49,18 @@ public class CommandCenter implements Listener
|
||||
args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ");
|
||||
}
|
||||
|
||||
ICommand command = Commands.get(commandName);
|
||||
ICommand command = Commands.get(commandName.toLowerCase());
|
||||
|
||||
if (command != null && ClientManager.Get(event.getPlayer()).GetRank().Has(event.getPlayer(), command.GetRequiredRank(), true))
|
||||
{
|
||||
command.SetAliasUsed(commandName);
|
||||
if (!Recharge.Instance.use(event.getPlayer(), "Command", 500, false, false))
|
||||
{
|
||||
event.getPlayer().sendMessage(F.main("Command Center", "You can't spam commands that fast."));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
command.SetAliasUsed(commandName.toLowerCase());
|
||||
command.Execute(event.getPlayer(), args);
|
||||
|
||||
event.setCancelled(true);
|
||||
@ -62,7 +71,7 @@ public class CommandCenter implements Listener
|
||||
{
|
||||
for (String commandRoot : command.Aliases())
|
||||
{
|
||||
Commands.put(commandRoot, command);
|
||||
Commands.put(commandRoot.toLowerCase(), command);
|
||||
command.SetCommandCenter(this);
|
||||
}
|
||||
}
|
||||
@ -71,7 +80,7 @@ public class CommandCenter implements Listener
|
||||
{
|
||||
for (String commandRoot : command.Aliases())
|
||||
{
|
||||
Commands.remove(commandRoot);
|
||||
Commands.remove(commandRoot.toLowerCase());
|
||||
command.SetCommandCenter(null);
|
||||
}
|
||||
}
|
||||
|
70
Plugins/Mineplex.Core/src/mineplex/core/logger/Logger.java
Normal file
70
Plugins/Mineplex.Core/src/mineplex/core/logger/Logger.java
Normal file
@ -0,0 +1,70 @@
|
||||
package mineplex.core.logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Logger
|
||||
{
|
||||
public static Logger Instance;
|
||||
|
||||
private LoggerRepository _repository;
|
||||
|
||||
public static void initialize(JavaPlugin plugin)
|
||||
{
|
||||
Instance = new Logger(plugin);
|
||||
}
|
||||
|
||||
public Logger(JavaPlugin plugin)
|
||||
{
|
||||
setupConfigValues(plugin);
|
||||
|
||||
_repository = new LoggerRepository(plugin.getConfig().getString("log.connectionurl"), plugin.getConfig().getString("serverstatus.name"));
|
||||
|
||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler()
|
||||
{
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e)
|
||||
{
|
||||
log(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setupConfigValues(JavaPlugin plugin)
|
||||
{
|
||||
try
|
||||
{
|
||||
plugin.getConfig().addDefault("log.connectionurl", "jdbc:mysql://sqlstats.mineplex.com:3306/Mineplex");
|
||||
plugin.getConfig().set("log.connectionurl", plugin.getConfig().getString("log.connectionurl"));
|
||||
plugin.saveConfig();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void log(String message)
|
||||
{
|
||||
_repository.saveLog(message);
|
||||
}
|
||||
|
||||
public void log(Throwable exception)
|
||||
{
|
||||
List<String> messages = new ArrayList<String>();
|
||||
|
||||
messages.add("[Exception Start]" + exception.getMessage());
|
||||
|
||||
for (StackTraceElement element : exception.getStackTrace())
|
||||
{
|
||||
messages.add(element.toString());
|
||||
}
|
||||
|
||||
messages.add("[Exception End]");
|
||||
|
||||
_repository.saveLog(messages.toArray(new String[0]));
|
||||
}
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
package mineplex.core.logger;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class LoggerRepository
|
||||
{
|
||||
private static Object _connectionLock = new Object();
|
||||
|
||||
private String _connectionString;
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
private static String CREATE_LOG_TABLE = "CREATE TABLE IF NOT EXISTS errorLog (id INT NOT NULL AUTO_INCREMENT, server VARCHAR(256), message VARCHAR(256), date LONG, PRIMARY KEY (id));";
|
||||
private static String INSERT_LOG = "INSERT INTO errorLog (server, message, date) VALUES (?, ?, now());";
|
||||
|
||||
private Connection _connection = null;
|
||||
private String _serverName;
|
||||
|
||||
public LoggerRepository(String connectionUrl, String serverName)
|
||||
{
|
||||
_connectionString = connectionUrl;
|
||||
_serverName = serverName;
|
||||
|
||||
initialize();
|
||||
}
|
||||
|
||||
public void initialize()
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
// Create table
|
||||
preparedStatement = _connection.prepareStatement(CREATE_LOG_TABLE);
|
||||
preparedStatement.execute();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void saveLog(String...message)
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
if (_connection.isClosed())
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
|
||||
preparedStatement = _connection.prepareStatement(INSERT_LOG);
|
||||
|
||||
for (String msg : message)
|
||||
{
|
||||
preparedStatement.setString(1, _serverName);
|
||||
preparedStatement.setString(2, msg.substring(0, Math.min(257, msg.length())));
|
||||
preparedStatement.addBatch();
|
||||
}
|
||||
|
||||
preparedStatement.executeBatch();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -134,11 +134,11 @@ public class StatsManager extends MiniPlugin
|
||||
try
|
||||
{
|
||||
List<Column<?>> columnList = new ArrayList<Column<?>>();
|
||||
columnList.add(new ColumnVarChar("playerName", 16, event.getClientName()));
|
||||
columnList.add(new ColumnVarChar("playerName", 16, event.getPlayerName()));
|
||||
List<Row> rows = table.retrieve(columnList);
|
||||
|
||||
Row row = table.createRow();
|
||||
((ColumnVarChar)row.Columns.get("playerName")).Value = event.getClientName();
|
||||
((ColumnVarChar)row.Columns.get("playerName")).Value = event.getPlayerName();
|
||||
|
||||
if (rows.size() > 0)
|
||||
{
|
||||
@ -148,7 +148,7 @@ public class StatsManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
_playerStatList.get(tableName).put(event.getClientName(), row);
|
||||
_playerStatList.get(tableName).put(event.getPlayerName(), row);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
@ -11,6 +11,7 @@ import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.energy.Energy;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.logger.Logger;
|
||||
import mineplex.core.memory.MemoryFix;
|
||||
import mineplex.core.message.MessageManager;
|
||||
import mineplex.core.monitor.LagMeter;
|
||||
@ -60,6 +61,8 @@ public class Hub extends JavaPlugin implements INautilusPlugin, IRelation
|
||||
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
|
||||
saveConfig();
|
||||
|
||||
Logger.initialize(this);
|
||||
|
||||
//Core Modules
|
||||
CoreClientManager clientManager = CoreClientManager.Initialize(this, GetWebServerAddress());
|
||||
|
||||
|
@ -54,6 +54,7 @@ import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||
import mineplex.core.disguise.disguises.DisguiseSlime;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.logger.Logger;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.task.TaskManager;
|
||||
@ -83,7 +84,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
private StatsManager _statsManager;
|
||||
private GadgetManager _gadgetManager;
|
||||
private MountManager _mountManager;
|
||||
|
||||
private VisibilityManager _visibilityManager;
|
||||
private TutorialManager _tutorialManager;
|
||||
private TextManager _textCreator;
|
||||
@ -349,6 +349,9 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
|
||||
for (Player otherPlayer : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (_clientManager.Get(otherPlayer) == null)
|
||||
continue;
|
||||
|
||||
String rankName = _clientManager.Get(player).GetRank().Name;
|
||||
String otherRankName = _clientManager.Get(otherPlayer).GetRank().Name;
|
||||
|
||||
@ -372,16 +375,10 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Instance.log(ex);
|
||||
System.out.println("[HubManager] Player Join exception");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
/*
|
||||
if (Bukkit.getOnlinePlayers().length == 1)
|
||||
{
|
||||
new Dragon(this).Spawn();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/* XXX TOURNEY
|
||||
@ -448,8 +445,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
Rank rank = GetClients().Get(player).GetRank();
|
||||
@ -470,27 +465,40 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
Party party = _partyManager.GetParty(player);
|
||||
if (party != null)
|
||||
{
|
||||
event.getRecipients().clear();
|
||||
|
||||
event.setMessage(event.getMessage().substring(1, event.getMessage().length()));
|
||||
event.setFormat(C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + "%1$s " + C.cPurple + "%2$s");
|
||||
|
||||
for (String name : party.GetPlayers())
|
||||
{
|
||||
Player other = UtilPlayer.searchExact(name);
|
||||
|
||||
if (other != null)
|
||||
UtilPlayer.message(other, C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + player.getName() + ChatColor.RESET + " " + C.cPurple + event.getMessage().substring(1, event.getMessage().length()));
|
||||
event.getRecipients().add(other);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Party", "You are not in a Party."));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
else
|
||||
{
|
||||
if (_tutorialManager.InTutorial(other))
|
||||
continue;
|
||||
|
||||
UtilPlayer.message(other, rankStr + C.cYellow + player.getName() + " " + C.cWhite + event.getMessage());
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
{
|
||||
if (_tutorialManager.InTutorial(other))
|
||||
{
|
||||
event.getRecipients().remove(other);
|
||||
continue;
|
||||
}
|
||||
|
||||
event.setMessage(event.getMessage());
|
||||
event.setFormat(rankStr + C.cYellow + "%1$s " + C.cWhite + "%2$s");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.logger.Logger;
|
||||
import mineplex.core.map.Map;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.UtilGear;
|
||||
@ -35,6 +36,7 @@ public class MapManager extends MiniPlugin
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Instance.log(ex);
|
||||
System.out.println("[MapManager] Player Join exception");
|
||||
throw ex;
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ public class WorldManager extends MiniPlugin
|
||||
@EventHandler
|
||||
public void BorderUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
if (event.getType() != UpdateType.FASTEST)
|
||||
return;
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
|
@ -153,7 +153,7 @@ public class Party
|
||||
//Scoreboard
|
||||
if (_players.contains(player.getName()))
|
||||
_scoreboard.getTeam("Party").addPlayer(player);
|
||||
else
|
||||
else if (Manager.GetClients().Get(player) != null)
|
||||
_scoreboard.getTeam(Manager.GetClients().Get(player).GetRank().Name).addPlayer(player);
|
||||
|
||||
if (_creator.equals(player.getName()))
|
||||
|
@ -12,6 +12,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.logger.Logger;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.party.commands.PartyCommand;
|
||||
@ -61,7 +62,7 @@ public class PartyManager extends MiniPlugin
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.out.println("[PartyManager] Player Join exception");
|
||||
Logger.Instance.log(ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.logger.Logger;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.status.ServerStatusData;
|
||||
@ -158,12 +159,8 @@ public class ServerManager extends MiniPlugin
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Logger.Instance.log(exception);
|
||||
exception.printStackTrace();
|
||||
|
||||
for (ServerInfo serverInfo : serverList)
|
||||
{
|
||||
System.out.println(F.main("ServerManager", ChatColor.YELLOW + serverInfo.Name + ": " + serverInfo.MOTD + " " + serverInfo.CurrentPlayers + "/" + serverInfo.MaxPlayers));
|
||||
}
|
||||
}
|
||||
|
||||
player.sendMessage(F.main("Server Portal", "There are currently no joinable servers!"));
|
||||
@ -528,6 +525,7 @@ public class ServerManager extends MiniPlugin
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Instance.log(e);
|
||||
System.out.println("ServerManager - Error parsing servers file : " + e.getMessage());
|
||||
}
|
||||
finally
|
||||
@ -619,11 +617,6 @@ public class ServerManager extends MiniPlugin
|
||||
{
|
||||
return _serverNpcShopMap.get("The Bridges");
|
||||
}
|
||||
|
||||
public ServerNpcShop getMinekartShop()
|
||||
{
|
||||
return _serverNpcShopMap.get("Minekart");
|
||||
}
|
||||
|
||||
public ServerNpcShop getSurvivalGamesShop()
|
||||
{
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.logger.Logger;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
@ -50,6 +51,7 @@ public class ServerManagerUpdater implements Listener
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Instance.log(ex);
|
||||
System.out.println("ServerManagerUpdater: Error parsing ServerManager dat md5's");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
@ -107,6 +109,7 @@ public class ServerManagerUpdater implements Listener
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Instance.log(ex);
|
||||
System.out.println("ServerManagerUpdater: Error parsing dat md5's");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
@ -164,6 +167,7 @@ public class ServerManagerUpdater implements Listener
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Instance.log(ex);
|
||||
System.out.println("ServerManagerUpdater: Error updating dats");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
@ -171,7 +175,6 @@ public class ServerManagerUpdater implements Listener
|
||||
|
||||
getCurrentMd5s();
|
||||
_plugin.LoadServers();
|
||||
System.out.println("ServerManagerUpdater: Updated with new dat file.");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,27 +0,0 @@
|
||||
package mineplex.hub.server.ui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.shop.item.IButton;
|
||||
|
||||
public class SelectMKButton implements IButton
|
||||
{
|
||||
private ServerGameMenu _menu;
|
||||
|
||||
public SelectMKButton(ServerGameMenu menu)
|
||||
{
|
||||
_menu = menu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ClickedLeft(Player player)
|
||||
{
|
||||
_menu.OpenMK(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ClickedRight(Player player)
|
||||
{
|
||||
ClickedLeft(player);
|
||||
}
|
||||
}
|
@ -63,15 +63,8 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
||||
ChatColor.RESET + "weapon and fight to survive against",
|
||||
ChatColor.RESET + "the Hunters!",
|
||||
}));
|
||||
this.setItem(6, ItemStackFactory.Instance.CreateStack(Material.SADDLE.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "MineKart " + C.cGray + "Racing", new String[]
|
||||
{
|
||||
ChatColor.RESET + "",
|
||||
ChatColor.RESET + "Pick your Kart and race against other",
|
||||
ChatColor.RESET + "players on exciting tracks, complete",
|
||||
ChatColor.RESET + "with weapons, drifting and more!",
|
||||
}));
|
||||
|
||||
this.setItem(7, ItemStackFactory.Instance.CreateStack(Material.BEACON.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Champions " + C.cGray + "Team Game", new String[]
|
||||
this.setItem(6, ItemStackFactory.Instance.CreateStack(Material.BEACON.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Champions " + C.cGray + "Team Game", new String[]
|
||||
{
|
||||
ChatColor.RESET + "",
|
||||
ChatColor.RESET + "Customize one of five exciting champions",
|
||||
@ -84,8 +77,7 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
||||
ButtonMap.put(3, new SelectSGButton(this));
|
||||
ButtonMap.put(4, new SelectBRButton(this));
|
||||
ButtonMap.put(5, new SelectBHButton(this));
|
||||
ButtonMap.put(6, new SelectMKButton(this));
|
||||
ButtonMap.put(7, new SelectDOMButton(this));
|
||||
ButtonMap.put(6, new SelectDOMButton(this));
|
||||
}
|
||||
|
||||
private void createTurfFortsCycle()
|
||||
@ -356,11 +348,6 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
||||
{
|
||||
Plugin.getBridgesShop().attemptShopOpen(player);
|
||||
}
|
||||
|
||||
public void OpenMK(Player player)
|
||||
{
|
||||
Plugin.getMinekartShop().attemptShopOpen(player);
|
||||
}
|
||||
|
||||
public void OpenBH(Player player)
|
||||
{
|
||||
|
@ -9,6 +9,7 @@ import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.logger.Logger;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.hub.server.ServerInfo;
|
||||
@ -51,12 +52,8 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Logger.Instance.log(exception);
|
||||
exception.printStackTrace();
|
||||
|
||||
for (ServerInfo serverInfo : serverList)
|
||||
{
|
||||
System.out.println(F.main("ServerNpcPage", ChatColor.YELLOW + serverInfo.Name + ": " + serverInfo.MOTD + " " + serverInfo.CurrentPlayers + "/" + serverInfo.MaxPlayers));
|
||||
}
|
||||
}
|
||||
|
||||
int slot = 10;
|
||||
|
@ -129,7 +129,7 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory
|
||||
skillToken.Name = skill.GetName();
|
||||
skillToken.Level = i + 1;
|
||||
skillToken.SalesPackage = new GameSalesPackageToken();
|
||||
skillToken.SalesPackage.Gems = 1000;
|
||||
skillToken.SalesPackage.Gems = 2000;
|
||||
|
||||
skillTokens.add(skillToken);
|
||||
}
|
||||
|
@ -104,11 +104,11 @@ public class ItemFactory extends MiniPlugin implements IItemFactory
|
||||
AddItem(new StandardSword(this, 0, 2));
|
||||
AddItem(new StandardAxe(this, 0, 2));
|
||||
|
||||
AddItem(new BoosterSword(this, 0, 4));
|
||||
AddItem(new BoosterAxe(this, 0, 4));
|
||||
AddItem(new BoosterSword(this, 2000, 4));
|
||||
AddItem(new BoosterAxe(this, 2000, 4));
|
||||
|
||||
AddItem(new PowerSword(this, 0, 4));
|
||||
AddItem(new PowerAxe(this, 0, 4));
|
||||
AddItem(new PowerSword(this, 2000, 4));
|
||||
AddItem(new PowerAxe(this, 2000, 4));
|
||||
|
||||
AddItem(new StandardBow(this, 0, 1));
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import mineplex.core.creature.Creature;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.logger.Logger;
|
||||
import mineplex.core.memory.MemoryFix;
|
||||
import mineplex.core.message.MessageManager;
|
||||
import mineplex.core.monitor.LagMeter;
|
||||
@ -34,7 +35,6 @@ import mineplex.core.teleport.Teleport;
|
||||
import mineplex.core.updater.FileUpdater;
|
||||
import mineplex.core.updater.Updater;
|
||||
import mineplex.minecraft.game.core.combat.CombatManager;
|
||||
import mineplex.minecraft.game.core.condition.ConditionManager;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
import nautilus.game.arcade.game.GameServerConfig;
|
||||
|
||||
@ -43,9 +43,9 @@ 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 implements INautilusPlugin
|
||||
{
|
||||
private String WEB_CONFIG = "webServer";
|
||||
private String WEB_CONFIG = "webServer";
|
||||
|
||||
//Modules
|
||||
private CoreClientManager _clientManager;
|
||||
@ -58,13 +58,15 @@ public class Arcade extends JavaPlugin implements INautilusPlugin
|
||||
public void onEnable()
|
||||
{
|
||||
//Delete Old Games Folders
|
||||
DeleteFolders();
|
||||
DeleteFolders();
|
||||
|
||||
//Configs
|
||||
getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/");
|
||||
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
|
||||
saveConfig();
|
||||
|
||||
Logger.initialize(this);
|
||||
|
||||
_clientManager = CoreClientManager.Initialize(this, GetWebServerAddress());
|
||||
|
||||
CommandCenter.Initialize(this, _clientManager);
|
||||
|
Loading…
Reference in New Issue
Block a user