Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex
This commit is contained in:
commit
7bc3966feb
@ -1,6 +1,8 @@
|
||||
package mineplex.core.portal;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@ -15,6 +17,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
@ -23,7 +26,7 @@ import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class Portal extends MiniPlugin
|
||||
public class Portal extends MiniPlugin implements PluginMessageListener
|
||||
{
|
||||
private static Object _transferLock = new Object();
|
||||
|
||||
@ -34,12 +37,14 @@ public class Portal extends MiniPlugin
|
||||
private boolean _retrieve = true;
|
||||
|
||||
private CoreClientManager _clientier;
|
||||
private String serverName = "";
|
||||
|
||||
public Portal(JavaPlugin plugin)
|
||||
{
|
||||
super("Portal", plugin);
|
||||
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(GetPlugin(), "BungeeCord");
|
||||
Bukkit.getMessenger().registerIncomingPluginChannel(GetPlugin(), "BungeeCord", this);
|
||||
|
||||
_repository.initialize(plugin.getConfig().getBoolean("serverstatus.us"));
|
||||
_clientier = CoreClientManager.Initialize(plugin, plugin.getConfig().getString("webServer"));
|
||||
@ -93,6 +98,34 @@ public class Portal extends MiniPlugin
|
||||
}
|
||||
}, 20L);
|
||||
}
|
||||
|
||||
private void ProcessServerName(final Player player)
|
||||
{
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(b);
|
||||
|
||||
try
|
||||
{
|
||||
out.writeUTF("GetServer");
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Can never happen
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
out.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
player.sendPluginMessage(GetPlugin(), "BungeeCord", b.toByteArray());
|
||||
}
|
||||
|
||||
private void SendPlayerToServerWithMessage(Player player, String serverName)
|
||||
{
|
||||
@ -180,7 +213,8 @@ public class Portal extends MiniPlugin
|
||||
|
||||
if(args.length == 0)
|
||||
{
|
||||
player.sendMessage(ChatColor.YELLOW + "You are currently on server: " + ChatColor.GOLD + GetPlugin().getServer().getName() + " " + GetPlugin().getServer().getServerName());
|
||||
ProcessServerName(player);
|
||||
player.sendMessage(ChatColor.YELLOW + "You are currently on server: " + ChatColor.GOLD + serverName);
|
||||
return;
|
||||
}
|
||||
else if(args.length == 1)
|
||||
@ -256,4 +290,40 @@ public class Portal extends MiniPlugin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] message)
|
||||
{
|
||||
if (!channel.equals("BungeeCord"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DataInputStream in = new DataInputStream(new ByteArrayInputStream(message));
|
||||
|
||||
try
|
||||
{
|
||||
String subchannel = in.readUTF();
|
||||
|
||||
if (subchannel.equals("GetServer"))
|
||||
{
|
||||
serverName = in.readUTF();
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Should never happen
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user