Removed BungeeSigns
Updated Bungee plugin to pull US servers only. Added dynamic MOTD from mysql for BungeeCord.jar Fixed crash for disguise block arm animation.
This commit is contained in:
parent
70dae64389
commit
41e9ffb018
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre7"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/BungeeCord.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -1,17 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Mineplex.Bungee.BungeeSigns</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -1,11 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
|
@ -1,4 +0,0 @@
|
|||
name: BungeeSigns
|
||||
main: mineplex.bungee.BungeeSigns.BungeeSigns
|
||||
version: 1
|
||||
author: defek7
|
|
@ -10,7 +10,7 @@
|
|||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value=""/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${BUILD_FILES}\common.xml"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${BUILD_FILES}/common.xml"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/>
|
||||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/Mineplex.Bungee.Mineplexer}"/>
|
|
@ -4,8 +4,8 @@ import java.io.DataInputStream;
|
|||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import mineplex.bungee.bungeeSigns.BungeeSigns;
|
||||
import mineplex.bungee.lobbyBalancer.LobbyBalancer;
|
||||
import mineplex.bungee.motd.MotdManager;
|
||||
import mineplex.bungee.playerCount.PlayerCount;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
|
@ -14,9 +14,8 @@ public class Mineplexer extends Plugin
|
|||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
new BungeeSigns(this);
|
||||
|
||||
//_dynamicServers = new GlobalServer(this);
|
||||
new MotdManager(this);
|
||||
new LobbyBalancer(this);
|
||||
new PlayerCount(this);
|
||||
|
||||
|
|
|
@ -1,223 +0,0 @@
|
|||
package mineplex.bungee.bungeeSigns;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutput;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.ConnectException;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketTimeoutException;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.Connection;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.protocol.packet.PacketFAPluginMessage;
|
||||
|
||||
public class BungeeSigns implements Listener
|
||||
{
|
||||
private Plugin _plugin;
|
||||
|
||||
public BungeeSigns(Plugin plugin)
|
||||
{
|
||||
_plugin = plugin;
|
||||
|
||||
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
|
||||
_plugin.getProxy().registerChannel("BungeeSigns");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void ReceiveServerRequest(final PluginMessageEvent event)
|
||||
{
|
||||
if (event.getTag().equals("BungeeSigns"))
|
||||
{
|
||||
DataInputStream in = null;
|
||||
|
||||
try
|
||||
{
|
||||
in = new DataInputStream(new ByteArrayInputStream(event.getData()));
|
||||
final ServerInfo serverInfo = _plugin.getProxy().getServerInfo(in.readUTF());
|
||||
|
||||
in.close();
|
||||
|
||||
if (serverInfo != null)
|
||||
{
|
||||
new Thread() {
|
||||
public void run()
|
||||
{
|
||||
SendServerInfo(serverInfo, event.getSender());
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
System.out.println("[BungeeSigns] Error retrieving serverInfo.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if (in != null)
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void SendServerInfo(ServerInfo serverInfo, Connection sender)
|
||||
{
|
||||
Socket socket = null;
|
||||
DataInputStream dataInputStream = null;
|
||||
DataOutputStream dataOutputStream = null;
|
||||
|
||||
try
|
||||
{
|
||||
socket = new Socket();
|
||||
socket.setSoTimeout(3000);
|
||||
socket.setTcpNoDelay(true);
|
||||
socket.setTrafficClass(18);
|
||||
socket.connect(serverInfo.getAddress(), 3000);
|
||||
dataInputStream = new DataInputStream(socket.getInputStream());
|
||||
dataOutputStream = new DataOutputStream(socket.getOutputStream());
|
||||
|
||||
dataOutputStream.writeByte(254);
|
||||
dataOutputStream.writeByte(1);
|
||||
dataOutputStream.writeByte(254);
|
||||
writeString("MC|PingHost", dataOutputStream);
|
||||
dataOutputStream.writeShort(3 + 2 * serverInfo.getAddress().getHostString().length() + 4);
|
||||
dataOutputStream.writeByte(74);
|
||||
writeString(serverInfo.getAddress().getHostString(), dataOutputStream);
|
||||
dataOutputStream.writeInt(serverInfo.getAddress().getPort());
|
||||
|
||||
if (dataInputStream.read() != 255)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String var6 = readString(dataInputStream, 256);
|
||||
|
||||
String[] var27;
|
||||
|
||||
if (var6.startsWith("\u00a7") && var6.length() > 1)
|
||||
{
|
||||
var27 = var6.substring(1).split("\u0000");
|
||||
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
|
||||
out.writeUTF(serverInfo.getName());
|
||||
out.writeUTF(var27[3]);
|
||||
out.writeInt(Integer.parseInt(var27[4]));
|
||||
out.writeInt(Integer.parseInt(var27[5]));
|
||||
|
||||
byte[] b = out.toByteArray();
|
||||
|
||||
if (b.length != 0)
|
||||
{
|
||||
sender.unsafe().sendPacket(new PacketFAPluginMessage("BungeeSigns", b));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SocketTimeoutException e)
|
||||
{
|
||||
;
|
||||
}
|
||||
catch (ConnectException e)
|
||||
{
|
||||
;
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
System.out.println("[BungeeSigns] Error pinging " + serverInfo.getName() + "(" + serverInfo.getAddress().getHostString() + ":" + serverInfo.getAddress().getPort());
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if (dataInputStream != null)
|
||||
{
|
||||
dataInputStream.close();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (dataOutputStream != null)
|
||||
{
|
||||
dataOutputStream.close();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (socket != null)
|
||||
{
|
||||
socket.close();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeString(String par0Str, DataOutput par1DataOutput) throws IOException
|
||||
{
|
||||
if (par0Str.length() > 32767)
|
||||
{
|
||||
throw new IOException("String too big");
|
||||
}
|
||||
else
|
||||
{
|
||||
par1DataOutput.writeShort(par0Str.length());
|
||||
par1DataOutput.writeChars(par0Str);
|
||||
}
|
||||
}
|
||||
|
||||
public static String readString(DataInput par0DataInput, int par1) throws IOException
|
||||
{
|
||||
short var2 = par0DataInput.readShort();
|
||||
|
||||
if (var2 > par1)
|
||||
{
|
||||
throw new IOException("Received string length longer than maximum allowed (" + var2 + " > " + par1 + ")");
|
||||
}
|
||||
else if (var2 < 0)
|
||||
{
|
||||
throw new IOException("Received string length is less than zero! Weird string!");
|
||||
}
|
||||
else
|
||||
{
|
||||
StringBuilder var3 = new StringBuilder();
|
||||
|
||||
for (int var4 = 0; var4 < var2; ++var4)
|
||||
{
|
||||
var3.append(par0DataInput.readChar());
|
||||
}
|
||||
|
||||
return var3.toString();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,7 +27,7 @@ public class LobbyBalancer implements Listener, Runnable
|
|||
{
|
||||
_plugin = plugin;
|
||||
_repository = new LobbyBalancerRepository();
|
||||
_repository.initialize();
|
||||
_repository.initialize(true);
|
||||
|
||||
loadLobbyServers();
|
||||
|
||||
|
|
|
@ -13,12 +13,15 @@ public class LobbyBalancerRepository
|
|||
private String _connectionString = "jdbc:mysql://sql.mineplex.com:3306/ServerStatus";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
private boolean _us;
|
||||
|
||||
private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS ServerStatus (id INT NOT NULL AUTO_INCREMENT, serverName VARCHAR(256), serverGroup VARCHAR(256), address VARCHAR(256), updated LONG, motd VARCHAR(256), players INT, maxPlayers INT, tps INT, ram INT, maxRam INT, PRIMARY KEY (id));";
|
||||
private static String RETRIEVE_SERVER_STATUSES = "SELECT serverName, address, motd, players, maxPlayers FROM ServerStatus WHERE TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) < 10;";
|
||||
private static String RETRIEVE_SERVER_STATUSES = "SELECT ServerStatus.serverName, ServerStatus.address, motd, players, maxPlayers FROM ServerStatus INNER JOIN DynamicServers ON ServerStatus.address LIKE CONCAT(DynamicServers.address, '%') WHERE DynamicServers.US = ? AND TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) < 10;";
|
||||
|
||||
public void initialize()
|
||||
public void initialize(boolean us)
|
||||
{
|
||||
_us = us;
|
||||
|
||||
Connection connection = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
|
@ -74,6 +77,8 @@ public class LobbyBalancerRepository
|
|||
connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = connection.prepareStatement(RETRIEVE_SERVER_STATUSES);
|
||||
preparedStatement.setBoolean(1, _us);
|
||||
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
|
||||
while (resultSet.next())
|
||||
|
|
|
@ -14,7 +14,7 @@ public class PlayerCountRepository
|
|||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS BungeeServers (id INT NOT NULL AUTO_INCREMENT, address VARCHAR(256), updated LONG, players INT, maxPlayers INT, ram INT, maxRam INT, PRIMARY KEY (id));";
|
||||
private static String INSERT_PLAYER_COUNT = "INSERT INTO BungeeServers values(default, ?, now(), ?, ?, ?, ?);";
|
||||
private static String INSERT_PLAYER_COUNT = "INSERT INTO BungeeServers(address, updated, players, maxPlayers, ram, maxRam) values(?, now(), ?, ?, ?, ?);";
|
||||
private static String UPDATE_PLAYER_COUNT = "UPDATE BungeeServers SET updated = now(), players = ?, maxPlayers = ?, ram = ?, maxRam = ? WHERE id = ?;";
|
||||
private static String RETRIEVE_ID = "SELECT id FROM BungeeServers WHERE address = ?;";
|
||||
private static String RETRIEVE_PLAYER_COUNT = "SELECT SUM(players) AS playerCount, SUM(maxPlayers) AS maxPlayerCount FROM BungeeServers WHERE TIME_TO_SEC(TIMEDIFF(now(), BungeeServers.updated)) < 10;";
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.Map.Entry;
|
|||
import net.minecraft.server.v1_6_R3.ChunkAddEntityEvent;
|
||||
import net.minecraft.server.v1_6_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_6_R3.Packet;
|
||||
import net.minecraft.server.v1_6_R3.Packet18ArmAnimation;
|
||||
import net.minecraft.server.v1_6_R3.Packet20NamedEntitySpawn;
|
||||
import net.minecraft.server.v1_6_R3.Packet24MobSpawn;
|
||||
import net.minecraft.server.v1_6_R3.Packet28EntityVelocity;
|
||||
|
@ -302,6 +303,15 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
|
|||
return false;
|
||||
}
|
||||
}
|
||||
else if (packet instanceof Packet18ArmAnimation)
|
||||
{
|
||||
int entityId = ((Packet18ArmAnimation)packet).a;
|
||||
|
||||
if (_spawnPacketMap.containsKey(entityId) && owner.getEntityId() != entityId)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (packet instanceof Packet40EntityMetadata)
|
||||
{
|
||||
int entityId = ((Packet40EntityMetadata)packet).a;
|
||||
|
|
|
@ -16,11 +16,11 @@ public class ServerStatusRepository
|
|||
private String _password;
|
||||
|
||||
private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS ServerStatus (id INT NOT NULL AUTO_INCREMENT, serverName VARCHAR(256), serverGroup VARCHAR(256), address VARCHAR(256), updated LONG, lastTimeWithPlayers LONG, motd VARCHAR(256), players INT, maxPlayers INT, tps INT, ram INT, maxRam INT, PRIMARY KEY (id));";
|
||||
private static String INSERT_PLAYER_COUNT = "INSERT INTO ServerStatus (serverName, serverGroup, address, updated, motd, players, maxPlayers, tps, ram, maxRam) values(default, ?, ?, ?, now(), 'Configuring server.', ?, ?, 0, ?, ?);";
|
||||
private static String INSERT_PLAYER_COUNT = "INSERT INTO ServerStatus (serverName, serverGroup, address, updated, motd, players, maxPlayers, tps, ram, maxRam) values(?, ?, ?, now(), 'Configuring server.', ?, ?, 0, ?, ?);";
|
||||
private static String UPDATE_PLAYER_COUNT_WITH_PLAYERS = "UPDATE ServerStatus SET updated = now(), serverName = ?, serverGroup = ?, motd = ?, players = ?, maxPlayers = ?, tps = ?, ram = ?, maxRam = ?, lastTimeWithPlayers = now() WHERE id = ?;";
|
||||
private static String UPDATE_PLAYER_COUNT_WITHOUT_PLAYERS = "UPDATE ServerStatus SET updated = now(), serverName = ?, serverGroup = ?, motd = ?, players = ?, maxPlayers = ?, tps = ?, ram = ?, maxRam = ? WHERE id = ?;";
|
||||
private static String RETRIEVE_ID = "SELECT id FROM ServerStatus WHERE address = ?;";
|
||||
private static String RETRIEVE_SERVER_STATUSES = "SELECT serverName, motd, players, maxPlayers FROM ServerStatus WHERE TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) < 10;";
|
||||
private static String RETRIEVE_SERVER_STATUSES = "SELECT serverName, motd, players, maxPlayers FROM ServerStatus INNER JOIN DynamicServers ON ServerStatus.address LIKE CONCAT(DynamicServers.address, '%') WHERE DynamicServers.US = 'true' AND TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) < 10;";
|
||||
|
||||
private int _id = -1;
|
||||
private String _serverName;
|
||||
|
|
|
@ -79,6 +79,7 @@ public class ServerMonitor
|
|||
|
||||
int serversToAdd = Math.max(serverGroup.RequiredTotalServers - groupStatus.getTotalServers(), serverGroup.RequiredJoinableServers - groupStatus.getJoinableCount());
|
||||
int serversToKill = groupStatus.EmptyServers.size() - serverGroup.RequiredJoinableServers;
|
||||
int serverNum = groupStatus.getTotalServers() + 1;
|
||||
|
||||
if (serversToAdd > 0)
|
||||
{
|
||||
|
@ -98,10 +99,10 @@ public class ServerMonitor
|
|||
|
||||
try
|
||||
{
|
||||
process = new ProcessBuilder(new String[] {"/bin/sh", "-x", cmd, bestServer.Address, serverGroup.Prefix + "-" + (groupStatus.getTotalServers() + 1)}).start();
|
||||
process = new ProcessBuilder(new String[] {"/bin/sh", "-x", cmd, bestServer.Address, serverGroup.ScriptName, serverGroup.Prefix + "-" + serverNum, "1"}).start();
|
||||
process.waitFor();
|
||||
BufferedReader reader=new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
String line = reader.readLine();
|
||||
String line = reader.readLine();
|
||||
|
||||
while(line != null)
|
||||
{
|
||||
|
@ -124,6 +125,7 @@ public class ServerMonitor
|
|||
bestServer.setServerGroupCount(serverGroup, bestServer.ServerGroupCount.containsKey(serverGroup.Name) ? (bestServer.ServerGroupCount.get(serverGroup.Name) + 1) : 1);
|
||||
System.out.println("Sent start command to " + bestServer.Address + " for " + serverGroup.Prefix + "-" + (groupStatus.getTotalServers() + 1));
|
||||
serversToAdd--;
|
||||
serverNum++;
|
||||
}
|
||||
}
|
||||
else if (serversToKill > 0)
|
||||
|
|
Loading…
Reference in New Issue