Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex into wizards
This commit is contained in:
commit
aeff6bf4b9
@ -1,6 +1,5 @@
|
||||
package mineplex.bungee;
|
||||
|
||||
import mineplex.bungee.account.AccountManager;
|
||||
import mineplex.bungee.lobbyBalancer.LobbyBalancer;
|
||||
import mineplex.bungee.motd.MotdManager;
|
||||
import mineplex.bungee.playerCount.PlayerCount;
|
||||
@ -21,6 +20,5 @@ public class Mineplexer extends Plugin
|
||||
new PlayerStats(this);
|
||||
//new InternetStatus(this);
|
||||
new PlayerTracker(this);
|
||||
new AccountManager(this, playerCount);
|
||||
}
|
||||
}
|
||||
|
@ -1,71 +0,0 @@
|
||||
package mineplex.bungee.account;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import mineplex.bungee.playerCount.PlayerCount;
|
||||
import net.md_5.bungee.api.event.LoginEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
public class AccountManager implements Listener, Runnable
|
||||
{
|
||||
private Plugin _plugin;
|
||||
private PlayerCount _playerCount;
|
||||
private int _playerCap = -1;
|
||||
private AccountManagerRepository _repository;
|
||||
|
||||
private Gson _gson = new Gson();
|
||||
|
||||
public AccountManager(Plugin plugin, PlayerCount playerCount)
|
||||
{
|
||||
_plugin = plugin;
|
||||
_playerCount = playerCount;
|
||||
|
||||
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
|
||||
_plugin.getProxy().getScheduler().schedule(_plugin, this, 10L, 10L, TimeUnit.SECONDS);
|
||||
|
||||
_repository = new AccountManagerRepository();
|
||||
_repository.initialize();
|
||||
_playerCap = _repository.retrievePlayerCap();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void login(LoginEvent event)
|
||||
{
|
||||
if (_playerCap == -1 || _playerCount.getTotalPlayers() <= _playerCap)
|
||||
return;
|
||||
|
||||
String response = getClient(event.getConnection().getName(), event.getConnection().getUniqueId(), event.getConnection().getAddress().toString());
|
||||
|
||||
ClientToken token = _gson.fromJson(response, ClientToken.class);
|
||||
|
||||
if (token.Rank.equalsIgnoreCase("ALL"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
event.setCancelReason("§fDue to server issues, we have added a §cplayer limit§f.\n"
|
||||
+ "§fWe hope to have this resolved soon, §nplease be ptient§r.\n"
|
||||
+ "§fPlayers with Ranks can still join the server!\n\n"
|
||||
+ "§fPurchase Ranks at §awww.mineplex.com/shop");
|
||||
}
|
||||
}
|
||||
|
||||
public String getClient(String name, UUID uuid, String ipAddress)
|
||||
{
|
||||
LoginToken token = new LoginToken();
|
||||
token.Name = name;
|
||||
token.Uuid = uuid.toString();
|
||||
token.IpAddress = ipAddress;
|
||||
|
||||
return new JsonWebCall("http://accounts.mineplex.com/PlayerAccount/Login").ExecuteReturnStream(token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
_playerCap = _repository.retrievePlayerCap();
|
||||
}
|
||||
}
|
@ -1,105 +0,0 @@
|
||||
package mineplex.bungee.account;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class AccountManagerRepository
|
||||
{
|
||||
private Connection _connection = null;
|
||||
private String _connectionString = "jdbc:mysql://db.mineplex.com:3306/BungeeServers?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS playerCap (id INT NOT NULL AUTO_INCREMENT, playerCap INT, PRIMARY KEY (id));";
|
||||
private static String RETRIEVE_PLAYERCAP = "SELECT playerCap FROM playerCap;";
|
||||
|
||||
public void initialize()
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
// Create table
|
||||
preparedStatement = _connection.prepareStatement(CREATE_TABLE);
|
||||
preparedStatement.execute();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Initialized AccountManager.");
|
||||
}
|
||||
|
||||
public int retrievePlayerCap()
|
||||
{
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(RETRIEVE_PLAYERCAP);
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
return resultSet.getInt(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 -1;
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package mineplex.bungee.account;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class AccountToken
|
||||
{
|
||||
public int AccountId;
|
||||
public String Name;
|
||||
public RankToken Rank;
|
||||
|
||||
public int LoginCount;
|
||||
public long LastLogin;
|
||||
public long TotalPlayingTime;
|
||||
public HashSet<String> IpAdddresses = new HashSet<String>();
|
||||
|
||||
public boolean Banned;
|
||||
public String Reason;
|
||||
|
||||
public int BlueGems;
|
||||
public int GreenGems;
|
||||
public List<Integer> SalesPackageIds;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package mineplex.bungee.account;
|
||||
|
||||
public interface Callback<T>
|
||||
{
|
||||
public void run(T data);
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package mineplex.bungee.account;
|
||||
|
||||
public class ClientToken
|
||||
{
|
||||
public int AccountId;
|
||||
public String Name;
|
||||
public String Rank;
|
||||
public boolean RankPerm;
|
||||
public String RankExpire;
|
||||
public int EconomyBalance;
|
||||
|
||||
public AccountToken AccountToken;
|
||||
public long LastLogin;
|
||||
}
|
@ -1,355 +0,0 @@
|
||||
package mineplex.bungee.account;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.conn.scheme.PlainSocketFactory;
|
||||
import org.apache.http.conn.scheme.Scheme;
|
||||
import org.apache.http.conn.scheme.SchemeRegistry;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.impl.conn.PoolingClientConnectionManager;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.apache.http.protocol.HTTP;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class JsonWebCall
|
||||
{
|
||||
private String _url;
|
||||
private PoolingClientConnectionManager _connectionManager;
|
||||
|
||||
public JsonWebCall(String url)
|
||||
{
|
||||
_url = url;
|
||||
|
||||
SchemeRegistry schemeRegistry = new SchemeRegistry();
|
||||
schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
|
||||
|
||||
_connectionManager = new PoolingClientConnectionManager(schemeRegistry);
|
||||
_connectionManager.setMaxTotal(200);
|
||||
_connectionManager.setDefaultMaxPerRoute(20);
|
||||
}
|
||||
|
||||
public String ExecuteReturnStream(Object argument)
|
||||
{
|
||||
HttpClient httpClient = new DefaultHttpClient(_connectionManager);
|
||||
InputStream in = null;
|
||||
String result = null;
|
||||
|
||||
try
|
||||
{
|
||||
HttpResponse response;
|
||||
|
||||
Gson gson = new Gson();
|
||||
HttpPost request = new HttpPost(_url);
|
||||
|
||||
if (argument != null)
|
||||
{
|
||||
StringEntity params = new StringEntity(gson.toJson(argument));
|
||||
params.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
|
||||
request.setEntity(params);
|
||||
}
|
||||
|
||||
response = httpClient.execute(request);
|
||||
|
||||
if (response != null)
|
||||
{
|
||||
in = response.getEntity().getContent();
|
||||
result = convertStreamToString(in);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.out.println("Error executing JsonWebCall: \n" + ex.getMessage());
|
||||
System.out.println("Result: \n" + result);
|
||||
|
||||
for (StackTraceElement trace : ex.getStackTrace())
|
||||
{
|
||||
System.out.println(trace);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
httpClient.getConnectionManager().shutdown();
|
||||
|
||||
if (in != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
Execute((Object)null);
|
||||
}
|
||||
|
||||
public void Execute(Object argument)
|
||||
{
|
||||
HttpClient httpClient = new DefaultHttpClient(_connectionManager);
|
||||
InputStream in = null;
|
||||
|
||||
try
|
||||
{
|
||||
Gson gson = new Gson();
|
||||
HttpPost request = new HttpPost(_url);
|
||||
|
||||
if (argument != null)
|
||||
{
|
||||
StringEntity params = new StringEntity(gson.toJson(argument));
|
||||
params.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
|
||||
request.setEntity(params);
|
||||
}
|
||||
|
||||
httpClient.execute(request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.out.println("JsonWebCall.Execute() Error:\n" + ex.getMessage());
|
||||
|
||||
for (StackTraceElement trace : ex.getStackTrace())
|
||||
{
|
||||
System.out.println(trace);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
httpClient.getConnectionManager().shutdown();
|
||||
|
||||
if (in != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public <T> T Execute(Class<T> returnClass)
|
||||
{
|
||||
return Execute(returnClass, (Object)null);
|
||||
}
|
||||
|
||||
public <T> T Execute(Type returnType, Object argument)
|
||||
{
|
||||
HttpClient httpClient = new DefaultHttpClient(_connectionManager);
|
||||
InputStream in = null;
|
||||
T returnData = null;
|
||||
String result = null;
|
||||
|
||||
try
|
||||
{
|
||||
HttpResponse response;
|
||||
|
||||
Gson gson = new Gson();
|
||||
HttpPost request = new HttpPost(_url);
|
||||
|
||||
if (argument != null)
|
||||
{
|
||||
StringEntity params = new StringEntity(gson.toJson(argument));
|
||||
params.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
|
||||
request.setEntity(params);
|
||||
}
|
||||
|
||||
response = httpClient.execute(request);
|
||||
|
||||
if (response != null)
|
||||
{
|
||||
in = response.getEntity().getContent();
|
||||
|
||||
result = convertStreamToString(in);
|
||||
returnData = new Gson().fromJson(result, returnType);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.out.println("Error executing JsonWebCall: \n" + ex.getMessage());
|
||||
System.out.println("Result: \n" + result);
|
||||
|
||||
for (StackTraceElement trace : ex.getStackTrace())
|
||||
{
|
||||
System.out.println(trace);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
httpClient.getConnectionManager().shutdown();
|
||||
|
||||
if (in != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
public <T> T Execute(Class<T> returnClass, Object argument)
|
||||
{
|
||||
HttpClient httpClient = new DefaultHttpClient(_connectionManager);
|
||||
InputStream in = null;
|
||||
T returnData = null;
|
||||
String result = null;
|
||||
|
||||
try
|
||||
{
|
||||
HttpResponse response;
|
||||
|
||||
Gson gson = new Gson();
|
||||
HttpPost request = new HttpPost(_url);
|
||||
|
||||
if (argument != null)
|
||||
{
|
||||
StringEntity params = new StringEntity(gson.toJson(argument));
|
||||
params.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
|
||||
request.setEntity(params);
|
||||
}
|
||||
|
||||
response = httpClient.execute(request);
|
||||
|
||||
if (response != null)
|
||||
{
|
||||
in = response.getEntity().getContent();
|
||||
|
||||
result = convertStreamToString(in);
|
||||
returnData = new Gson().fromJson(result, returnClass);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.out.println("Error executing JsonWebCall: \n" + ex.getMessage());
|
||||
System.out.println("Result: \n" + result);
|
||||
|
||||
for (StackTraceElement trace : ex.getStackTrace())
|
||||
{
|
||||
System.out.println(trace);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
httpClient.getConnectionManager().shutdown();
|
||||
|
||||
if (in != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
public <T> void Execute(Class<T> callbackClass, Callback<T> callback)
|
||||
{
|
||||
Execute(callbackClass, callback, (Object)null);
|
||||
}
|
||||
|
||||
public <T> void Execute(Class<T> callbackClass, Callback<T> callback, Object argument)
|
||||
{
|
||||
HttpClient httpClient = new DefaultHttpClient(_connectionManager);
|
||||
InputStream in = null;
|
||||
String result = null;
|
||||
|
||||
try
|
||||
{
|
||||
HttpResponse response;
|
||||
|
||||
Gson gson = new Gson();
|
||||
HttpPost request = new HttpPost(_url);
|
||||
|
||||
if (argument != null)
|
||||
{
|
||||
StringEntity params = new StringEntity(gson.toJson(argument));
|
||||
params.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
|
||||
request.setEntity(params);
|
||||
}
|
||||
|
||||
response = httpClient.execute(request);
|
||||
|
||||
if (response != null && callback != null)
|
||||
{
|
||||
in = response.getEntity().getContent();
|
||||
|
||||
result = convertStreamToString(in);
|
||||
callback.run(new Gson().fromJson(result, callbackClass));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.out.println("Error executing JsonWebCall: \n" + ex.getMessage());
|
||||
System.out.println("Result: \n" + result);
|
||||
}
|
||||
finally
|
||||
{
|
||||
httpClient.getConnectionManager().shutdown();
|
||||
|
||||
if (in != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected String convertStreamToString(InputStream is)
|
||||
{
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
String line = null;
|
||||
try {
|
||||
while ((line = reader.readLine()) != null) {
|
||||
sb.append(line + "\n");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package mineplex.bungee.account;
|
||||
|
||||
public class LoginToken
|
||||
{
|
||||
public String Name;
|
||||
public String IpAddress = "0.0.0.0";
|
||||
public String MacAddress = "00-00-00-00-00-00-00-00";
|
||||
public String Uuid;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package mineplex.bungee.account;
|
||||
|
||||
public class RankToken
|
||||
{
|
||||
public int RankId;
|
||||
|
||||
public String Name;
|
||||
}
|
@ -1,189 +0,0 @@
|
||||
package mineplex.bungee.motd;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.Favicon;
|
||||
import net.md_5.bungee.api.ServerPing;
|
||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||
import net.md_5.bungee.connection.CustomMotd;
|
||||
import net.md_5.bungee.connection.InitialHandler;
|
||||
import net.md_5.bungee.protocol.packet.PingPacket;
|
||||
import net.md_5.bungee.protocol.packet.StatusResponse;
|
||||
|
||||
public class Motd implements CustomMotd
|
||||
{
|
||||
private static final int MAX_TICKS = 30;
|
||||
private static final char SNOWFLAKE = '❅';
|
||||
private static final String SNOWMAN = ChatColor.WHITE + "☃" + ChatColor.RESET;
|
||||
private static final String LEFT_SWORD = "§b§l§m §8§l§m[ §r";
|
||||
private static final String RIGHT_SWORD = "§8§l§m ]§b§l§m §r";
|
||||
private static final ChatColor[] COLOR_ROTATION =
|
||||
{ChatColor.RED, ChatColor.LIGHT_PURPLE, ChatColor.GOLD, ChatColor.BLUE, ChatColor.YELLOW, ChatColor.GREEN, ChatColor.AQUA};
|
||||
private static List<Favicon> ICON_FRAMES;
|
||||
|
||||
private MotdManager _manager;
|
||||
private ScheduledFuture _task;
|
||||
private int _ticks = 0;
|
||||
|
||||
public Motd(MotdManager manager)
|
||||
{
|
||||
_manager = manager;
|
||||
}
|
||||
|
||||
public void handlePing(final ProxyPingEvent pingResult, final InitialHandler initialHandler)
|
||||
{
|
||||
BungeeCord.getInstance().getConnectionThrottle().unthrottle(initialHandler.getAddress().getAddress());
|
||||
final Gson gson = initialHandler.getHandshake().getProtocolVersion() == 4?BungeeCord.getInstance().gsonLegacy:BungeeCord.getInstance().gson;
|
||||
|
||||
_task = initialHandler.getChannelWrapper().getHandle().eventLoop().scheduleAtFixedRate(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (initialHandler.getChannelWrapper().getHandle().isOpen() && _ticks <= MAX_TICKS)
|
||||
{
|
||||
ServerPing ping = pingResult.getResponse();
|
||||
|
||||
String desc = getDesc();
|
||||
ping.setDescription(desc);
|
||||
|
||||
Favicon icon = getIcon();
|
||||
if (icon != null)
|
||||
ping.setFavicon(icon);
|
||||
|
||||
initialHandler.unsafe().sendPacket(new StatusResponse(gson.toJson(ping)));
|
||||
_ticks++;
|
||||
|
||||
if (_ticks > MAX_TICKS)
|
||||
{
|
||||
PingPacket packet = initialHandler.getPingPacket();
|
||||
if (packet != null)
|
||||
{
|
||||
initialHandler.unsafe().sendPacket(packet);
|
||||
initialHandler.setPingPacket(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (initialHandler.getChannelWrapper().getHandle().isOpen())
|
||||
initialHandler.getChannelWrapper().getHandle().close();
|
||||
_task.cancel(true);
|
||||
}
|
||||
}
|
||||
}, 0, 200, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
private String getDesc()
|
||||
{
|
||||
int insetSpaces = 8;
|
||||
int maxSpaces = 6;
|
||||
|
||||
ChatColor mineplexColor = COLOR_ROTATION[_ticks % COLOR_ROTATION.length];
|
||||
int spaceLeftCount;
|
||||
int spaceNumber = _ticks % (maxSpaces*2);
|
||||
if (spaceNumber > maxSpaces)
|
||||
spaceLeftCount = 2*maxSpaces - spaceNumber;
|
||||
else
|
||||
spaceLeftCount = spaceNumber;
|
||||
|
||||
String spacesLeft = getRepeatedCharacters(' ', spaceLeftCount);
|
||||
String spacesRight = getRepeatedCharacters(' ', maxSpaces - spaceLeftCount);
|
||||
String insets = getRepeatedCharacters(' ', insetSpaces);
|
||||
String desc = insets + spacesLeft + LEFT_SWORD + spacesRight + getMineplex(mineplexColor) + spacesRight + RIGHT_SWORD + spacesLeft;
|
||||
|
||||
List<String> lines = _manager.getMotdLines();
|
||||
if (lines != null && lines.size() > 0)
|
||||
{
|
||||
int index = _ticks / (MAX_TICKS / (lines.size()));
|
||||
String currentLine = index >= lines.size() ? lines.get(lines.size() - 1) : lines.get(index);
|
||||
desc += "\n" + currentLine;
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
private Favicon getIcon()
|
||||
{
|
||||
Favicon icon = null;
|
||||
|
||||
if (ICON_FRAMES.size() > 0)
|
||||
{
|
||||
icon = ICON_FRAMES.get(_ticks % ICON_FRAMES.size());
|
||||
}
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
private String getMineplex(ChatColor color)
|
||||
{
|
||||
return " " + color + ChatColor.BOLD.toString() + "Mineplex" + ChatColor.RESET + ChatColor.WHITE + ChatColor.BOLD + " Games" + ChatColor.RESET + " ";
|
||||
}
|
||||
|
||||
private String getRepeatedCharacters(char c, int count)
|
||||
{
|
||||
char[] spaces = new char[count];
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
spaces[i] = c;
|
||||
}
|
||||
return new String(spaces);
|
||||
}
|
||||
|
||||
private static Comparator<File> FILE_NUMBER_COMPARATOR = new Comparator<File>()
|
||||
{
|
||||
@Override
|
||||
public int compare(File f1, File f2)
|
||||
{
|
||||
int compareValue = 0;
|
||||
|
||||
try
|
||||
{
|
||||
int i1 = Integer.parseInt(f1.getName().substring(0, f1.getName().indexOf('.')));
|
||||
int i2 = Integer.parseInt(f2.getName().substring(0, f2.getName().indexOf('.')));
|
||||
return i1 - i2;
|
||||
}
|
||||
catch (Exception e) {}
|
||||
|
||||
return compareValue;
|
||||
}
|
||||
};
|
||||
|
||||
static
|
||||
{
|
||||
// Load icon animations
|
||||
ICON_FRAMES = new ArrayList<Favicon>();
|
||||
|
||||
File iconFolder = new File("server-icon");
|
||||
if (iconFolder.exists() && iconFolder.isDirectory())
|
||||
{
|
||||
File[] files = iconFolder.listFiles();
|
||||
Arrays.sort(files, FILE_NUMBER_COMPARATOR);
|
||||
for (int i = 0; i < files.length; i++)
|
||||
{
|
||||
File file = files[i];
|
||||
try
|
||||
{
|
||||
BufferedImage image = ImageIO.read(file);
|
||||
Favicon favicon = Favicon.create(image);
|
||||
ICON_FRAMES.add(favicon);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Just ignore extra files
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package mineplex.bungee.motd;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import mineplex.serverdata.Region;
|
||||
@ -11,17 +11,15 @@ import mineplex.serverdata.servers.ServerManager;
|
||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.connection.CustomMotd;
|
||||
import net.md_5.bungee.connection.CustomMotdFactory;
|
||||
import net.md_5.bungee.connection.InitialHandler;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
public class MotdManager implements Listener, Runnable, CustomMotdFactory
|
||||
public class MotdManager implements Listener, Runnable
|
||||
{
|
||||
private Plugin _plugin;
|
||||
|
||||
private DataRepository<GlobalMotd> _repository;
|
||||
|
||||
private Random _random = new Random();
|
||||
private String _firstLine = " §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r";
|
||||
private List<String> _motdLines;
|
||||
|
||||
@ -45,7 +43,7 @@ public class MotdManager implements Listener, Runnable, CustomMotdFactory
|
||||
String motd = _firstLine;
|
||||
if (_motdLines != null && _motdLines.size() > 0)
|
||||
{
|
||||
motd += "\n" + _motdLines.get(0);
|
||||
motd += "\n" + _motdLines.get(_random.nextInt(_motdLines.size()));
|
||||
}
|
||||
|
||||
event.setResponse(new net.md_5.bungee.api.ServerPing(serverPing.getVersion(), serverPing.getPlayers(), motd, serverPing.getFaviconObject()));
|
||||
@ -79,8 +77,6 @@ public class MotdManager implements Listener, Runnable, CustomMotdFactory
|
||||
_motdLines = motd.getMotd();
|
||||
_firstLine = motd.getHeadline();
|
||||
}
|
||||
|
||||
InitialHandler.setCustomMotdFactory(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,10 +92,4 @@ public class MotdManager implements Listener, Runnable, CustomMotdFactory
|
||||
{
|
||||
return _motdLines;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomMotd makeMotd()
|
||||
{
|
||||
return new Motd(this);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
package net.md_5.bungee.connection;
|
||||
|
||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||
import net.md_5.bungee.protocol.packet.PingPacket;
|
||||
|
||||
public interface CustomMotd
|
||||
{
|
||||
public void handlePing(ProxyPingEvent event, InitialHandler initialHandler);
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package net.md_5.bungee.connection;
|
||||
|
||||
public interface CustomMotdFactory
|
||||
{
|
||||
public CustomMotd makeMotd();
|
||||
}
|
@ -1,487 +0,0 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by Fernflower decompiler)
|
||||
//
|
||||
|
||||
package net.md_5.bungee.connection;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.gson.Gson;
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.math.BigInteger;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URLEncoder;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import javax.crypto.SecretKey;
|
||||
import net.md_5.bungee.BungeeCipher;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.BungeeServerInfo;
|
||||
import net.md_5.bungee.EncryptionUtil;
|
||||
import net.md_5.bungee.UserConnection;
|
||||
import net.md_5.bungee.Util;
|
||||
import net.md_5.bungee.api.AbstractReconnectHandler;
|
||||
import net.md_5.bungee.api.Callback;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.Favicon;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.ServerPing;
|
||||
import net.md_5.bungee.api.ServerPing.PlayerInfo;
|
||||
import net.md_5.bungee.api.ServerPing.Players;
|
||||
import net.md_5.bungee.api.ServerPing.Protocol;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.config.ListenerInfo;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.PendingConnection;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.LoginEvent;
|
||||
import net.md_5.bungee.api.event.PlayerHandshakeEvent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.api.event.PreLoginEvent;
|
||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||
import net.md_5.bungee.chat.ComponentSerializer;
|
||||
import net.md_5.bungee.http.HttpClient;
|
||||
import net.md_5.bungee.netty.ChannelWrapper;
|
||||
import net.md_5.bungee.netty.HandlerBoss;
|
||||
import net.md_5.bungee.netty.PacketHandler;
|
||||
import net.md_5.bungee.netty.cipher.CipherDecoder;
|
||||
import net.md_5.bungee.netty.cipher.CipherEncoder;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
||||
import net.md_5.bungee.protocol.packet.EncryptionResponse;
|
||||
import net.md_5.bungee.protocol.packet.Handshake;
|
||||
import net.md_5.bungee.protocol.packet.Kick;
|
||||
import net.md_5.bungee.protocol.packet.LegacyHandshake;
|
||||
import net.md_5.bungee.protocol.packet.LegacyPing;
|
||||
import net.md_5.bungee.protocol.packet.LoginRequest;
|
||||
import net.md_5.bungee.protocol.packet.LoginSuccess;
|
||||
import net.md_5.bungee.protocol.packet.PingPacket;
|
||||
import net.md_5.bungee.protocol.packet.PluginMessage;
|
||||
import net.md_5.bungee.protocol.packet.StatusRequest;
|
||||
import net.md_5.bungee.protocol.packet.StatusResponse;
|
||||
|
||||
public class InitialHandler extends PacketHandler implements PendingConnection {
|
||||
|
||||
private static CustomMotdFactory _customMotdFactory;
|
||||
|
||||
private PingPacket _pingPacket;
|
||||
private final ProxyServer bungee;
|
||||
private ChannelWrapper ch;
|
||||
private final ListenerInfo listener;
|
||||
private Handshake handshake;
|
||||
private LoginRequest loginRequest;
|
||||
private EncryptionRequest request;
|
||||
private final List<PluginMessage> registerMessages = new ArrayList();
|
||||
private InitialHandler.State thisState;
|
||||
private final Unsafe unsafe;
|
||||
private boolean onlineMode;
|
||||
private InetSocketAddress virtualHost;
|
||||
private UUID uniqueId;
|
||||
private UUID offlineId;
|
||||
private LoginResult loginProfile;
|
||||
private boolean legacy;
|
||||
|
||||
public void connected(ChannelWrapper channel) throws Exception {
|
||||
this.ch = channel;
|
||||
}
|
||||
|
||||
public void exception(Throwable t) throws Exception {
|
||||
this.disconnect((String)(ChatColor.RED + Util.exception(t)));
|
||||
}
|
||||
|
||||
public void handle(PluginMessage pluginMessage) throws Exception {
|
||||
if(pluginMessage.getTag().equals("REGISTER")) {
|
||||
Preconditions.checkState(this.registerMessages.size() < 128, "Too many channels registered");
|
||||
this.registerMessages.add(pluginMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void handle(LegacyHandshake legacyHandshake) throws Exception {
|
||||
this.legacy = true;
|
||||
this.ch.getHandle().writeAndFlush(this.bungee.getTranslation("outdated_client", new Object[0]));
|
||||
this.ch.close();
|
||||
}
|
||||
|
||||
public void handle(LegacyPing ping) throws Exception {
|
||||
this.legacy = true;
|
||||
final boolean v1_5 = ping.isV1_5();
|
||||
ServerPing legacy = new ServerPing(new Protocol(this.bungee.getName() + " " + this.bungee.getGameVersion(), this.bungee.getProtocolVersion()), new Players(this.listener.getMaxPlayers(), this.bungee.getOnlineCount(), (PlayerInfo[])null), this.listener.getMotd(), (Favicon)null);
|
||||
Callback callback = new Callback<ProxyPingEvent>() {
|
||||
public void done(ProxyPingEvent result, Throwable error) {
|
||||
if(!InitialHandler.this.ch.isClosed()) {
|
||||
ServerPing legacy = result.getResponse();
|
||||
String kickMessage;
|
||||
if(v1_5) {
|
||||
kickMessage = ChatColor.DARK_BLUE + "\u0000" + 127 + '\u0000' + legacy.getVersion().getName() + '\u0000' + InitialHandler.getFirstLine(legacy.getDescription()) + '\u0000' + legacy.getPlayers().getOnline() + '\u0000' + legacy.getPlayers().getMax();
|
||||
} else {
|
||||
kickMessage = ChatColor.stripColor(InitialHandler.getFirstLine(legacy.getDescription())) + '§' + legacy.getPlayers().getOnline() + '§' + legacy.getPlayers().getMax();
|
||||
}
|
||||
|
||||
InitialHandler.this.ch.getHandle().writeAndFlush(kickMessage);
|
||||
InitialHandler.this.ch.close();
|
||||
}
|
||||
}
|
||||
};
|
||||
this.bungee.getPluginManager().callEvent(new ProxyPingEvent(this, legacy, callback));
|
||||
}
|
||||
|
||||
private static String getFirstLine(String str) {
|
||||
int pos = str.indexOf(10);
|
||||
return pos == -1?str:str.substring(0, pos);
|
||||
}
|
||||
|
||||
public void handle(StatusRequest statusRequest) throws Exception {
|
||||
Preconditions.checkState(this.thisState == InitialHandler.State.STATUS, "Not expecting STATUS");
|
||||
ServerInfo forced = AbstractReconnectHandler.getForcedHost(this);
|
||||
String motd = forced != null?forced.getMotd():this.listener.getMotd();
|
||||
Callback pingBack = new Callback<ServerPing>() {
|
||||
public void done(ServerPing result, Throwable error) {
|
||||
if(error != null) {
|
||||
result = new ServerPing();
|
||||
result.setDescription(InitialHandler.this.bungee.getTranslation("ping_cannot_connect", new Object[0]));
|
||||
InitialHandler.this.bungee.getLogger().log(Level.WARNING, "Error pinging remote server", error);
|
||||
}
|
||||
|
||||
Callback callback = new Callback<ProxyPingEvent>() {
|
||||
public void done(ProxyPingEvent pingResult, Throwable error) {
|
||||
// MINEPLEX
|
||||
if (_customMotdFactory != null)
|
||||
{
|
||||
_customMotdFactory.makeMotd().handlePing(pingResult, InitialHandler.this);
|
||||
}
|
||||
else
|
||||
{
|
||||
BungeeCord.getInstance().getConnectionThrottle().unthrottle(InitialHandler.this.getAddress().getAddress());
|
||||
Gson gson = InitialHandler.this.handshake.getProtocolVersion() == 4?BungeeCord.getInstance().gsonLegacy:BungeeCord.getInstance().gson;
|
||||
InitialHandler.this.unsafe.sendPacket(new StatusResponse(gson.toJson(pingResult.getResponse())));
|
||||
}
|
||||
}
|
||||
};
|
||||
InitialHandler.this.bungee.getPluginManager().callEvent(new ProxyPingEvent(InitialHandler.this, result, callback));
|
||||
}
|
||||
};
|
||||
if(forced != null && this.listener.isPingPassthrough()) {
|
||||
((BungeeServerInfo)forced).ping(pingBack, this.handshake.getProtocolVersion());
|
||||
} else {
|
||||
int protocol = net.md_5.bungee.protocol.Protocol.supportedVersions.contains(Integer.valueOf(this.handshake.getProtocolVersion()))?this.handshake.getProtocolVersion():this.bungee.getProtocolVersion();
|
||||
pingBack.done(new ServerPing(new Protocol(this.bungee.getName() + " " + this.bungee.getGameVersion(), protocol), new Players(this.listener.getMaxPlayers(), this.bungee.getOnlineCount(), (PlayerInfo[])null), motd, BungeeCord.getInstance().config.getFaviconObject()), (Throwable)null);
|
||||
}
|
||||
|
||||
this.thisState = InitialHandler.State.PING;
|
||||
}
|
||||
|
||||
public void handle(final PingPacket ping) throws Exception {
|
||||
|
||||
_pingPacket = ping;
|
||||
// if (thisState == State.PING) return; // MINEPLEX
|
||||
// Preconditions.checkState(this.thisState == InitialHandler.State.PING, "Not expecting PING");
|
||||
// getChannelWrapper().getHandle().eventLoop().schedule(new Runnable()
|
||||
// {
|
||||
// @Override
|
||||
// public void run()
|
||||
// {
|
||||
// unsafe.sendPacket(ping);
|
||||
// }
|
||||
// }, 6, TimeUnit.SECONDS);
|
||||
//
|
||||
// this.unsafe.sendPacket(ping);
|
||||
// this.disconnect((String)"");
|
||||
}
|
||||
|
||||
public void handle(Handshake handshake) throws Exception {
|
||||
Preconditions.checkState(this.thisState == InitialHandler.State.HANDSHAKE, "Not expecting HANDSHAKE");
|
||||
this.handshake = handshake;
|
||||
this.ch.setVersion(handshake.getProtocolVersion());
|
||||
if(handshake.getHost().endsWith(".")) {
|
||||
handshake.setHost(handshake.getHost().substring(0, handshake.getHost().length() - 1));
|
||||
}
|
||||
|
||||
this.virtualHost = InetSocketAddress.createUnresolved(handshake.getHost(), handshake.getPort());
|
||||
this.bungee.getLogger().log(Level.INFO, "{0} has connected", this);
|
||||
this.bungee.getPluginManager().callEvent(new PlayerHandshakeEvent(this, handshake));
|
||||
switch(handshake.getRequestedProtocol()) {
|
||||
case 1:
|
||||
this.thisState = InitialHandler.State.STATUS;
|
||||
this.ch.setProtocol(net.md_5.bungee.protocol.Protocol.STATUS);
|
||||
break;
|
||||
case 2:
|
||||
this.thisState = InitialHandler.State.USERNAME;
|
||||
this.ch.setProtocol(net.md_5.bungee.protocol.Protocol.LOGIN);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Cannot request protocol " + handshake.getRequestedProtocol());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void handle(LoginRequest loginRequest) throws Exception {
|
||||
Preconditions.checkState(this.thisState == InitialHandler.State.USERNAME, "Not expecting USERNAME");
|
||||
this.loginRequest = loginRequest;
|
||||
if(!net.md_5.bungee.protocol.Protocol.supportedVersions.contains(Integer.valueOf(this.handshake.getProtocolVersion()))) {
|
||||
this.disconnect((String)this.bungee.getTranslation("outdated_server", new Object[0]));
|
||||
} else if(this.getName().contains(".")) {
|
||||
this.disconnect((String)this.bungee.getTranslation("name_invalid", new Object[0]));
|
||||
} else if(this.getName().length() > 16) {
|
||||
this.disconnect((String)this.bungee.getTranslation("name_too_long", new Object[0]));
|
||||
} else {
|
||||
int limit = BungeeCord.getInstance().config.getPlayerLimit();
|
||||
if(limit > 0 && this.bungee.getOnlineCount() > limit) {
|
||||
this.disconnect((String)this.bungee.getTranslation("proxy_full", new Object[0]));
|
||||
} else if(!this.isOnlineMode() && this.bungee.getPlayer(this.getName()) != null) {
|
||||
this.disconnect((String)this.bungee.getTranslation("already_connected", new Object[0]));
|
||||
} else {
|
||||
Callback callback = new Callback<PreLoginEvent>() {
|
||||
public void done(PreLoginEvent result, Throwable error) {
|
||||
if(result.isCancelled()) {
|
||||
InitialHandler.this.disconnect((String)result.getCancelReason());
|
||||
} else if(!InitialHandler.this.ch.isClosed()) {
|
||||
if(InitialHandler.this.onlineMode) {
|
||||
InitialHandler.this.unsafe().sendPacket(InitialHandler.this.request = EncryptionUtil.encryptRequest());
|
||||
} else {
|
||||
InitialHandler.this.finish();
|
||||
}
|
||||
|
||||
InitialHandler.this.thisState = InitialHandler.State.ENCRYPT;
|
||||
}
|
||||
}
|
||||
};
|
||||
this.bungee.getPluginManager().callEvent(new PreLoginEvent(this, callback));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void handle(EncryptionResponse encryptResponse) throws Exception {
|
||||
Preconditions.checkState(this.thisState == InitialHandler.State.ENCRYPT, "Not expecting ENCRYPT");
|
||||
SecretKey sharedKey = EncryptionUtil.getSecret(encryptResponse, this.request);
|
||||
BungeeCipher decrypt = EncryptionUtil.getCipher(false, sharedKey);
|
||||
this.ch.addBefore("frame-decoder", "decrypt", new CipherDecoder(decrypt));
|
||||
BungeeCipher encrypt = EncryptionUtil.getCipher(true, sharedKey);
|
||||
this.ch.addBefore("frame-prepender", "encrypt", new CipherEncoder(encrypt));
|
||||
String encName = URLEncoder.encode(this.getName(), "UTF-8");
|
||||
MessageDigest sha = MessageDigest.getInstance("SHA-1");
|
||||
byte[][] encodedHash = new byte[][]{this.request.getServerId().getBytes("ISO_8859_1"), sharedKey.getEncoded(), EncryptionUtil.keys.getPublic().getEncoded()};
|
||||
int authURL = encodedHash.length;
|
||||
|
||||
for(int handler = 0; handler < authURL; ++handler) {
|
||||
byte[] bit = encodedHash[handler];
|
||||
sha.update(bit);
|
||||
}
|
||||
|
||||
String var11 = URLEncoder.encode((new BigInteger(sha.digest())).toString(16), "UTF-8");
|
||||
String var12 = "https://sessionserver.mojang.com/session/minecraft/hasJoined?username=" + encName + "&serverId=" + var11;
|
||||
Callback var13 = new Callback<String>() {
|
||||
public void done(String result, Throwable error) {
|
||||
if(error == null) {
|
||||
LoginResult obj = (LoginResult)BungeeCord.getInstance().gson.fromJson(result, LoginResult.class);
|
||||
if(obj != null) {
|
||||
InitialHandler.this.loginProfile = obj;
|
||||
InitialHandler.this.uniqueId = Util.getUUID(obj.getId());
|
||||
InitialHandler.this.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
InitialHandler.this.disconnect((String)"Not authenticated with Minecraft.net");
|
||||
} else {
|
||||
InitialHandler.this.disconnect((String)InitialHandler.this.bungee.getTranslation("mojang_fail", new Object[0]));
|
||||
InitialHandler.this.bungee.getLogger().log(Level.SEVERE, "Error authenticating " + InitialHandler.this.getName() + " with minecraft.net", error);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
HttpClient.get(var12, this.ch.getHandle().eventLoop(), var13);
|
||||
}
|
||||
|
||||
private void finish() {
|
||||
ProxiedPlayer old = this.bungee.getPlayer(this.getName());
|
||||
if(old != null) {
|
||||
old.disconnect(this.bungee.getTranslation("already_connected", new Object[0]));
|
||||
}
|
||||
|
||||
this.offlineId = UUID.nameUUIDFromBytes(("OfflinePlayer:" + this.getName()).getBytes(Charsets.UTF_8));
|
||||
if(this.uniqueId == null) {
|
||||
this.uniqueId = this.offlineId;
|
||||
}
|
||||
|
||||
Callback complete = new Callback<LoginEvent>() {
|
||||
public void done(LoginEvent result, Throwable error) {
|
||||
if(result.isCancelled()) {
|
||||
InitialHandler.this.disconnect((String)result.getCancelReason());
|
||||
} else if(!InitialHandler.this.ch.isClosed()) {
|
||||
InitialHandler.this.ch.getHandle().eventLoop().execute(new Runnable() {
|
||||
public void run() {
|
||||
if(InitialHandler.this.ch.getHandle().isActive()) {
|
||||
if(InitialHandler.this.getVersion() >= 5) {
|
||||
InitialHandler.this.unsafe.sendPacket(new LoginSuccess(InitialHandler.this.getUniqueId().toString(), InitialHandler.this.getName()));
|
||||
} else {
|
||||
InitialHandler.this.unsafe.sendPacket(new LoginSuccess(InitialHandler.this.getUUID(), InitialHandler.this.getName()));
|
||||
}
|
||||
|
||||
InitialHandler.this.ch.setProtocol(net.md_5.bungee.protocol.Protocol.GAME);
|
||||
UserConnection userCon = new UserConnection(InitialHandler.this.bungee, InitialHandler.this.ch, InitialHandler.this.getName(), InitialHandler.this);
|
||||
userCon.init();
|
||||
InitialHandler.this.bungee.getPluginManager().callEvent(new PostLoginEvent(userCon));
|
||||
((HandlerBoss)InitialHandler.this.ch.getHandle().pipeline().get(HandlerBoss.class)).setHandler(new UpstreamBridge(InitialHandler.this.bungee, userCon));
|
||||
ServerInfo server;
|
||||
if(InitialHandler.this.bungee.getReconnectHandler() != null) {
|
||||
server = InitialHandler.this.bungee.getReconnectHandler().getServer(userCon);
|
||||
} else {
|
||||
server = AbstractReconnectHandler.getForcedHost(InitialHandler.this);
|
||||
}
|
||||
|
||||
if(server == null) {
|
||||
server = InitialHandler.this.bungee.getServerInfo(InitialHandler.this.listener.getDefaultServer());
|
||||
}
|
||||
|
||||
userCon.connect(server, (Callback)null, true);
|
||||
InitialHandler.this.thisState = InitialHandler.State.FINISHED;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
this.bungee.getPluginManager().callEvent(new LoginEvent(this, complete));
|
||||
}
|
||||
|
||||
public void disconnect(String reason) {
|
||||
this.disconnect((BaseComponent[])TextComponent.fromLegacyText(reason));
|
||||
}
|
||||
|
||||
public void disconnect(final BaseComponent... reason) {
|
||||
if(!this.ch.isClosed()) {
|
||||
this.ch.getHandle().eventLoop().schedule(new Runnable() {
|
||||
public void run() {
|
||||
InitialHandler.this.unsafe().sendPacket(new Kick(ComponentSerializer.toString(reason)));
|
||||
InitialHandler.this.ch.close();
|
||||
}
|
||||
}, 500L, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void disconnect(BaseComponent reason) {
|
||||
this.disconnect((BaseComponent[])(new BaseComponent[]{reason}));
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.loginRequest == null?null:this.loginRequest.getData();
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return this.handshake == null?-1:this.handshake.getProtocolVersion();
|
||||
}
|
||||
|
||||
public InetSocketAddress getAddress() {
|
||||
return (InetSocketAddress)this.ch.getHandle().remoteAddress();
|
||||
}
|
||||
|
||||
public Unsafe unsafe() {
|
||||
return this.unsafe;
|
||||
}
|
||||
|
||||
public void setOnlineMode(boolean onlineMode) {
|
||||
Preconditions.checkState(this.thisState == InitialHandler.State.USERNAME, "Can only set online mode status whilst state is username");
|
||||
this.onlineMode = onlineMode;
|
||||
}
|
||||
|
||||
public String getUUID() {
|
||||
return this.uniqueId.toString().replaceAll("-", "");
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "[" + (this.getName() != null?this.getName():this.getAddress()) + "] <-> InitialHandler";
|
||||
}
|
||||
|
||||
@ConstructorProperties({"bungee", "listener"})
|
||||
public InitialHandler(ProxyServer bungee, ListenerInfo listener) {
|
||||
this.thisState = InitialHandler.State.HANDSHAKE;
|
||||
this.unsafe = new Unsafe() {
|
||||
public void sendPacket(DefinedPacket packet) {
|
||||
InitialHandler.this.ch.write(packet);
|
||||
}
|
||||
};
|
||||
this.onlineMode = BungeeCord.getInstance().config.isOnlineMode();
|
||||
this.bungee = bungee;
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public ListenerInfo getListener() {
|
||||
return this.listener;
|
||||
}
|
||||
|
||||
public Handshake getHandshake() {
|
||||
return this.handshake;
|
||||
}
|
||||
|
||||
public LoginRequest getLoginRequest() {
|
||||
return this.loginRequest;
|
||||
}
|
||||
|
||||
public List<PluginMessage> getRegisterMessages() {
|
||||
return this.registerMessages;
|
||||
}
|
||||
|
||||
public boolean isOnlineMode() {
|
||||
return this.onlineMode;
|
||||
}
|
||||
|
||||
public InetSocketAddress getVirtualHost() {
|
||||
return this.virtualHost;
|
||||
}
|
||||
|
||||
public UUID getUniqueId() {
|
||||
return this.uniqueId;
|
||||
}
|
||||
|
||||
public UUID getOfflineId() {
|
||||
return this.offlineId;
|
||||
}
|
||||
|
||||
public LoginResult getLoginProfile() {
|
||||
return this.loginProfile;
|
||||
}
|
||||
|
||||
public boolean isLegacy() {
|
||||
return this.legacy;
|
||||
}
|
||||
|
||||
public ChannelWrapper getChannelWrapper()
|
||||
{
|
||||
return ch; //MINEPLEX
|
||||
}
|
||||
|
||||
public PingPacket getPingPacket()
|
||||
{
|
||||
return _pingPacket; // MINEPLEX
|
||||
}
|
||||
|
||||
public void setPingPacket(PingPacket packet)
|
||||
{
|
||||
_pingPacket = packet;
|
||||
}
|
||||
|
||||
private static enum State {
|
||||
HANDSHAKE,
|
||||
STATUS,
|
||||
PING,
|
||||
USERNAME,
|
||||
ENCRYPT,
|
||||
FINISHED;
|
||||
|
||||
private State() {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setCustomMotdFactory(CustomMotdFactory factory)
|
||||
{
|
||||
_customMotdFactory = factory;
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by Fernflower decompiler)
|
||||
//
|
||||
|
||||
package net.md_5.bungee.connection;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.Callback;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.ServerPing;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.netty.ChannelWrapper;
|
||||
import net.md_5.bungee.netty.PacketHandler;
|
||||
import net.md_5.bungee.protocol.MinecraftDecoder;
|
||||
import net.md_5.bungee.protocol.MinecraftEncoder;
|
||||
import net.md_5.bungee.protocol.Protocol;
|
||||
import net.md_5.bungee.protocol.packet.Handshake;
|
||||
import net.md_5.bungee.protocol.packet.StatusRequest;
|
||||
import net.md_5.bungee.protocol.packet.StatusResponse;
|
||||
|
||||
public class PingHandler extends PacketHandler {
|
||||
private final ServerInfo target;
|
||||
private final Callback<ServerPing> callback;
|
||||
private final int protocol;
|
||||
private ChannelWrapper channel;
|
||||
|
||||
public void connected(ChannelWrapper channel) throws Exception {
|
||||
this.channel = channel;
|
||||
MinecraftEncoder encoder = new MinecraftEncoder(Protocol.HANDSHAKE, false, this.protocol);
|
||||
channel.getHandle().pipeline().addAfter("frame-decoder", "packet-decoder", new MinecraftDecoder(Protocol.STATUS, false, ProxyServer.getInstance().getProtocolVersion()));
|
||||
channel.getHandle().pipeline().addAfter("frame-prepender", "packet-encoder", encoder);
|
||||
channel.write(new Handshake(this.protocol, this.target.getAddress().getHostString(), this.target.getAddress().getPort(), 1));
|
||||
encoder.setProtocol(Protocol.STATUS);
|
||||
channel.write(new StatusRequest());
|
||||
}
|
||||
|
||||
public void exception(Throwable t) throws Exception {
|
||||
this.callback.done(null, t);
|
||||
}
|
||||
|
||||
public void handle(StatusResponse statusResponse) throws Exception {
|
||||
Gson gson = this.protocol == 4?BungeeCord.getInstance().gsonLegacy:BungeeCord.getInstance().gson;
|
||||
this.callback.done(gson.fromJson(statusResponse.getResponse(), ServerPing.class), (Throwable)null);
|
||||
System.out.println("handle");
|
||||
// this.channel.close(); //MINEPLEX
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "[Ping Handler] -> " + this.target.getName();
|
||||
}
|
||||
|
||||
public PingHandler(ServerInfo target, Callback<ServerPing> callback, int protocol) {
|
||||
this.target = target;
|
||||
this.callback = callback;
|
||||
this.protocol = protocol;
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ public enum Rank
|
||||
SNR_MODERATOR("Sr.Mod", ChatColor.GOLD),
|
||||
MODERATOR("Mod", ChatColor.GOLD),
|
||||
HELPER("Helper", ChatColor.DARK_AQUA),
|
||||
MAPDEV("MapTeam", ChatColor.BLUE),
|
||||
MAPDEV("Builder", ChatColor.BLUE),
|
||||
MAPLEAD("MapLead", ChatColor.DARK_PURPLE),
|
||||
|
||||
EVENT("Event", ChatColor.WHITE),
|
||||
|
@ -185,10 +185,10 @@ public class AccountRepository extends RepositoryBase
|
||||
}
|
||||
}, new ColumnVarChar("name", 100, name));
|
||||
|
||||
if (uuids.size() > 1)
|
||||
return null;
|
||||
if (uuids.size() > 0)
|
||||
return uuids.get(uuids.size() - 1);
|
||||
else
|
||||
return uuids.size() == 1 ? uuids.get(0) : null;
|
||||
return null;
|
||||
}
|
||||
|
||||
public void saveRank(final Callback<Rank> callback, final String name, final UUID uuid, final Rank rank, final boolean perm)
|
||||
|
@ -209,6 +209,8 @@ public class AchievementManager extends MiniPlugin
|
||||
level = Math.max(level, 50 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
|
||||
else if (rank.Has(Rank.ADMIN))
|
||||
level = Math.max(level, 30 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
|
||||
else if (rank.Has(Rank.SNR_MODERATOR))
|
||||
level = Math.max(level, 15);
|
||||
else if (rank.Has(Rank.MODERATOR))
|
||||
level = Math.max(level, 5);
|
||||
|
||||
|
@ -102,8 +102,6 @@ public class AntiHack extends MiniPlugin
|
||||
_movementDetectors.add(new Speed(this));
|
||||
|
||||
_combatDetectors.add(new Reach(this));
|
||||
|
||||
_enabled = false;
|
||||
}
|
||||
|
||||
public static void Initialize(JavaPlugin plugin, Punish punish, Portal portal, PreferencesManager preferences, CoreClientManager clientManager)
|
||||
|
@ -7,9 +7,9 @@ import org.apache.commons.dbcp2.BasicDataSource;
|
||||
|
||||
public final class DBPool
|
||||
{
|
||||
public static final DataSource ACCOUNT = openDataSource("jdbc:mysql://db.mineplex.com/Account", "root", "tAbechAk3wR7tuTh");
|
||||
public static final DataSource QUEUE = openDataSource("jdbc:mysql://db.mineplex.com/Queue", "root", "tAbechAk3wR7tuTh");
|
||||
public static final DataSource MINEPLEX = openDataSource("jdbc:mysql://db.mineplex.com:3306/Mineplex", "root", "tAbechAk3wR7tuTh");
|
||||
public static final DataSource ACCOUNT = openDataSource("jdbc:mysql://db.mineplex.com/Account", "MilitaryPolice", "CUPr6Wuw2Rus$qap");
|
||||
public static final DataSource QUEUE = openDataSource("jdbc:mysql://db.mineplex.com/Queue", "MilitaryPolice", "CUPr6Wuw2Rus$qap");
|
||||
public static final DataSource MINEPLEX = openDataSource("jdbc:mysql://db.mineplex.com:3306/Mineplex", "MilitaryPolice", "CUPr6Wuw2Rus$qap");
|
||||
public static final DataSource STATS_MINEPLEX = openDataSource("jdbc:mysql://sqlstats.mineplex.com:3306/Mineplex", "root", "tAbechAk3wR7tuTh");
|
||||
|
||||
private static DataSource openDataSource(String url, String username, String password)
|
||||
|
@ -81,7 +81,6 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
|
||||
if (event.getType() != UpdateType.SLOW || Bukkit.getOnlinePlayers().size() == 0)
|
||||
return;
|
||||
|
||||
/*
|
||||
final Player[] onlinePlayers = UtilServer.getPlayers();
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable()
|
||||
@ -109,13 +108,10 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
|
||||
});
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
public void addFriend(final Player caller, final String name)
|
||||
{
|
||||
caller.sendMessage(F.main(getName(), ChatColor.RED + "Friend is currently disabled."));
|
||||
/*
|
||||
if (caller.getName().equalsIgnoreCase(name))
|
||||
{
|
||||
caller.sendMessage(F.main(getName(), ChatColor.GRAY + "You cannot add yourself as a friend"));
|
||||
@ -218,13 +214,10 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
|
||||
});
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
public void removeFriend(final Player caller, final String name)
|
||||
{
|
||||
caller.sendMessage(F.main(getName(), ChatColor.RED + "Friend is currently disabled."));
|
||||
/*
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
@ -254,13 +247,10 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
|
||||
});
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
public void showFriends(Player caller)
|
||||
{
|
||||
caller.sendMessage(F.main(getName(), ChatColor.RED + "Friend is currently disabled."));
|
||||
/*
|
||||
boolean isStaff = ClientManager.Get(caller).GetRank().Has(Rank.HELPER);
|
||||
boolean gotAFriend = false;
|
||||
List<FriendStatus> friendStatuses = Get(caller).getFriends();
|
||||
@ -393,7 +383,6 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
|
||||
message.add(C.cAqua + C.Strike + "======================");
|
||||
|
||||
message.sendToPlayer(caller);
|
||||
*/
|
||||
}
|
||||
|
||||
public boolean isFriends(Player player, String friend)
|
||||
|
@ -16,7 +16,6 @@ import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.column.ColumnInt;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
import mineplex.core.friend.FriendStatusType;
|
||||
import mineplex.serverdata.Region;
|
||||
@ -27,8 +26,11 @@ import mineplex.serverdata.servers.ServerManager;
|
||||
|
||||
public class FriendRepository extends RepositoryBase
|
||||
{
|
||||
private static String ADD_FRIEND_RECORD = "INSERT INTO accountFriend (sourceId, targetId) VALUES(?, ?);";
|
||||
private static String DELETE_FRIEND_RECORD = "DELETE FROM accountFriend WHERE id = ?;";
|
||||
private static String CREATE_FRIEND_TABLE = "CREATE TABLE IF NOT EXISTS accountFriend (id INT NOT NULL AUTO_INCREMENT, uuidSource VARCHAR(100), uuidTarget VARCHAR(100), status VARCHAR(100), PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuidSource, uuidTarget));";
|
||||
private static String RETRIEVE_MULTIPLE_FRIEND_RECORDS = "SELECT uuidSource, tA.Name, status, tA.lastLogin, now() FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget WHERE uuidSource IN ";
|
||||
private static String ADD_FRIEND_RECORD = "INSERT INTO accountFriend (uuidSource, uuidTarget, status, created) SELECT fA.uuid AS uuidSource, tA.uuid AS uuidTarget, ?, now() FROM accounts as fA LEFT JOIN accounts AS tA ON tA.name = ? WHERE fA.name = ?;";
|
||||
private static String UPDATE_MUTUAL_RECORD = "UPDATE accountFriend AS aF INNER JOIN accounts as fA ON aF.uuidSource = fA.uuid INNER JOIN accounts AS tA ON aF.uuidTarget = tA.uuid SET aF.status = ? WHERE tA.name = ? AND fA.name = ?;";
|
||||
private static String DELETE_FRIEND_RECORD = "DELETE aF FROM accountFriend AS aF INNER JOIN accounts as fA ON aF.uuidSource = fA.uuid INNER JOIN accounts AS tA ON aF.uuidTarget = tA.uuid WHERE fA.name = ? AND tA.name = ?;";
|
||||
|
||||
// Repository holding active PlayerStatus data.
|
||||
private DataRepository<PlayerStatus> _repository;
|
||||
@ -52,14 +54,29 @@ public class FriendRepository extends RepositoryBase
|
||||
{
|
||||
}
|
||||
|
||||
public boolean addFriend(int sourceAccountId, int targetAccountId)
|
||||
public boolean addFriend(final Player caller, String name)
|
||||
{
|
||||
return executeUpdate(ADD_FRIEND_RECORD, new ColumnInt("sourceId", sourceAccountId), new ColumnInt("targetId", targetAccountId)) > 0;
|
||||
int rowsAffected = executeUpdate(ADD_FRIEND_RECORD, new ColumnVarChar("status", 100, "Sent"), new ColumnVarChar("name", 100, name), new ColumnVarChar("name", 100, caller.getName()));
|
||||
|
||||
if (rowsAffected > 0)
|
||||
return executeUpdate(ADD_FRIEND_RECORD, new ColumnVarChar("status", 100, "Pending"), new ColumnVarChar("name", 100, caller.getName()), new ColumnVarChar("uuid", 100, name)) > 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean removeFriendRecord(int recordId)
|
||||
public boolean updateFriend(String caller, String name, String status)
|
||||
{
|
||||
return executeUpdate(DELETE_FRIEND_RECORD, new ColumnInt("id", recordId)) > 0;
|
||||
return executeUpdate(UPDATE_MUTUAL_RECORD, new ColumnVarChar("status", 100, status), new ColumnVarChar("uuid", 100, name), new ColumnVarChar("name", 100, caller)) > 0;
|
||||
}
|
||||
|
||||
public boolean removeFriend(String caller, String name)
|
||||
{
|
||||
int rowsAffected = executeUpdate(DELETE_FRIEND_RECORD, new ColumnVarChar("name", 100, name), new ColumnVarChar("name", 100, caller));
|
||||
|
||||
if (rowsAffected > 0)
|
||||
return executeUpdate(DELETE_FRIEND_RECORD, new ColumnVarChar("name", 100, caller), new ColumnVarChar("uuid", 100, name)) > 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public NautHashMap<String, FriendData> getFriendsForAll(Player...players)
|
||||
@ -67,7 +84,7 @@ public class FriendRepository extends RepositoryBase
|
||||
final NautHashMap<String, FriendData> friends = new NautHashMap<String, FriendData>();
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
//stringBuilder.append(RETRIEVE_MULTIPLE_FRIEND_RECORDS + "(");
|
||||
stringBuilder.append(RETRIEVE_MULTIPLE_FRIEND_RECORDS + "(");
|
||||
|
||||
for (Player player : players)
|
||||
{
|
||||
|
@ -41,6 +41,23 @@ public class PunishCommand extends CommandBase<Punish>
|
||||
|
||||
final String finalReason = reason;
|
||||
|
||||
//Match exact online first
|
||||
Player target = UtilPlayer.searchExact(playerName);
|
||||
if (target != null)
|
||||
{
|
||||
Plugin.GetRepository().LoadPunishClient(playerName, new Callback<PunishClientToken>()
|
||||
{
|
||||
public void run(PunishClientToken clientToken)
|
||||
{
|
||||
Plugin.LoadClient(clientToken);
|
||||
new PunishPage(Plugin, caller, playerName, finalReason);
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//Check repo
|
||||
Plugin.GetRepository().MatchPlayerName(new Callback<List<String>>()
|
||||
{
|
||||
public void run(List<String> matches)
|
||||
|
@ -70,10 +70,10 @@ public class ServerStatusManager extends MiniPlugin
|
||||
getPlugin().getConfig().addDefault("serverstatus.connectionurl", "db.mineplex.com:3306");
|
||||
getPlugin().getConfig().set("serverstatus.connectionurl", getPlugin().getConfig().getString("serverstatus.connectionurl"));
|
||||
|
||||
getPlugin().getConfig().addDefault("serverstatus.username", "root");
|
||||
getPlugin().getConfig().addDefault("serverstatus.username", "MilitaryPolice");
|
||||
getPlugin().getConfig().set("serverstatus.username", getPlugin().getConfig().getString("serverstatus.username"));
|
||||
|
||||
getPlugin().getConfig().addDefault("serverstatus.password", "tAbechAk3wR7tuTh");
|
||||
getPlugin().getConfig().addDefault("serverstatus.password", "CUPr6Wuw2Rus$qap");
|
||||
getPlugin().getConfig().set("serverstatus.password", getPlugin().getConfig().getString("serverstatus.password"));
|
||||
|
||||
getPlugin().getConfig().addDefault("serverstatus.us", true);
|
||||
|
@ -4,8 +4,8 @@
|
||||
<jdbc>
|
||||
<driver>com.mysql.jdbc.Driver</driver>
|
||||
<url>jdbc:mysql://db.mineplex.com:3306</url>
|
||||
<user>root</user>
|
||||
<password>tAbechAk3wR7tuTh</password>
|
||||
<user>MilitaryPolice</user>
|
||||
<password>CUPr6Wuw2Rus$qap</password>
|
||||
</jdbc>
|
||||
|
||||
<generator>
|
||||
|
@ -50,7 +50,7 @@ public class SmokeArrow extends SkillActive
|
||||
SetDesc(new String[]
|
||||
{
|
||||
"Your next arrow will give Blindness",
|
||||
"to target for #4#1 seconds."
|
||||
"and Slow 2 to target for #3#1 seconds."
|
||||
});
|
||||
}
|
||||
|
||||
@ -127,6 +127,7 @@ public class SmokeArrow extends SkillActive
|
||||
//Confuse
|
||||
double dur = 3 + level;
|
||||
Factory.Condition().Factory().Blind(GetName(), damagee, damager, dur, 0, true, true, true);
|
||||
Factory.Condition().Factory().Slow(GetName(), damagee, damager, dur, 1, true, true, true, true);
|
||||
|
||||
//Effect
|
||||
damagee.getWorld().playSound(damagee.getLocation(), Sound.BLAZE_BREATH, 2.5f, 2.0f);
|
||||
|
@ -18,7 +18,7 @@ public class Colossus extends Skill
|
||||
SetDesc(new String[]
|
||||
{
|
||||
"You are so huge that you take",
|
||||
"#25#25 % less knockback from attacks."
|
||||
"#15#20 % less knockback from attacks."
|
||||
});
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ public class Colossus extends Skill
|
||||
|
||||
//Damage
|
||||
event.AddMod(damagee.getName(), GetName(), 0, false);
|
||||
event.AddKnockback(GetName(), 0.75 - 0.25*level);
|
||||
event.AddKnockback(GetName(), 0.85 - 0.20*level);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -38,6 +38,8 @@ public class DwarfToss extends SkillActive
|
||||
private NautHashMap<Player, LivingEntity> _holding = new NautHashMap<Player, LivingEntity>();
|
||||
private NautHashMap<Player, Long> _time = new NautHashMap<Player, Long>();
|
||||
|
||||
private long _chargeTime = 2500;
|
||||
|
||||
public DwarfToss(SkillFactory skills, String name, ClassType classType, SkillType skillType,
|
||||
int cost, int levels,
|
||||
int energy, int energyMod,
|
||||
@ -58,7 +60,9 @@ public class DwarfToss extends SkillActive
|
||||
"Release Block to throw with #1.2#0.2 velocity.",
|
||||
"",
|
||||
"Players you are holding cannot harm",
|
||||
"you, or be harmed by others."
|
||||
"you, or be harmed by others.",
|
||||
"",
|
||||
"Takes 2.5 seconds to fully charge."
|
||||
});
|
||||
}
|
||||
|
||||
@ -302,13 +306,20 @@ public class DwarfToss extends SkillActive
|
||||
for (final Player cur : throwSet)
|
||||
{
|
||||
final LivingEntity target = _holding.remove(cur);
|
||||
_time.remove(cur);
|
||||
long time = _time.remove(cur);
|
||||
int level = getLevel(cur);
|
||||
|
||||
//Time Reduce
|
||||
double timeScale = 1;
|
||||
if (time < _chargeTime)
|
||||
{
|
||||
timeScale = Math.max(0.25, ((double)time/(double)_chargeTime));
|
||||
}
|
||||
|
||||
//Throw
|
||||
cur.eject();
|
||||
target.leaveVehicle();
|
||||
final double mult = 1.2 + (0.2 * level);
|
||||
final double mult = (1.2 + (0.2 * level)) * timeScale;
|
||||
|
||||
//Delay
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Factory.getPlugin(), new Runnable()
|
||||
|
@ -108,7 +108,7 @@ public class FleshHook extends SkillActiveCharge implements IThrown
|
||||
1 + charge , false, 0, 0.2, 20, false);
|
||||
|
||||
Factory.Projectile().AddThrow(item, cur, this, -1, true, true, true,
|
||||
Sound.FIRE_IGNITE, 1.4f, 0.8f, ParticleType.CRIT, UpdateType.TICK, 1.2f);
|
||||
Sound.FIRE_IGNITE, 1.4f, 0.8f, ParticleType.CRIT, UpdateType.TICK, 0.6f);
|
||||
|
||||
//Inform
|
||||
UtilPlayer.message(cur, F.main(GetClassType().name(), "You used " + F.skill(GetName(level)) + "."));
|
||||
|
@ -91,7 +91,7 @@ public class AxeThrow extends SkillActive implements IThrown
|
||||
player.setItemInHand(null);
|
||||
|
||||
//Projectile
|
||||
Factory.Projectile().AddThrow(item, player, this, -1, true, true, true, false, 0.5f);
|
||||
Factory.Projectile().AddThrow(item, player, this, -1, true, true, true, false, 0.4f);
|
||||
|
||||
//Store
|
||||
_thrown.put(item, player);
|
||||
|
@ -40,7 +40,7 @@ public class DefensiveStance extends SkillActive
|
||||
|
||||
SetDesc(new String[]
|
||||
{
|
||||
"While Blocking, you are immune to all",
|
||||
"While Blocking, you take 75% less",
|
||||
"damage from attacks infront of you."
|
||||
});
|
||||
}
|
||||
@ -116,10 +116,7 @@ public class DefensiveStance extends SkillActive
|
||||
}
|
||||
|
||||
//Damage
|
||||
if (event.GetCause() == DamageCause.ENTITY_ATTACK)
|
||||
event.AddMult(GetName(), GetName(), 0.1, false);
|
||||
else
|
||||
event.SetCancelled(GetName() + " Defense");
|
||||
event.AddMult(GetName(), GetName(), 0.25, false);
|
||||
|
||||
//Effect
|
||||
damagee.getWorld().playSound(damagee.getLocation(), Sound.ZOMBIE_METAL, 1f, 2f);
|
||||
|
@ -45,7 +45,7 @@ public class ArcticArmor extends Skill
|
||||
"",
|
||||
"Create a freezing area around you",
|
||||
"in a #3#1 Block radius. Allies inside",
|
||||
"this area receive Protection 2.",
|
||||
"this area receive Protection 1.",
|
||||
"",
|
||||
"You are permanently immune to the",
|
||||
"Slowing effect of snow."
|
||||
@ -176,7 +176,7 @@ public class ArcticArmor extends Skill
|
||||
//Protection
|
||||
for (Player other : UtilPlayer.getNearby(cur.getLocation(), 3 + getLevel(cur)))
|
||||
if (!Factory.Relation().canHurt(cur, other) || other.equals(cur))
|
||||
Factory.Condition().Factory().Protection(GetName(), other, cur, 1.9, 1, false, true, true);
|
||||
Factory.Condition().Factory().Protection(GetName(), other, cur, 1.9, 0, false, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ public class GlacialBlade extends SkillActive implements IThrown
|
||||
Item item = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()).subtract(0, 0.2, 0), ItemStackFactory.Instance.CreateStack(370));
|
||||
UtilAction.velocity(item, player.getLocation().getDirection(), 1.6, false, 0, 0.2, 10, false);
|
||||
Factory.Projectile().AddThrow(item, player, this, -1, true, true, true,
|
||||
null, 0, 0, ParticleType.SNOW_SHOVEL, UpdateType.TICK, 0.4f);
|
||||
null, 0, 0, ParticleType.SNOW_SHOVEL, UpdateType.TICK, 0.3f);
|
||||
|
||||
//Effect
|
||||
item.getWorld().playSound(item.getLocation(), Sound.ORB_PICKUP, 1f, 2f);
|
||||
|
@ -48,7 +48,7 @@ public class IcePrison extends SkillActive implements IThrown
|
||||
{
|
||||
"Launch an icy orb. When it collides,",
|
||||
"it creates a hollow sphere of ice",
|
||||
"thats lasts for #1#1.5 seconds.",
|
||||
"thats lasts for #2#1 seconds.",
|
||||
});
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ public class IcePrison extends SkillActive implements IThrown
|
||||
if (!UtilBlock.airFoliage(freeze))
|
||||
return;
|
||||
|
||||
long time = 2500 + (1500 * level);
|
||||
long time = 2500 + (1000 * level);
|
||||
|
||||
int yDiff = freeze.getY() - mid.getY();
|
||||
|
||||
|
@ -78,8 +78,8 @@ public class LightningOrb extends SkillActive implements IThrown
|
||||
"Launch a lightning orb. Upon a direct",
|
||||
"hit with player, or #5#-0.4 seconds, it will",
|
||||
"strike all enemies within #3#0.5 Blocks ",
|
||||
"with lightning, giving them Slow 3",
|
||||
"for #2#1 seconds."
|
||||
"with lightning, giving them Slow 2",
|
||||
"for 4 seconds."
|
||||
});
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ public class LightningOrb extends SkillActive implements IThrown
|
||||
Item item = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), ItemStackFactory.Instance.CreateStack(57));
|
||||
item.setVelocity(player.getLocation().getDirection());
|
||||
Factory.Projectile().AddThrow(item, player, this, System.currentTimeMillis() + 5000 - (400 * level), true, false, false,
|
||||
Sound.FIZZ, 0.6f, 1.6f, ParticleType.FIREWORKS_SPARK, UpdateType.TICK, 1f);
|
||||
Sound.FIZZ, 0.6f, 1.6f, ParticleType.FIREWORKS_SPARK, UpdateType.TICK, 0.6f);
|
||||
|
||||
//Inform
|
||||
UtilPlayer.message(player, F.main(GetClassType().name(), "You used " + F.skill(GetName(level)) + "."));
|
||||
@ -179,7 +179,7 @@ public class LightningOrb extends SkillActive implements IThrown
|
||||
if (cur.equals(player))
|
||||
continue;
|
||||
|
||||
Factory.Condition().Factory().Slow(GetName(), cur, player, 2 + (1 * level), 2, false, true, true, true);
|
||||
Factory.Condition().Factory().Slow(GetName(), cur, player, 4, 1, false, true, true, true);
|
||||
}
|
||||
|
||||
Bukkit.getPluginManager().callEvent(new LightningOrbEvent(player, struck));
|
||||
|
@ -55,7 +55,7 @@ public class HealingShot extends SkillActive
|
||||
{
|
||||
"Prepare a healing shot;",
|
||||
"Your next arrow will give its target",
|
||||
"Regeneration 2 for #3#2 seconds,",
|
||||
"Regeneration 2 for #5#1 seconds,",
|
||||
"and remove all negative effects."
|
||||
});
|
||||
}
|
||||
|
@ -24,8 +24,12 @@ public class Longshot extends Skill
|
||||
|
||||
SetDesc(new String[]
|
||||
{
|
||||
"Arrows do an additional 1 damage", "for every #4#-0.5 Blocks they travelled,",
|
||||
"however, their base damage is", "reduced by 3.", "", "Maximum of #6#6 additional damage."
|
||||
"Arrows do an additional 1 damage",
|
||||
"for every #4#-0.5 Blocks they travelled,",
|
||||
"however, their base damage is",
|
||||
"reduced by 5.",
|
||||
"",
|
||||
"Maximum of #6#6 additional damage."
|
||||
});
|
||||
}
|
||||
|
||||
@ -70,7 +74,10 @@ public class Longshot extends Skill
|
||||
double length = UtilMath.offset(loc, projectile.getLocation());
|
||||
|
||||
// Damage
|
||||
double damage = Math.min(6 + 6 * level, (length / (4 - 0.5 * level)) - 3);
|
||||
double damage = Math.min(6 + 6 * level, (length / (4 - 0.5 * level)) - 5);
|
||||
|
||||
if (damage < 0)
|
||||
damage = 0;
|
||||
|
||||
event.AddMod(damager.getName(), GetName(), damage, damage > 0);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class WolfsPounce extends SkillChargeSword
|
||||
public void DoSkillCustom(Player player, float charge)
|
||||
{
|
||||
//Action
|
||||
UtilAction.velocity(player, 0.4 + (1.4*charge), 0.2, 0.2 + (0.7*charge), true);
|
||||
UtilAction.velocity(player, 0.4 + (1.4*charge), 0.2, 0.3 + (0.8*charge), true);
|
||||
_live.put(player, System.currentTimeMillis());
|
||||
|
||||
//Inform
|
||||
|
@ -142,7 +142,7 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory
|
||||
//Passive C
|
||||
AddSkill(new BreakFall(this, "Break Fall", ClassType.Global, SkillType.GlobalPassive, 1, 3));
|
||||
AddSkill(new Resistance(this, "Resistance", ClassType.Global, SkillType.GlobalPassive, 1, 3));
|
||||
AddSkill(new Cooldown(this, "Quick Recovery", ClassType.Global, SkillType.GlobalPassive, 1, 3));
|
||||
//AddSkill(new Cooldown(this, "Quick Recovery", ClassType.Global, SkillType.GlobalPassive, 1, 3));
|
||||
//AddSkill(new Rations(this, "Rations", ClassType.Global, SkillType.GlobalPassive, 1, 2));
|
||||
|
||||
AddSkill(new Fitness(this, "Mana Pool", ClassType.Mage, SkillType.GlobalPassive, 1, 3));
|
||||
@ -301,7 +301,7 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory
|
||||
AddSkill(new Riposte(this, "Riposte", ClassType.Knight, SkillType.Sword,
|
||||
1, 5,
|
||||
0, 0,
|
||||
10000, -1000, false,
|
||||
11000, -1000, false,
|
||||
new Material[] {Material.IRON_SWORD, Material.GOLD_SWORD, Material.DIAMOND_SWORD},
|
||||
new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK}));
|
||||
|
||||
@ -331,7 +331,7 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory
|
||||
AddSkill(new ShieldSmash(this, "Shield Smash", ClassType.Knight, SkillType.Axe,
|
||||
1, 5,
|
||||
0, 0,
|
||||
8000, -1000, true,
|
||||
10000, -1000, true,
|
||||
new Material[] {Material.IRON_AXE, Material.GOLD_AXE, Material.DIAMOND_AXE},
|
||||
new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK}));
|
||||
|
||||
@ -434,7 +434,7 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory
|
||||
AddSkill(new GlacialBlade(this, "Glacial Blade", ClassType.Mage, SkillType.PassiveB,
|
||||
1, 3,
|
||||
16, -2,
|
||||
1300, -300, false,
|
||||
1200, -200, false,
|
||||
new Material[] {Material.IRON_SWORD, Material.GOLD_SWORD, Material.DIAMOND_SWORD},
|
||||
new Action[] {Action.LEFT_CLICK_AIR, Action.LEFT_CLICK_BLOCK}));
|
||||
|
||||
@ -476,7 +476,7 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory
|
||||
AddSkill(new HealingShot(this, "Healing Shot", ClassType.Ranger, SkillType.Bow,
|
||||
1, 4,
|
||||
0, 0,
|
||||
20000, -2000, true,
|
||||
20000, -3000, true,
|
||||
new Material[] {Material.BOW},
|
||||
new Action[] {Action.LEFT_CLICK_AIR, Action.LEFT_CLICK_BLOCK}));
|
||||
|
||||
@ -504,7 +504,7 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory
|
||||
AddSkill(new RopedArrow(this, "Roped Arrow", ClassType.Ranger, SkillType.Bow,
|
||||
1, 4,
|
||||
0, 0,
|
||||
10000, -1500, false,
|
||||
9000, -1000, false,
|
||||
new Material[] {Material.BOW},
|
||||
new Action[] {Action.LEFT_CLICK_AIR, Action.LEFT_CLICK_BLOCK}));
|
||||
|
||||
|
@ -17,7 +17,6 @@ import mineplex.servermonitor.data.BungeeStatusData;
|
||||
public class StatusHistoryRepository
|
||||
{
|
||||
private String _connectionString = "jdbc:mysql://sqlstats.mineplex.com:3306/ServerStats";
|
||||
private String _bungeeConnectionString = "jdbc:mysql://db.mineplex.com:3306/BungeeServers";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
@ -47,9 +46,6 @@ public class StatusHistoryRepository
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
if (_bungeeconnection == null || _bungeeconnection.isClosed())
|
||||
_bungeeconnection = DriverManager.getConnection(_bungeeConnectionString, _userName, _password);
|
||||
|
||||
// Create table
|
||||
preparedStatement = _connection.prepareStatement(CREATE_GROUP_TABLE);
|
||||
preparedStatement.execute();
|
||||
@ -189,6 +185,7 @@ public class StatusHistoryRepository
|
||||
|
||||
public void saveNetworkStats(double usedCpuPercent, double usedRamPercent, double availableCPU, double availableRAM, Region region)
|
||||
{
|
||||
/*
|
||||
int totalPlayers = 0;
|
||||
|
||||
List<BungeeStatusData> bungeeStatuses = new ArrayList<BungeeStatusData>();
|
||||
@ -318,5 +315,6 @@ public class StatusHistoryRepository
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
@ -1191,7 +1191,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
|
||||
if (type != Material.GOLDEN_APPLE &&
|
||||
type != Material.GOLDEN_CARROT &&
|
||||
type != Material.FLINT_AND_STEEL)
|
||||
type != Material.FLINT_AND_STEEL && type != Material.HOPPER)
|
||||
return;
|
||||
|
||||
if (!(event.getInventory() instanceof CraftingInventory))
|
||||
|
Loading…
Reference in New Issue
Block a user