Add getServerInfo(name) and rework plugin channel system for stupud Bukkit limitations.
This commit is contained in:
		| @@ -87,6 +87,14 @@ public abstract class ProxyServer | ||||
|      */ | ||||
|     public abstract Map<String, ServerInfo> getServers(); | ||||
|  | ||||
|     /** | ||||
|      * Gets the server info of a server. | ||||
|      * | ||||
|      * @param name the name of the configured server | ||||
|      * @return the server info belonging to the specified server | ||||
|      */ | ||||
|     public abstract ServerInfo getServerInfo(String name); | ||||
|  | ||||
|     /** | ||||
|      * Get the {@link PluginManager} associated with loading plugins and | ||||
|      * dispatching events. It is recommended that implementations use the | ||||
|   | ||||
| @@ -105,9 +105,7 @@ public class BungeeCord extends ProxyServer | ||||
|         getPluginManager().registerCommand(new CommandAlert()); | ||||
|         getPluginManager().registerCommand(new CommandBungee()); | ||||
|  | ||||
|         registerChannel("BungeeCord::Disconnect"); | ||||
|         registerChannel("BungeeCord::Connect"); | ||||
|         registerChannel("BungeeCord::Forward"); | ||||
|         registerChannel("BungeeCord"); | ||||
|     } | ||||
|  | ||||
|     public static BungeeCord getInstance() | ||||
| @@ -291,6 +289,12 @@ public class BungeeCord extends ProxyServer | ||||
|         return config.getServers(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public ServerInfo getServerInfo(String name) | ||||
|     { | ||||
|         return getServers().get(name); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     @Synchronized("pluginChannels") | ||||
|     public void registerChannel(String channel) | ||||
|   | ||||
| @@ -282,6 +282,13 @@ public class UserConnection extends GenericConnection implements ProxiedPlayer | ||||
|                         case 0xFA: | ||||
|                             // Call the onPluginMessage event | ||||
|                             PacketFAPluginMessage message = new PacketFAPluginMessage(packet); | ||||
|  | ||||
|                             // Might matter in the future | ||||
|                             if (message.tag.equals("BungeeCord")) | ||||
|                             { | ||||
|                                 continue; | ||||
|                             } | ||||
|  | ||||
|                             PluginMessageEvent event = new PluginMessageEvent(UserConnection.this, server, message.tag, message.data); | ||||
|                             ProxyServer.getInstance().getPluginManager().callEvent(event); | ||||
|  | ||||
| @@ -371,11 +378,13 @@ public class UserConnection extends GenericConnection implements ProxiedPlayer | ||||
|                                 continue; | ||||
|                             } | ||||
|  | ||||
|                             switch (message.tag) | ||||
|                             if (message.tag.equals("BungeeCord")) | ||||
|                             { | ||||
|                                 case "BungeeCord::Disconnect": | ||||
|                                 switch (in.readUTF()) | ||||
|                                 { | ||||
|                                     case "Disconnect": | ||||
|                                         break outer; | ||||
|                                 case "BungeeCord::Forward": | ||||
|                                     case "Forward": | ||||
|                                         String target = in.readUTF(); | ||||
|                                         String channel = in.readUTF(); | ||||
|                                         short len = in.readShort(); | ||||
| @@ -396,7 +405,7 @@ public class UserConnection extends GenericConnection implements ProxiedPlayer | ||||
|                                         } | ||||
|  | ||||
|                                         break; | ||||
|                                 case "BungeeCord::Connect": | ||||
|                                     case "Connect": | ||||
|                                         ServerInfo server = BungeeCord.getInstance().config.getServers().get(in.readUTF()); | ||||
|                                         if (server != null) | ||||
|                                         { | ||||
| @@ -406,6 +415,7 @@ public class UserConnection extends GenericConnection implements ProxiedPlayer | ||||
|                                         break; | ||||
|                                 } | ||||
|                             } | ||||
|                     } | ||||
|  | ||||
|                     while (!packetQueue.isEmpty()) | ||||
|                     { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 md_5
					md_5