Added DynamicServer for bungee.
Added reload commands for balancer, dynamicserver, playercount. Added depends for lboby on dynamic server.
This commit is contained in:
parent
9121d429c2
commit
22ee1522c1
7
Plugins/Mineplex.Bungee.DynamicServer/.classpath
Normal file
7
Plugins/Mineplex.Bungee.DynamicServer/.classpath
Normal file
@ -0,0 +1,7 @@
|
||||
<?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>
|
@ -0,0 +1,11 @@
|
||||
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
|
4
Plugins/Mineplex.Bungee.DynamicServer/plugin.yml
Normal file
4
Plugins/Mineplex.Bungee.DynamicServer/plugin.yml
Normal file
@ -0,0 +1,4 @@
|
||||
name: DynamicServer
|
||||
main: mineplex.bungee.dynamicServer.DynamicServer
|
||||
version: 1
|
||||
author: defek7
|
@ -0,0 +1,87 @@
|
||||
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 extends Plugin implements Listener
|
||||
{
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
LoadServers();
|
||||
|
||||
getProxy().getPluginManager().registerListener(this, this);
|
||||
getProxy().getPluginManager().registerCommand(this, new ReloadServerListCommand(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);
|
||||
|
||||
getProxy().getServers().put(name, 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package mineplex.bungee.dynamicServer;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
|
||||
public class ReloadServerListCommand extends Command
|
||||
{
|
||||
private DynamicServer _plugin;
|
||||
|
||||
public ReloadServerListCommand(DynamicServer plugin)
|
||||
{
|
||||
super( "reloaddynamicserver", "bungeecord.command.reloadserverlist" );
|
||||
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] arg1)
|
||||
{
|
||||
_plugin.LoadServers();
|
||||
sender.sendMessage(ChatColor.BLUE + "DynamicServer>" + ChatColor.GRAY + " Reloaded server list.");
|
||||
}
|
||||
}
|
@ -2,3 +2,4 @@ name: LobbyBalancer
|
||||
main: mineplex.bungee.lobbyBalancer.LobbyBalancer
|
||||
version: 1
|
||||
author: defek7
|
||||
depends: [DynamicServer]
|
||||
|
@ -29,6 +29,8 @@ public class LobbyBalancer extends Plugin implements Listener, Runnable
|
||||
|
||||
getProxy().getPluginManager().registerListener(this, this);
|
||||
getProxy().getScheduler().schedule(this, this, 1L, 1L, TimeUnit.SECONDS);
|
||||
|
||||
getProxy().getPluginManager().registerCommand(this, new ReloadLobbyServerListCommand(this));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -220,9 +222,11 @@ public class LobbyBalancer extends Plugin implements Listener, Runnable
|
||||
return var3.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadLobbyServers()
|
||||
{
|
||||
|
||||
public void loadLobbyServers()
|
||||
{
|
||||
_lobbyServers.clear();
|
||||
|
||||
for (String key : getProxy().getServers().keySet())
|
||||
{
|
||||
if (key.toUpperCase().contains("LOBBY"))
|
||||
@ -230,5 +234,5 @@ public class LobbyBalancer extends Plugin implements Listener, Runnable
|
||||
_lobbyServers.put(key, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
package mineplex.bungee.lobbyBalancer;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
|
||||
public class ReloadLobbyServerListCommand extends Command
|
||||
{
|
||||
private LobbyBalancer _plugin;
|
||||
|
||||
public ReloadLobbyServerListCommand(LobbyBalancer plugin)
|
||||
{
|
||||
super( "reloadlobbybalancer", "bungeecord.command.reloadserverlist" );
|
||||
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] arg1)
|
||||
{
|
||||
_plugin.loadLobbyServers();
|
||||
sender.sendMessage(ChatColor.BLUE + "LobbyBalancer>" + ChatColor.GRAY + " Reloaded lobby server list.");
|
||||
}
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user