Fixed dominate start issues.
Fixed issue with server status manager and config for server tracker. Changed minekart mob name. Updated Minekart with new server status stuff. Updated Dominate with new server status stuff.
This commit is contained in:
parent
ae00d3df18
commit
978254c16c
@ -1,31 +1,90 @@
|
|||||||
package mineplex.bungee;
|
package mineplex.bungee;
|
||||||
|
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.net.Socket;
|
||||||
|
|
||||||
import mineplex.bungee.bungeeSigns.BungeeSigns;
|
import mineplex.bungee.bungeeSigns.BungeeSigns;
|
||||||
import mineplex.bungee.dynamicServer.DynamicServer;
|
import mineplex.bungee.globalServer.GlobalServer;
|
||||||
import mineplex.bungee.lobbyBalancer.LobbyBalancer;
|
import mineplex.bungee.lobbyBalancer.LobbyBalancer;
|
||||||
import mineplex.bungee.playerCount.PlayerCount;
|
import mineplex.bungee.playerCount.PlayerCount;
|
||||||
import mineplex.bungee.updater.Updater;
|
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
|
|
||||||
public class Mineplexer extends Plugin
|
public class Mineplexer extends Plugin
|
||||||
{
|
{
|
||||||
private DynamicServer _dynamicServers;
|
private GlobalServer _dynamicServers;
|
||||||
private LobbyBalancer _lobbyBalancer;
|
private LobbyBalancer _lobbyBalancer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable()
|
public void onEnable()
|
||||||
{
|
{
|
||||||
new BungeeSigns(this);
|
new BungeeSigns(this);
|
||||||
new Updater(this);
|
|
||||||
|
|
||||||
_dynamicServers = new DynamicServer(this);
|
//_dynamicServers = new GlobalServer(this);
|
||||||
_lobbyBalancer = new LobbyBalancer(this);
|
_lobbyBalancer = new LobbyBalancer(this);
|
||||||
new PlayerCount(this);
|
new PlayerCount(this);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Socket socket = null;
|
||||||
|
DataInputStream dataInputStream = null;
|
||||||
|
DataOutputStream dataOutputStream = null;
|
||||||
|
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
socket = new Socket();
|
||||||
|
socket.setSoTimeout(3000);
|
||||||
|
socket.setTcpNoDelay(true);
|
||||||
|
socket.setTrafficClass(18);
|
||||||
|
socket.connect(new InetSocketAddress("192.95.30.130", 4444));
|
||||||
|
dataInputStream = new DataInputStream(socket.getInputStream());
|
||||||
|
dataOutputStream = new DataOutputStream(socket.getOutputStream());
|
||||||
|
|
||||||
|
dataOutputStream.writeShort(71);
|
||||||
|
writeString("defek7", dataOutputStream);
|
||||||
|
|
||||||
|
dataInputStream.read();
|
||||||
|
System.out.println(dataInputStream.readByte());
|
||||||
|
System.out.println(readString(dataInputStream, 16));
|
||||||
|
System.out.println(readString(dataInputStream, 24));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReloadServerLists()
|
protected String readString(DataInputStream dataInputStream, int maxLength) throws IOException
|
||||||
{
|
{
|
||||||
_dynamicServers.LoadServers();
|
short length = dataInputStream.readShort();
|
||||||
_lobbyBalancer.loadLobbyServers();
|
|
||||||
}
|
if (length > maxLength)
|
||||||
|
{
|
||||||
|
throw new IOException("Received string length longer than maximum allowed (" + length + " > " + maxLength + ")");
|
||||||
|
}
|
||||||
|
else if (length < 0)
|
||||||
|
{
|
||||||
|
throw new IOException("Received string length is less than zero! Weird string!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
|
||||||
|
for (int i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
stringBuilder.append(dataInputStream.readChar());
|
||||||
|
}
|
||||||
|
|
||||||
|
return stringBuilder.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void writeString(String string, DataOutputStream dataOutputStream) throws IOException
|
||||||
|
{
|
||||||
|
dataOutputStream.writeShort(string.length());
|
||||||
|
dataOutputStream.writeChars(string);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,89 +0,0 @@
|
|||||||
package mineplex.bungee.dynamicServer;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
|
||||||
|
|
||||||
public class DynamicServer implements Listener
|
|
||||||
{
|
|
||||||
private Plugin _plugin;
|
|
||||||
|
|
||||||
public DynamicServer(Plugin plugin)
|
|
||||||
{
|
|
||||||
_plugin = plugin;
|
|
||||||
|
|
||||||
LoadServers();
|
|
||||||
|
|
||||||
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LoadServers()
|
|
||||||
{
|
|
||||||
FileInputStream fstream = null;
|
|
||||||
BufferedReader br = null;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
File npcFile = new File("servers.dat");
|
|
||||||
|
|
||||||
if (npcFile.exists())
|
|
||||||
{
|
|
||||||
fstream = new FileInputStream(npcFile);
|
|
||||||
br = new BufferedReader(new InputStreamReader(fstream));
|
|
||||||
|
|
||||||
String line = br.readLine();
|
|
||||||
|
|
||||||
while (line != null)
|
|
||||||
{
|
|
||||||
String name = line.split(",")[0];
|
|
||||||
String address = line.split(",")[1].split(":")[0];
|
|
||||||
Integer port = Integer.parseInt(line.split(",")[1].split(":")[1]);
|
|
||||||
InetSocketAddress socketAddress = new InetSocketAddress(address, port);
|
|
||||||
|
|
||||||
_plugin.getProxy().getServers().put(name, _plugin.getProxy().constructServerInfo(name, socketAddress, "DynamicServer", false));
|
|
||||||
line = br.readLine();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
npcFile.createNewFile();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
System.out.println("Error parsing servers file.");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (br != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
br.close();
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fstream != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
fstream.close();
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +1,6 @@
|
|||||||
package mineplex.bungee.lobbyBalancer;
|
package mineplex.bungee.lobbyBalancer;
|
||||||
|
|
||||||
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.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.Socket;
|
|
||||||
import java.net.SocketTimeoutException;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -21,6 +13,7 @@ import net.md_5.bungee.event.EventHandler;
|
|||||||
public class LobbyBalancer implements Listener, Runnable
|
public class LobbyBalancer implements Listener, Runnable
|
||||||
{
|
{
|
||||||
private Plugin _plugin;
|
private Plugin _plugin;
|
||||||
|
private LobbyBalancerRepository _repository;
|
||||||
private HashMap<String, Integer> _lobbyServers = new HashMap<String, Integer>();
|
private HashMap<String, Integer> _lobbyServers = new HashMap<String, Integer>();
|
||||||
|
|
||||||
private String _bestServer = "Lobby";
|
private String _bestServer = "Lobby";
|
||||||
@ -30,11 +23,13 @@ public class LobbyBalancer implements Listener, Runnable
|
|||||||
public LobbyBalancer(Plugin plugin)
|
public LobbyBalancer(Plugin plugin)
|
||||||
{
|
{
|
||||||
_plugin = plugin;
|
_plugin = plugin;
|
||||||
|
_repository = new LobbyBalancerRepository();
|
||||||
|
_repository.initialize();
|
||||||
|
|
||||||
loadLobbyServers();
|
loadLobbyServers();
|
||||||
|
|
||||||
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
|
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
|
||||||
_plugin.getProxy().getScheduler().schedule(_plugin, this, 1L, 1L, TimeUnit.SECONDS);
|
_plugin.getProxy().getScheduler().schedule(_plugin, this, 4L, 4L, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -48,20 +43,10 @@ public class LobbyBalancer implements Listener, Runnable
|
|||||||
|
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
|
loadLobbyServers();
|
||||||
|
|
||||||
synchronized (_serverLock)
|
synchronized (_serverLock)
|
||||||
{
|
{
|
||||||
for (String name : _lobbyServers.keySet())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
UpdateServerCount(name);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String bestServer = null;
|
String bestServer = null;
|
||||||
Entry<String, Integer> leastPlayerServer = null;
|
Entry<String, Integer> leastPlayerServer = null;
|
||||||
|
|
||||||
@ -84,7 +69,7 @@ public class LobbyBalancer implements Listener, Runnable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_lobbyServers.get(bestServer) > 80)
|
if (_lobbyServers.containsKey(bestServer) && _lobbyServers.get(bestServer) > 80)
|
||||||
{
|
{
|
||||||
bestServer = leastPlayerServer.getKey();
|
bestServer = leastPlayerServer.getKey();
|
||||||
}
|
}
|
||||||
@ -93,163 +78,18 @@ public class LobbyBalancer implements Listener, Runnable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void UpdateServerCount(String name) throws IOException
|
|
||||||
{
|
|
||||||
InetSocketAddress address = _plugin.getProxy().getServerInfo(name).getAddress();
|
|
||||||
|
|
||||||
Socket socket = null;
|
|
||||||
DataInputStream dataInputStream = null;
|
|
||||||
DataOutputStream dataOutputStream = null;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
socket = new Socket();
|
|
||||||
socket.setSoTimeout(3000);
|
|
||||||
socket.setTcpNoDelay(true);
|
|
||||||
socket.setTrafficClass(18);
|
|
||||||
socket.connect(address, 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 * address.getAddress().getHostName().length() + 4);
|
|
||||||
dataOutputStream.writeByte(73);
|
|
||||||
writeString(address.getAddress().getHostName(), dataOutputStream);
|
|
||||||
dataOutputStream.writeInt(address.getPort());
|
|
||||||
|
|
||||||
if (dataInputStream.read() != 255)
|
|
||||||
{
|
|
||||||
System.out.println("not 255");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String var6 = readString(dataInputStream, 256);
|
|
||||||
|
|
||||||
String[] var27;
|
|
||||||
|
|
||||||
if (var6.startsWith("\u00a7") && var6.length() > 1)
|
|
||||||
{
|
|
||||||
var27 = var6.substring(1).split("\u0000");
|
|
||||||
|
|
||||||
synchronized (_serverLock)
|
|
||||||
{
|
|
||||||
if (var27[3].contains("Restarting"))
|
|
||||||
_lobbyServers.put(name, 999);
|
|
||||||
else
|
|
||||||
_lobbyServers.put(name, Integer.parseInt(var27[4]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SocketTimeoutException e)
|
|
||||||
{
|
|
||||||
synchronized (_serverLock)
|
|
||||||
{
|
|
||||||
_lobbyServers.put(name, 999);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (ConnectException e)
|
|
||||||
{
|
|
||||||
synchronized (_serverLock)
|
|
||||||
{
|
|
||||||
_lobbyServers.put(name, 999);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
System.out.println("[LobbyBalancer IOException] Error pinging " + address.getHostString() + ":" + address.getPort());
|
|
||||||
synchronized (_serverLock)
|
|
||||||
{
|
|
||||||
_lobbyServers.put(name, 999);
|
|
||||||
}
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadLobbyServers()
|
public void loadLobbyServers()
|
||||||
{
|
{
|
||||||
synchronized (_serverLock)
|
synchronized (_serverLock)
|
||||||
{
|
{
|
||||||
_lobbyServers.clear();
|
_lobbyServers.clear();
|
||||||
|
|
||||||
|
for (ServerStatusData serverStatusData : _repository.retrieveServerStatuses())
|
||||||
|
{
|
||||||
|
InetSocketAddress socketAddress = new InetSocketAddress(serverStatusData.Address, serverStatusData.Port);
|
||||||
|
_plugin.getProxy().getServers().put(serverStatusData.Name, _plugin.getProxy().constructServerInfo(serverStatusData.Name, socketAddress, "DynamicServer", false));
|
||||||
|
}
|
||||||
|
|
||||||
for (String key : _plugin.getProxy().getServers().keySet())
|
for (String key : _plugin.getProxy().getServers().keySet())
|
||||||
{
|
{
|
||||||
if (key.toUpperCase().contains("LOBBY"))
|
if (key.toUpperCase().contains("LOBBY"))
|
||||||
|
@ -1,193 +0,0 @@
|
|||||||
package mineplex.bungee.updater;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FilenameFilter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
|
|
||||||
import mineplex.bungee.Mineplexer;
|
|
||||||
|
|
||||||
public class Updater implements Runnable
|
|
||||||
{
|
|
||||||
private Mineplexer _plugin;
|
|
||||||
private HashMap<String, String> _jarMd5Map = new HashMap<String, String>();
|
|
||||||
private File _updateDirectory;
|
|
||||||
|
|
||||||
private boolean _enabled = true;
|
|
||||||
private boolean _needUpdate = false;
|
|
||||||
|
|
||||||
public Updater(Mineplexer plugin)
|
|
||||||
{
|
|
||||||
_plugin = plugin;
|
|
||||||
_jarMd5Map = new HashMap<String, String>();
|
|
||||||
|
|
||||||
getCurrentMd5s();
|
|
||||||
|
|
||||||
boolean windows = System.getProperty("os.name").startsWith("Windows");
|
|
||||||
|
|
||||||
_updateDirectory = new File((windows ? "C:" : File.separator + "home" + File.separator + "mineplex") + File.separator + "update" + File.separator + "bungee");
|
|
||||||
|
|
||||||
_updateDirectory.mkdirs();
|
|
||||||
|
|
||||||
if (new File("IgnoreUpdates.dat").exists())
|
|
||||||
_enabled = false;
|
|
||||||
|
|
||||||
if (_enabled)
|
|
||||||
_plugin.getProxy().getScheduler().schedule(_plugin, this, 1L, 1L, TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void getCurrentMd5s()
|
|
||||||
{
|
|
||||||
File currentDir = new File(".");
|
|
||||||
|
|
||||||
FilenameFilter statsFilter = new FilenameFilter()
|
|
||||||
{
|
|
||||||
public boolean accept(File paramFile, String paramString)
|
|
||||||
{
|
|
||||||
if (paramString.endsWith("dat"))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
for (File f : currentDir.listFiles(statsFilter))
|
|
||||||
{
|
|
||||||
FileInputStream fis = null;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
fis = new FileInputStream(f);
|
|
||||||
_jarMd5Map.put(f.getName(), DigestUtils.md5Hex(fis));
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
System.out.println("Updater: Error parsing dat md5's");
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (fis != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
fis.close();
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
FilenameFilter statsFilter = new FilenameFilter()
|
|
||||||
{
|
|
||||||
public boolean accept(File paramFile, String paramString)
|
|
||||||
{
|
|
||||||
if (paramString.endsWith("dat"))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
for (File f : _updateDirectory.listFiles(statsFilter))
|
|
||||||
{
|
|
||||||
FileInputStream fis = null;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_jarMd5Map.containsKey(f.getName()))
|
|
||||||
{
|
|
||||||
fis = new FileInputStream(f);
|
|
||||||
String md5 = DigestUtils.md5Hex(fis);
|
|
||||||
|
|
||||||
if (!md5.equals(_jarMd5Map.get(f.getName())))
|
|
||||||
{
|
|
||||||
_needUpdate = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
System.out.println("Updater: Error parsing dat md5's");
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (fis != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
fis.close();
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_needUpdate)
|
|
||||||
{
|
|
||||||
updateFiles();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateFiles()
|
|
||||||
{
|
|
||||||
_needUpdate = false;
|
|
||||||
|
|
||||||
boolean windows = System.getProperty("os.name").startsWith("Windows");
|
|
||||||
|
|
||||||
File updateDir = new File((windows ? "C:" : File.separator + "home" + File.separator + "mineplex") + File.separator + "update" + File.separator + "bungee");
|
|
||||||
File currentDir = new File(".");
|
|
||||||
|
|
||||||
updateDir.mkdirs();
|
|
||||||
|
|
||||||
FilenameFilter statsFilter = new FilenameFilter()
|
|
||||||
{
|
|
||||||
public boolean accept(File paramFile, String paramString)
|
|
||||||
{
|
|
||||||
if (paramString.endsWith("dat"))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
for (File f : updateDir.listFiles(statsFilter))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
FileUtils.copyFileToDirectory(f, currentDir);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
System.out.println("Updater: Error updating dats");
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getCurrentMd5s();
|
|
||||||
_plugin.ReloadServerLists();
|
|
||||||
System.out.println("Updater: Updated with new dat files.");
|
|
||||||
}
|
|
||||||
}
|
|
@ -52,6 +52,9 @@ public class ServerStatusManager extends MiniPlugin
|
|||||||
FileConfiguration yamlConfig = new YamlConfiguration();
|
FileConfiguration yamlConfig = new YamlConfiguration();
|
||||||
File serverTrackerConfig = new File("plugins/ServerTracker/config.yml");
|
File serverTrackerConfig = new File("plugins/ServerTracker/config.yml");
|
||||||
|
|
||||||
|
if (!serverTrackerConfig.exists())
|
||||||
|
return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
yamlConfig.load(serverTrackerConfig);
|
yamlConfig.load(serverTrackerConfig);
|
||||||
|
@ -232,7 +232,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
|||||||
{
|
{
|
||||||
if (((LivingEntity)entity).getCustomName().equalsIgnoreCase("play minekart plz"))
|
if (((LivingEntity)entity).getCustomName().equalsIgnoreCase("play minekart plz"))
|
||||||
{
|
{
|
||||||
_disguiseManager.disguise(new DisguisePlayer(entity, "Play " + ChatColor.YELLOW + "MineKart"));
|
_disguiseManager.disguise(new DisguisePlayer(entity, ChatColor.YELLOW + "MineKart"));
|
||||||
}
|
}
|
||||||
else if (((LivingEntity)entity).getCustomName().equalsIgnoreCase("defek7"))
|
else if (((LivingEntity)entity).getCustomName().equalsIgnoreCase("defek7"))
|
||||||
_disguiseManager.disguise(new DisguisePlayer(entity, "defek7"));
|
_disguiseManager.disguise(new DisguisePlayer(entity, "defek7"));
|
||||||
|
@ -16,6 +16,7 @@ import me.chiss.Core.MemoryFix.MemoryFix;
|
|||||||
import me.chiss.Core.Module.ModuleManager;
|
import me.chiss.Core.Module.ModuleManager;
|
||||||
import me.chiss.Core.Modules.*;
|
import me.chiss.Core.Modules.*;
|
||||||
import mineplex.core.message.MessageManager;
|
import mineplex.core.message.MessageManager;
|
||||||
|
import mineplex.core.monitor.LagMeter;
|
||||||
import mineplex.core.movement.Movement;
|
import mineplex.core.movement.Movement;
|
||||||
import mineplex.core.npc.NpcManager;
|
import mineplex.core.npc.NpcManager;
|
||||||
import mineplex.core.packethandler.PacketHandler;
|
import mineplex.core.packethandler.PacketHandler;
|
||||||
@ -27,6 +28,7 @@ import mineplex.core.server.Server;
|
|||||||
import mineplex.core.server.ServerListener;
|
import mineplex.core.server.ServerListener;
|
||||||
import mineplex.core.server.ServerTalker;
|
import mineplex.core.server.ServerTalker;
|
||||||
import mineplex.core.spawn.Spawn;
|
import mineplex.core.spawn.Spawn;
|
||||||
|
import mineplex.core.status.ServerStatusManager;
|
||||||
import mineplex.core.teleport.Teleport;
|
import mineplex.core.teleport.Teleport;
|
||||||
import mineplex.core.updater.FileUpdater;
|
import mineplex.core.updater.FileUpdater;
|
||||||
import mineplex.core.updater.Updater;
|
import mineplex.core.updater.Updater;
|
||||||
@ -111,6 +113,7 @@ public abstract class GamePlugin extends JavaPlugin implements IRelation
|
|||||||
_damage = new DamageManager(this, CombatManager, NpcManager, new DisguiseManager(this, PacketHandler));
|
_damage = new DamageManager(this, CombatManager, NpcManager, new DisguiseManager(this, PacketHandler));
|
||||||
_fire = new Fire(this, ConditionManager, _damage);
|
_fire = new Fire(this, ConditionManager, _damage);
|
||||||
new Punish(this, GetWebServerAddress());
|
new Punish(this, GetWebServerAddress());
|
||||||
|
new ServerStatusManager(this, new LagMeter(this, ClientManager));
|
||||||
|
|
||||||
|
|
||||||
SkillManager = new SkillFactory(this, _damage, this, CombatManager, ConditionManager, _throw, _blockRestore, _fire, new Movement(this), _teleport, Energy, GetWebServerAddress());
|
SkillManager = new SkillFactory(this, _damage, this, CombatManager, ConditionManager, _throw, _blockRestore, _fire, new Movement(this), _teleport, Energy, GetWebServerAddress());
|
||||||
|
@ -93,7 +93,7 @@ import net.minecraft.server.v1_6_R2.NBTTagCompound;
|
|||||||
import net.minecraft.server.v1_6_R2.NBTTagList;
|
import net.minecraft.server.v1_6_R2.NBTTagList;
|
||||||
import net.minecraft.server.v1_6_R2.NBTTagString;
|
import net.minecraft.server.v1_6_R2.NBTTagString;
|
||||||
|
|
||||||
public abstract class GameEngine<GameType extends IGame<ArenaType, PlayerType>, ScoreHandlerType extends IScoreHandler<PlayerType>, ArenaType extends IArena, PlayerType extends IGamePlayer> implements IGameEngine<GameType, ArenaType, PlayerType>, Listener, Runnable, IRelation
|
public abstract class GameEngine<GameType extends IGame<ArenaType, PlayerType>, ScoreHandlerType extends IScoreHandler<PlayerType>, ArenaType extends IArena, PlayerType extends IGamePlayer> implements IGameEngine<GameType, ArenaType, PlayerType>, Listener, IRelation
|
||||||
{
|
{
|
||||||
protected int MaxGames = -1;
|
protected int MaxGames = -1;
|
||||||
|
|
||||||
@ -161,7 +161,6 @@ public abstract class GameEngine<GameType extends IGame<ArenaType, PlayerType>,
|
|||||||
Portal = new mineplex.core.portal.Portal(plugin);
|
Portal = new mineplex.core.portal.Portal(plugin);
|
||||||
|
|
||||||
Plugin.getServer().getPluginManager().registerEvents(this, Plugin);
|
Plugin.getServer().getPluginManager().registerEvents(this, Plugin);
|
||||||
Plugin.getServer().getScheduler().scheduleSyncRepeatingTask(Plugin, this, 0L, 1200L);
|
|
||||||
|
|
||||||
StartBook = CraftItemStack.asNewCraftStack(Item.WRITTEN_BOOK);
|
StartBook = CraftItemStack.asNewCraftStack(Item.WRITTEN_BOOK);
|
||||||
NBTTagCompound bookData = StartBook.getHandle().tag;
|
NBTTagCompound bookData = StartBook.getHandle().tag;
|
||||||
|
@ -188,9 +188,12 @@ public abstract class TeamGameEngine<GameType extends ITeamGame<ArenaType, Playe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler
|
||||||
public void run()
|
public void updateStartTimer(UpdateEvent event)
|
||||||
{
|
{
|
||||||
|
if (event.getType() != UpdateType.MIN_01)
|
||||||
|
return;
|
||||||
|
|
||||||
if (Scheduler.GetGames().size() > 0)
|
if (Scheduler.GetGames().size() > 0)
|
||||||
{
|
{
|
||||||
GameType game = Scheduler.GetGames().get(Scheduler.GetGames().size() - 1);
|
GameType game = Scheduler.GetGames().get(Scheduler.GetGames().size() - 1);
|
||||||
@ -198,34 +201,21 @@ public abstract class TeamGameEngine<GameType extends ITeamGame<ArenaType, Playe
|
|||||||
|
|
||||||
if (players < TeamSize * 2 && players >= MinQueuePlayersToStart)
|
if (players < TeamSize * 2 && players >= MinQueuePlayersToStart)
|
||||||
{
|
{
|
||||||
if (game.GetPlayers().size() % 2 != 0)
|
_gameQueueTickValue++;
|
||||||
{
|
|
||||||
if (BroadcastQueueJoinMessage )
|
|
||||||
{
|
|
||||||
for (Player gameplayer : game.GetBlueTeam().GetPlayers().get(0).GetPlayer().getWorld().getPlayers())
|
|
||||||
{
|
|
||||||
gameplayer.sendMessage(F.main("Play Queue", "Waiting for teams to be even before start timer resumes."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_gameQueueTickValue++;
|
|
||||||
|
|
||||||
if (_gameQueueTickValue > TimeToStart)
|
if (_gameQueueTickValue > TimeToStart)
|
||||||
{
|
{
|
||||||
TeamSize = players/2;
|
TeamSize = players/2;
|
||||||
TryToActivateGames();
|
TryToActivateGames();
|
||||||
}
|
}
|
||||||
else if (BroadcastQueueJoinMessage)
|
else if (BroadcastQueueJoinMessage)
|
||||||
{
|
{
|
||||||
for (Player gameplayer : game.GetBlueTeam().GetPlayers().get(0).GetPlayer().getWorld().getPlayers())
|
for (Player gameplayer : game.GetBlueTeam().GetPlayers().get(0).GetPlayer().getWorld().getPlayers())
|
||||||
{
|
{
|
||||||
String minuteMessage = (3 - _gameQueueTickValue) == 1 ? "minute" : "minutes";
|
String minuteMessage = (3 - _gameQueueTickValue) == 1 ? "minute" : "minutes";
|
||||||
gameplayer.sendMessage(F.main("Play Queue", "Game will start in " + (3 - _gameQueueTickValue) + " " + minuteMessage + "!"));
|
gameplayer.sendMessage(F.main("Play Queue", "Game will start in " + (3 - _gameQueueTickValue) + " " + minuteMessage + "!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package nautilus.game.core.game;
|
package nautilus.game.core.game;
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -15,6 +13,7 @@ import org.bukkit.entity.Arrow;
|
|||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -23,6 +22,8 @@ import org.bukkit.potion.PotionEffect;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import mineplex.core.energy.Energy;
|
import mineplex.core.energy.Energy;
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.minecraft.game.classcombat.Class.ClassManager;
|
import mineplex.minecraft.game.classcombat.Class.ClassManager;
|
||||||
import mineplex.minecraft.game.classcombat.Class.ClientClass;
|
import mineplex.minecraft.game.classcombat.Class.ClientClass;
|
||||||
import mineplex.minecraft.game.classcombat.Skill.ISkill;
|
import mineplex.minecraft.game.classcombat.Skill.ISkill;
|
||||||
@ -31,7 +32,6 @@ import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
|||||||
import nautilus.game.core.arena.IArena;
|
import nautilus.game.core.arena.IArena;
|
||||||
import nautilus.game.core.notifier.PlayerNotifier;
|
import nautilus.game.core.notifier.PlayerNotifier;
|
||||||
import nautilus.game.core.player.IGamePlayer;
|
import nautilus.game.core.player.IGamePlayer;
|
||||||
import nautilus.game.core.util.BroadcastSecondTimer;
|
|
||||||
import nautilus.minecraft.core.utils.GenericRunnable;
|
import nautilus.minecraft.core.utils.GenericRunnable;
|
||||||
|
|
||||||
public abstract class Game<PlayerType extends IGamePlayer, ArenaType extends IArena> implements IGame<ArenaType, PlayerType>, Listener, Runnable
|
public abstract class Game<PlayerType extends IGamePlayer, ArenaType extends IArena> implements IGame<ArenaType, PlayerType>, Listener, Runnable
|
||||||
@ -48,11 +48,13 @@ public abstract class Game<PlayerType extends IGamePlayer, ArenaType extends IAr
|
|||||||
protected long StartTime;
|
protected long StartTime;
|
||||||
protected boolean HasStarted;
|
protected boolean HasStarted;
|
||||||
protected boolean CountdownRunning;
|
protected boolean CountdownRunning;
|
||||||
protected BroadcastSecondTimer StartTimer;
|
|
||||||
|
|
||||||
protected HashMap<String, Integer> PlayerTaskIdMap;
|
protected HashMap<String, Integer> PlayerTaskIdMap;
|
||||||
|
|
||||||
protected int UpdaterTaskId;
|
protected int UpdaterTaskId;
|
||||||
|
protected PlayerNotifier<IGame<ArenaType, PlayerType>, ArenaType, PlayerType> Notifier;
|
||||||
|
|
||||||
|
private int _countDown;
|
||||||
|
|
||||||
public Game(JavaPlugin plugin, ClassManager classManager, ConditionManager conditionManager, Energy energy)
|
public Game(JavaPlugin plugin, ClassManager classManager, ConditionManager conditionManager, Energy energy)
|
||||||
{
|
{
|
||||||
@ -301,26 +303,50 @@ public abstract class Game<PlayerType extends IGamePlayer, ArenaType extends IAr
|
|||||||
public void Activate(ArenaType arena)
|
public void Activate(ArenaType arena)
|
||||||
{
|
{
|
||||||
Arena = arena;
|
Arena = arena;
|
||||||
StartTimer = new BroadcastSecondTimer(new PlayerNotifier<IGame<ArenaType, PlayerType>, ArenaType, PlayerType>(Plugin, "Dominate"), this, 30, "Game starting", "Game starting...", new ActionListener()
|
Notifier = new PlayerNotifier<IGame<ArenaType, PlayerType>, ArenaType, PlayerType>(Plugin, "Dominate");
|
||||||
{
|
|
||||||
public void actionPerformed(ActionEvent evt)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ReallyStartGame();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
StartTimer.Start();
|
|
||||||
|
|
||||||
|
_countDown = 30;
|
||||||
CountdownRunning = true;
|
CountdownRunning = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void updateStartTimer(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.SEC)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!CountdownRunning)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_countDown == 0)
|
||||||
|
{
|
||||||
|
ReallyStartGame();
|
||||||
|
CountdownRunning = false;
|
||||||
|
}
|
||||||
|
else if (_countDown == 1)
|
||||||
|
{
|
||||||
|
Notifier.BroadcastMessageToPlayers("Game starting in 1 second.", GetPlayers());
|
||||||
|
}
|
||||||
|
else if (_countDown < 11)
|
||||||
|
{
|
||||||
|
Notifier.BroadcastMessageToPlayers("Game starting in " + _countDown + " seconds.", GetPlayers());
|
||||||
|
}
|
||||||
|
else if (_countDown == 15)
|
||||||
|
{
|
||||||
|
Notifier.BroadcastMessageToPlayers("Game starting in " + _countDown + " seconds.", GetPlayers());
|
||||||
|
}
|
||||||
|
else if (_countDown == 30)
|
||||||
|
{
|
||||||
|
Notifier.BroadcastMessageToPlayers("Game starting in " + _countDown + " seconds.", GetPlayers());
|
||||||
|
}
|
||||||
|
else if (_countDown == 45)
|
||||||
|
{
|
||||||
|
Notifier.BroadcastMessageToPlayers("Game starting in " + _countDown + " seconds.", GetPlayers());
|
||||||
|
}
|
||||||
|
|
||||||
|
_countDown--;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean IsActive()
|
public boolean IsActive()
|
||||||
{
|
{
|
||||||
return CountdownRunning || HasStarted;
|
return CountdownRunning || HasStarted;
|
||||||
@ -357,13 +383,9 @@ public abstract class Game<PlayerType extends IGamePlayer, ArenaType extends IAr
|
|||||||
Players.clear();
|
Players.clear();
|
||||||
Spectators.clear();
|
Spectators.clear();
|
||||||
|
|
||||||
if (StartTimer != null)
|
|
||||||
StartTimer.Deactivate();
|
|
||||||
|
|
||||||
Plugin.getServer().getScheduler().cancelTask(UpdaterTaskId);
|
Plugin.getServer().getScheduler().cancelTask(UpdaterTaskId);
|
||||||
HandlerList.unregisterAll(this);
|
HandlerList.unregisterAll(this);
|
||||||
|
|
||||||
StartTimer = null;
|
|
||||||
Arena = null;
|
Arena = null;
|
||||||
Plugin = null;
|
Plugin = null;
|
||||||
Players = null;
|
Players = null;
|
||||||
|
@ -33,7 +33,7 @@ public class DominateGameEngine extends TeamGameEngine<IDominateGame, IDominateS
|
|||||||
_notifier = notifier;
|
_notifier = notifier;
|
||||||
new DominateStatsReporter(plugin, donationManager, webServerAddress);
|
new DominateStatsReporter(plugin, donationManager, webServerAddress);
|
||||||
|
|
||||||
TeamSize = 5;
|
TeamSize = 1;
|
||||||
AddToActiveGame = true;
|
AddToActiveGame = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,12 +4,8 @@ import java.io.File;
|
|||||||
import java.io.FileFilter;
|
import java.io.FileFilter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import me.chiss.Core.Config.Config;
|
|
||||||
import me.chiss.Core.Loot.LootFactory;
|
|
||||||
import me.chiss.Core.MemoryFix.MemoryFix;
|
import me.chiss.Core.MemoryFix.MemoryFix;
|
||||||
import me.chiss.Core.Module.ModuleManager;
|
|
||||||
import me.chiss.Core.Modules.*;
|
import me.chiss.Core.Modules.*;
|
||||||
import me.chiss.Core.Plugin.IPlugin;
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.antistack.AntiStack;
|
import mineplex.core.antistack.AntiStack;
|
||||||
import mineplex.core.blockrestore.BlockRestore;
|
import mineplex.core.blockrestore.BlockRestore;
|
||||||
@ -17,25 +13,20 @@ import mineplex.core.command.CommandCenter;
|
|||||||
import mineplex.core.common.CurrencyType;
|
import mineplex.core.common.CurrencyType;
|
||||||
import mineplex.core.creature.Creature;
|
import mineplex.core.creature.Creature;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.energy.Energy;
|
|
||||||
import mineplex.core.explosion.Explosion;
|
import mineplex.core.explosion.Explosion;
|
||||||
import mineplex.core.fakeEntity.FakeEntity;
|
import mineplex.core.fakeEntity.FakeEntity;
|
||||||
import mineplex.core.fakeEntity.FakeEntityManager;
|
import mineplex.core.fakeEntity.FakeEntityManager;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
import mineplex.core.monitor.LagMeter;
|
||||||
import mineplex.core.npc.NpcManager;
|
import mineplex.core.npc.NpcManager;
|
||||||
import mineplex.core.packethandler.PacketHandler;
|
import mineplex.core.packethandler.PacketHandler;
|
||||||
import mineplex.core.pet.PetManager;
|
|
||||||
import mineplex.core.projectile.ProjectileManager;
|
|
||||||
import mineplex.core.punish.Punish;
|
import mineplex.core.punish.Punish;
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.core.server.ServerListener;
|
import mineplex.core.server.ServerListener;
|
||||||
import mineplex.core.spawn.Spawn;
|
import mineplex.core.spawn.Spawn;
|
||||||
|
import mineplex.core.status.ServerStatusManager;
|
||||||
import mineplex.core.teleport.Teleport;
|
import mineplex.core.teleport.Teleport;
|
||||||
import mineplex.core.updater.Updater;
|
import mineplex.core.updater.Updater;
|
||||||
import mineplex.minecraft.game.core.combat.CombatManager;
|
|
||||||
import mineplex.minecraft.game.core.condition.ConditionManager;
|
|
||||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
|
||||||
import mineplex.minecraft.game.core.fire.Fire;
|
|
||||||
|
|
||||||
import nautilus.game.minekart.gp.GPManager;
|
import nautilus.game.minekart.gp.GPManager;
|
||||||
import nautilus.game.minekart.kart.KartManager;
|
import nautilus.game.minekart.kart.KartManager;
|
||||||
@ -69,30 +60,17 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class MineKart extends JavaPlugin implements INautilusPlugin, IPlugin, Listener
|
public class MineKart extends JavaPlugin implements INautilusPlugin, Listener
|
||||||
{
|
{
|
||||||
private String WEB_CONFIG = "webServer";
|
private String WEB_CONFIG = "webServer";
|
||||||
|
|
||||||
//Modules
|
//Modules
|
||||||
private ModuleManager _moduleManager;
|
|
||||||
private CoreClientManager _clientManager;
|
private CoreClientManager _clientManager;
|
||||||
private DonationManager _donationManager;
|
private DonationManager _donationManager;
|
||||||
private Config _config;
|
|
||||||
private Utility _utility;
|
|
||||||
private BlockRegenerate _blockRegenerate;
|
|
||||||
private BlockRestore _blockRestore;
|
private BlockRestore _blockRestore;
|
||||||
private Blood _blood;
|
|
||||||
private Creature _creature;
|
private Creature _creature;
|
||||||
private Energy _energy;
|
|
||||||
private Fire _fire;
|
|
||||||
private Logger _logger;
|
|
||||||
private LootFactory _lootFactory;
|
|
||||||
private Observer _observer;
|
|
||||||
private me.chiss.Core.Server.Server _serverModule;
|
|
||||||
private Spawn _spawn;
|
private Spawn _spawn;
|
||||||
private Teleport _teleport;
|
private Teleport _teleport;
|
||||||
private ProjectileManager _throw;
|
|
||||||
private NpcManager _npcManager;
|
|
||||||
|
|
||||||
private GPManager _gpManager;
|
private GPManager _gpManager;
|
||||||
|
|
||||||
@ -115,7 +93,7 @@ public class MineKart extends JavaPlugin implements INautilusPlugin, IPlugin, Li
|
|||||||
{
|
{
|
||||||
ClearRaceFolders();
|
ClearRaceFolders();
|
||||||
|
|
||||||
getConfig().addDefault(WEB_CONFIG, "http://bettermc.com/");
|
getConfig().addDefault(WEB_CONFIG, "http:/api.mineplex.com/");
|
||||||
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
|
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
|
||||||
saveConfig();
|
saveConfig();
|
||||||
|
|
||||||
@ -124,28 +102,30 @@ public class MineKart extends JavaPlugin implements INautilusPlugin, IPlugin, Li
|
|||||||
_clientManager = CoreClientManager.Initialize(this, GetWebServerAddress());
|
_clientManager = CoreClientManager.Initialize(this, GetWebServerAddress());
|
||||||
CommandCenter.Initialize(this, _clientManager);
|
CommandCenter.Initialize(this, _clientManager);
|
||||||
FakeEntityManager.Initialize(this);
|
FakeEntityManager.Initialize(this);
|
||||||
_donationManager = new DonationManager(this, GetWebServerAddress());
|
|
||||||
Recharge.Initialize(this);
|
Recharge.Initialize(this);
|
||||||
|
|
||||||
//Init Modules
|
_donationManager = new DonationManager(this, GetWebServerAddress());
|
||||||
GetModules();
|
|
||||||
GetCreature();
|
_creature = new Creature(this);
|
||||||
|
|
||||||
new Punish(this, GetWebServerAddress());
|
new Punish(this, GetWebServerAddress());
|
||||||
new Explosion(this, _blockRestore);
|
new Explosion(this, _blockRestore);
|
||||||
|
|
||||||
GetServer();
|
_teleport = new Teleport(this, _clientManager, _spawn);
|
||||||
GetTeleport();
|
|
||||||
|
|
||||||
//Unreferenced Modules
|
//Unreferenced Modules
|
||||||
new AntiStack(this);
|
new AntiStack(this);
|
||||||
//new Chat(this, GetClans(), _repository);
|
//new Chat(this, GetClans(), _repository);
|
||||||
new JoinQuit();
|
new JoinQuit();
|
||||||
|
new ServerStatusManager(this, new LagMeter(this, _clientManager));
|
||||||
|
|
||||||
|
|
||||||
|
PacketHandler packetHandler = new PacketHandler(this);
|
||||||
|
|
||||||
ItemStackFactory.Initialize(this, true);
|
ItemStackFactory.Initialize(this, true);
|
||||||
|
|
||||||
//Kart
|
//Kart
|
||||||
_gpManager = new GPManager(this, _donationManager, GetTeleport(), Recharge.Instance, new KartManager(this, Recharge.Instance), new TrackManager(this, GetTeleport()));
|
_gpManager = new GPManager(this, _donationManager, _teleport, Recharge.Instance, new KartManager(this, Recharge.Instance), new TrackManager(this, _teleport));
|
||||||
new TrackProcessor();
|
new TrackProcessor();
|
||||||
|
|
||||||
//Updates
|
//Updates
|
||||||
@ -155,16 +135,18 @@ public class MineKart extends JavaPlugin implements INautilusPlugin, IPlugin, Li
|
|||||||
|
|
||||||
//new TabLobbyList(this, playerNamer.PacketHandler, _clientManager, _donationManager, true);
|
//new TabLobbyList(this, playerNamer.PacketHandler, _clientManager, _donationManager, true);
|
||||||
|
|
||||||
FakeEntityManager.Instance.SetPacketHandler(new PacketHandler(this));
|
FakeEntityManager.Instance.SetPacketHandler(packetHandler);
|
||||||
DonationManager donationManager = new DonationManager(this, GetWebServerAddress());
|
DonationManager donationManager = new DonationManager(this, GetWebServerAddress());
|
||||||
|
|
||||||
_npcManager = new NpcManager(this, _creature);
|
new NpcManager(this, _creature);
|
||||||
KartFactory _kartFactory = new KartFactory(this, new KartRepository(GetWebServerAddress()));
|
KartFactory _kartFactory = new KartFactory(this, new KartRepository(GetWebServerAddress()));
|
||||||
new KartShop(_kartFactory, _clientManager, donationManager, CurrencyType.Gems);
|
new KartShop(_kartFactory, _clientManager, donationManager, CurrencyType.Gems);
|
||||||
new KartMenu(_kartFactory, _clientManager, donationManager, _gpManager);
|
new KartMenu(_kartFactory, _clientManager, donationManager, _gpManager);
|
||||||
|
|
||||||
new MemoryFix(this);
|
new MemoryFix(this);
|
||||||
|
|
||||||
|
new ServerStatusManager(this, new LagMeter(this, _clientManager));
|
||||||
|
|
||||||
getServer().getPluginManager().registerEvents(this, this);
|
getServer().getPluginManager().registerEvents(this, this);
|
||||||
|
|
||||||
CreateFakeKarts();
|
CreateFakeKarts();
|
||||||
@ -173,7 +155,7 @@ public class MineKart extends JavaPlugin implements INautilusPlugin, IPlugin, Li
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void OnPlayerJoin(PlayerJoinEvent event)
|
public void OnPlayerJoin(PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
event.getPlayer().teleport(GetSpawnLocation());
|
event.getPlayer().teleport(_spawnLocation);
|
||||||
event.getPlayer().setGameMode(GameMode.SURVIVAL);
|
event.getPlayer().setGameMode(GameMode.SURVIVAL);
|
||||||
event.getPlayer().setFoodLevel(20);
|
event.getPlayer().setFoodLevel(20);
|
||||||
event.getPlayer().setHealth(20d);
|
event.getPlayer().setHealth(20d);
|
||||||
@ -246,7 +228,6 @@ public class MineKart extends JavaPlugin implements INautilusPlugin, IPlugin, Li
|
|||||||
@Override
|
@Override
|
||||||
public void onDisable()
|
public void onDisable()
|
||||||
{
|
{
|
||||||
GetModules().onDisable();
|
|
||||||
_serverListener.Shutdown();
|
_serverListener.Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,162 +255,6 @@ public class MineKart extends JavaPlugin implements INautilusPlugin, IPlugin, Li
|
|||||||
return GetRealServer().getPluginManager();
|
return GetRealServer().getPluginManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void Log(String moduleName, String data)
|
|
||||||
{
|
|
||||||
System.out.println(moduleName + " : " + data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ModuleManager GetModules()
|
|
||||||
{
|
|
||||||
if (_moduleManager == null)
|
|
||||||
_moduleManager = new ModuleManager();
|
|
||||||
|
|
||||||
return _moduleManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Config GetConfig()
|
|
||||||
{
|
|
||||||
if (_config == null)
|
|
||||||
_config = new Config(this);
|
|
||||||
|
|
||||||
return _config;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Utility GetUtility()
|
|
||||||
{
|
|
||||||
if (_utility == null)
|
|
||||||
_utility = new Utility(this);
|
|
||||||
|
|
||||||
return _utility;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockRegenerate GetBlockRegenerate()
|
|
||||||
{
|
|
||||||
if (_blockRegenerate == null)
|
|
||||||
_blockRegenerate = new BlockRegenerate(this);
|
|
||||||
|
|
||||||
return _blockRegenerate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockRestore GetBlockRestore()
|
|
||||||
{
|
|
||||||
if (_blockRestore == null)
|
|
||||||
_blockRestore = new BlockRestore(this);
|
|
||||||
|
|
||||||
return _blockRestore;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Blood GetBlood()
|
|
||||||
{
|
|
||||||
if (_blood == null)
|
|
||||||
_blood = new Blood(this);
|
|
||||||
|
|
||||||
return _blood;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Creature GetCreature()
|
|
||||||
{
|
|
||||||
if (_creature == null)
|
|
||||||
_creature = new Creature(this);
|
|
||||||
|
|
||||||
return _creature;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Energy GetEnergy()
|
|
||||||
{
|
|
||||||
if (_energy == null)
|
|
||||||
_energy = new Energy(this);
|
|
||||||
|
|
||||||
return _energy;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Fire GetFire()
|
|
||||||
{
|
|
||||||
if (_fire == null)
|
|
||||||
_fire = new Fire(this, new ConditionManager(this), new DamageManager(this, new CombatManager(this), _npcManager));
|
|
||||||
|
|
||||||
return _fire;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Logger GetLogger()
|
|
||||||
{
|
|
||||||
if (_logger == null)
|
|
||||||
_logger = new Logger(this);
|
|
||||||
|
|
||||||
return _logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LootFactory GetLoot()
|
|
||||||
{
|
|
||||||
if (_lootFactory == null)
|
|
||||||
_lootFactory = new LootFactory(this);
|
|
||||||
|
|
||||||
return _lootFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Observer GetObserver()
|
|
||||||
{
|
|
||||||
if (_observer == null)
|
|
||||||
_observer = new Observer(this);
|
|
||||||
|
|
||||||
return _observer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public me.chiss.Core.Server.Server GetServer()
|
|
||||||
{
|
|
||||||
if (_serverModule == null)
|
|
||||||
_serverModule = new me.chiss.Core.Server.Server(this,_clientManager);
|
|
||||||
|
|
||||||
return _serverModule;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Spawn GetSpawn()
|
|
||||||
{
|
|
||||||
if (_spawn == null)
|
|
||||||
_spawn = new Spawn(this);
|
|
||||||
|
|
||||||
return _spawn;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Teleport GetTeleport()
|
|
||||||
{
|
|
||||||
if (_teleport == null)
|
|
||||||
_teleport = new Teleport(this, _clientManager, GetSpawn());
|
|
||||||
|
|
||||||
return _teleport;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ProjectileManager GetThrow()
|
|
||||||
{
|
|
||||||
if (_throw == null)
|
|
||||||
_throw = new ProjectileManager(this);
|
|
||||||
|
|
||||||
return _throw;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Location GetSpawnLocation()
|
|
||||||
{
|
|
||||||
return _spawnLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CreateFakeKarts()
|
private void CreateFakeKarts()
|
||||||
{
|
{
|
||||||
_chicken = new FakeEntity(EntityType.CHICKEN, new Location(_spawnLocation.getWorld(), 6.5, 17.5, -39.5, 0f, 0f));
|
_chicken = new FakeEntity(EntityType.CHICKEN, new Location(_spawnLocation.getWorld(), 6.5, 17.5, -39.5, 0f, 0f));
|
||||||
@ -484,10 +309,4 @@ public class MineKart extends JavaPlugin implements INautilusPlugin, IPlugin, Li
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public PetManager GetPetManager()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public class GPResult
|
|||||||
if (_gp.GetTrack().GetPositions().size() > 0 && sortedScores.size() > 0)
|
if (_gp.GetTrack().GetPositions().size() > 0 && sortedScores.size() > 0)
|
||||||
{
|
{
|
||||||
_first = sortedScores.get(0);
|
_first = sortedScores.get(0);
|
||||||
manager.RewardGems(_first.GetDriver().getName(), 8 * _gp.GetPlayers().size() + buffer);
|
manager.RewardGems(null, _first.GetDriver().getName(), 8 * _gp.GetPlayers().size() + buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer += 2;
|
buffer += 2;
|
||||||
@ -70,7 +70,7 @@ public class GPResult
|
|||||||
if (_gp.GetTrack().GetPositions().size() > 1 && sortedScores.size() > 1)
|
if (_gp.GetTrack().GetPositions().size() > 1 && sortedScores.size() > 1)
|
||||||
{
|
{
|
||||||
_second = sortedScores.get(1);
|
_second = sortedScores.get(1);
|
||||||
manager.RewardGems(_second.GetDriver().getName(), 5 * _gp.GetPlayers().size() + buffer);
|
manager.RewardGems(null, _second.GetDriver().getName(), 5 * _gp.GetPlayers().size() + buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer += 2;
|
buffer += 2;
|
||||||
@ -78,14 +78,14 @@ public class GPResult
|
|||||||
if (_gp.GetTrack().GetPositions().size() > 2 && sortedScores.size() > 2)
|
if (_gp.GetTrack().GetPositions().size() > 2 && sortedScores.size() > 2)
|
||||||
{
|
{
|
||||||
_third = sortedScores.get(2);
|
_third = sortedScores.get(2);
|
||||||
manager.RewardGems(_third.GetDriver().getName(), 2 * _gp.GetPlayers().size() + buffer);
|
manager.RewardGems(null, _third.GetDriver().getName(), 2 * _gp.GetPlayers().size() + buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer += 2;
|
buffer += 2;
|
||||||
|
|
||||||
for (int i = 3; i < sortedScores.size(); i++)
|
for (int i = 3; i < sortedScores.size(); i++)
|
||||||
{
|
{
|
||||||
manager.RewardGems(sortedScores.get(i).GetDriver().getName(), buffer);
|
manager.RewardGems(null, sortedScores.get(i).GetDriver().getName(), buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
_fireworkLocations = new ArrayList<Location>(5);
|
_fireworkLocations = new ArrayList<Location>(5);
|
||||||
|
Loading…
Reference in New Issue
Block a user