-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f3099f
commit d757d41
Showing
27 changed files
with
692 additions
and
694 deletions.
There are no files selected for viewing
50 changes: 25 additions & 25 deletions
50
bungee/src/main/java/com/sekwah/advancedportals/bungee/AdvancedPortalsBungeePlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
package com.sekwah.advancedportals.bungee; | ||
|
||
import com.sekwah.advancedportals.bungee.connector.container.BungeeProxyContainer; | ||
import com.sekwah.advancedportals.core.ProxyMessages; | ||
import com.sekwah.advancedportals.proxycore.AdvancedPortalsProxyCore; | ||
import net.md_5.bungee.api.plugin.Plugin; | ||
|
||
public class AdvancedPortalsBungeePlugin extends Plugin { | ||
private AdvancedPortalsProxyCore proxyCore; | ||
|
||
@Override | ||
public void onEnable() { | ||
this.proxyCore = new AdvancedPortalsProxyCore(new BungeeInfoLogger(this), new BungeeProxyContainer(this)); | ||
this.proxyCore.onEnable(); | ||
|
||
getProxy().registerChannel(ProxyMessages.CHANNEL_NAME); | ||
|
||
getProxy().getPluginManager().registerListener(this, new EventListener(this, this.proxyCore)); | ||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
this.proxyCore.onDisable(); | ||
} | ||
} | ||
package com.sekwah.advancedportals.bungee; | ||
|
||
import com.sekwah.advancedportals.bungee.connector.container.BungeeProxyContainer; | ||
import com.sekwah.advancedportals.core.ProxyMessages; | ||
import com.sekwah.advancedportals.proxycore.AdvancedPortalsProxyCore; | ||
import net.md_5.bungee.api.plugin.Plugin; | ||
|
||
public class AdvancedPortalsBungeePlugin extends Plugin { | ||
private AdvancedPortalsProxyCore proxyCore; | ||
|
||
@Override | ||
public void onEnable() { | ||
this.proxyCore = new AdvancedPortalsProxyCore(new BungeeInfoLogger(this), new BungeeProxyContainer(this)); | ||
this.proxyCore.onEnable(); | ||
|
||
getProxy().registerChannel(ProxyMessages.CHANNEL_NAME); | ||
|
||
getProxy().getPluginManager().registerListener(this, new EventListener(this, this.proxyCore)); | ||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
this.proxyCore.onDisable(); | ||
} | ||
} |
94 changes: 47 additions & 47 deletions
94
bungee/src/main/java/com/sekwah/advancedportals/bungee/EventListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,47 @@ | ||
package com.sekwah.advancedportals.bungee; | ||
|
||
import com.sekwah.advancedportals.bungee.connector.container.BungeeProxyPlayerContainer; | ||
import com.sekwah.advancedportals.bungee.connector.container.BungeeProxyServerContainer; | ||
import com.sekwah.advancedportals.core.ProxyMessages; | ||
import com.sekwah.advancedportals.proxycore.AdvancedPortalsProxyCore; | ||
import net.md_5.bungee.api.connection.ProxiedPlayer; | ||
import net.md_5.bungee.api.connection.Server; | ||
import net.md_5.bungee.api.event.PlayerDisconnectEvent; | ||
import net.md_5.bungee.api.event.PluginMessageEvent; | ||
import net.md_5.bungee.api.event.ServerConnectedEvent; | ||
import net.md_5.bungee.api.plugin.Listener; | ||
import net.md_5.bungee.event.EventHandler; | ||
|
||
public class EventListener implements Listener { | ||
|
||
|
||
private final AdvancedPortalsBungeePlugin plugin; | ||
private final AdvancedPortalsProxyCore proxyCore; | ||
|
||
public EventListener(AdvancedPortalsBungeePlugin plugin, AdvancedPortalsProxyCore proxyCore) { | ||
this.plugin = plugin; | ||
this.proxyCore = proxyCore; | ||
} | ||
|
||
@EventHandler | ||
public void onMessageReceived(PluginMessageEvent event) { | ||
if(!event.getTag().equalsIgnoreCase(ProxyMessages.CHANNEL_NAME)) return; | ||
event.setCancelled(true); | ||
|
||
if(!(event.getSender() instanceof Server)) return; | ||
|
||
if(event.getReceiver() instanceof ProxiedPlayer player) { | ||
this.proxyCore.incomingMessage(new BungeeProxyPlayerContainer(player), event.getData()); | ||
} | ||
} | ||
|
||
@EventHandler | ||
public void onServerConnected(ServerConnectedEvent event) { | ||
this.proxyCore.onServerConnect(new BungeeProxyServerContainer(event.getServer()), new BungeeProxyPlayerContainer(event.getPlayer())); | ||
} | ||
|
||
@EventHandler | ||
public void onDisconnect(PlayerDisconnectEvent event) { | ||
this.proxyCore.onPlayerDisconnect(new BungeeProxyPlayerContainer(event.getPlayer())); | ||
} | ||
} | ||
package com.sekwah.advancedportals.bungee; | ||
|
||
import com.sekwah.advancedportals.bungee.connector.container.BungeeProxyPlayerContainer; | ||
import com.sekwah.advancedportals.bungee.connector.container.BungeeProxyServerContainer; | ||
import com.sekwah.advancedportals.core.ProxyMessages; | ||
import com.sekwah.advancedportals.proxycore.AdvancedPortalsProxyCore; | ||
import net.md_5.bungee.api.connection.ProxiedPlayer; | ||
import net.md_5.bungee.api.connection.Server; | ||
import net.md_5.bungee.api.event.PlayerDisconnectEvent; | ||
import net.md_5.bungee.api.event.PluginMessageEvent; | ||
import net.md_5.bungee.api.event.ServerConnectedEvent; | ||
import net.md_5.bungee.api.plugin.Listener; | ||
import net.md_5.bungee.event.EventHandler; | ||
|
||
public class EventListener implements Listener { | ||
|
||
|
||
private final AdvancedPortalsBungeePlugin plugin; | ||
private final AdvancedPortalsProxyCore proxyCore; | ||
|
||
public EventListener(AdvancedPortalsBungeePlugin plugin, AdvancedPortalsProxyCore proxyCore) { | ||
this.plugin = plugin; | ||
this.proxyCore = proxyCore; | ||
} | ||
|
||
@EventHandler | ||
public void onMessageReceived(PluginMessageEvent event) { | ||
if(!event.getTag().equalsIgnoreCase(ProxyMessages.CHANNEL_NAME)) return; | ||
event.setCancelled(true); | ||
|
||
if(!(event.getSender() instanceof Server)) return; | ||
|
||
if(event.getReceiver() instanceof ProxiedPlayer player) { | ||
this.proxyCore.incomingMessage(new BungeeProxyPlayerContainer(player), event.getData()); | ||
} | ||
} | ||
|
||
@EventHandler | ||
public void onServerConnected(ServerConnectedEvent event) { | ||
this.proxyCore.onServerConnect(new BungeeProxyServerContainer(event.getServer()), new BungeeProxyPlayerContainer(event.getPlayer())); | ||
} | ||
|
||
@EventHandler | ||
public void onDisconnect(PlayerDisconnectEvent event) { | ||
this.proxyCore.onPlayerDisconnect(new BungeeProxyPlayerContainer(event.getPlayer())); | ||
} | ||
} |
76 changes: 38 additions & 38 deletions
76
...main/java/com/sekwah/advancedportals/bungee/connector/container/BungeeProxyContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
package com.sekwah.advancedportals.bungee.connector.container; | ||
|
||
import com.sekwah.advancedportals.bungee.AdvancedPortalsBungeePlugin; | ||
import com.sekwah.advancedportals.core.util.Lang; | ||
import com.sekwah.advancedportals.proxycore.connector.container.ProxyContainer; | ||
import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerContainer; | ||
import net.md_5.bungee.api.chat.TextComponent; | ||
|
||
public class BungeeProxyContainer implements ProxyContainer { | ||
|
||
private final AdvancedPortalsBungeePlugin plugin; | ||
|
||
public BungeeProxyContainer(AdvancedPortalsBungeePlugin plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
@Override | ||
public void invokeCommand(ProxyPlayerContainer proxyPlayer, String command) { | ||
// Should never not be true but just to be safe | ||
if(proxyPlayer instanceof BungeeProxyPlayerContainer playerContainer) { | ||
plugin.getProxy().getPluginManager().dispatchCommand(playerContainer.getPlayer(), command); | ||
} | ||
} | ||
|
||
@Override | ||
public void transferPlayer(ProxyPlayerContainer proxyPlayer, String serverName) { | ||
// Should never not be true but just to be safe | ||
if(proxyPlayer instanceof BungeeProxyPlayerContainer playerContainer) { | ||
var serverInfo = plugin.getProxy().getServerInfo(serverName); | ||
var player = playerContainer.getPlayer(); | ||
if(serverInfo == null) { | ||
player.sendMessage(new TextComponent(Lang.convertColors("&cCould not find server: &e") + serverName)); | ||
return; | ||
} | ||
player.connect(serverInfo); | ||
} | ||
} | ||
} | ||
package com.sekwah.advancedportals.bungee.connector.container; | ||
|
||
import com.sekwah.advancedportals.bungee.AdvancedPortalsBungeePlugin; | ||
import com.sekwah.advancedportals.core.util.Lang; | ||
import com.sekwah.advancedportals.proxycore.connector.container.ProxyContainer; | ||
import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerContainer; | ||
import net.md_5.bungee.api.chat.TextComponent; | ||
|
||
public class BungeeProxyContainer implements ProxyContainer { | ||
|
||
private final AdvancedPortalsBungeePlugin plugin; | ||
|
||
public BungeeProxyContainer(AdvancedPortalsBungeePlugin plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
@Override | ||
public void invokeCommand(ProxyPlayerContainer proxyPlayer, String command) { | ||
// Should never not be true but just to be safe | ||
if(proxyPlayer instanceof BungeeProxyPlayerContainer playerContainer) { | ||
plugin.getProxy().getPluginManager().dispatchCommand(playerContainer.getPlayer(), command); | ||
} | ||
} | ||
|
||
@Override | ||
public void transferPlayer(ProxyPlayerContainer proxyPlayer, String serverName) { | ||
// Should never not be true but just to be safe | ||
if(proxyPlayer instanceof BungeeProxyPlayerContainer playerContainer) { | ||
var serverInfo = plugin.getProxy().getServerInfo(serverName); | ||
var player = playerContainer.getPlayer(); | ||
if(serverInfo == null) { | ||
player.sendMessage(new TextComponent(Lang.convertColors("&cCould not find server: &e") + serverName)); | ||
return; | ||
} | ||
player.connect(serverInfo); | ||
} | ||
} | ||
} |
66 changes: 33 additions & 33 deletions
66
...ava/com/sekwah/advancedportals/bungee/connector/container/BungeeProxyPlayerContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
package com.sekwah.advancedportals.bungee.connector.container; | ||
|
||
import com.sekwah.advancedportals.core.ProxyMessages; | ||
import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerContainer; | ||
import net.md_5.bungee.api.connection.ProxiedPlayer; | ||
|
||
public class BungeeProxyPlayerContainer implements ProxyPlayerContainer { | ||
|
||
private final ProxiedPlayer player; | ||
|
||
public BungeeProxyPlayerContainer(ProxiedPlayer player) { | ||
this.player = player; | ||
} | ||
|
||
public ProxiedPlayer getPlayer() { | ||
return this.player; | ||
} | ||
|
||
@Override | ||
public String getUUID() { | ||
return this.player.getUniqueId().toString(); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return this.player.getName(); | ||
} | ||
|
||
public void sendServerPluginMessage(byte[] data) { | ||
this.player.getServer().sendData(ProxyMessages.CHANNEL_NAME, data); | ||
} | ||
|
||
} | ||
package com.sekwah.advancedportals.bungee.connector.container; | ||
|
||
import com.sekwah.advancedportals.core.ProxyMessages; | ||
import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerContainer; | ||
import net.md_5.bungee.api.connection.ProxiedPlayer; | ||
|
||
public class BungeeProxyPlayerContainer implements ProxyPlayerContainer { | ||
|
||
private final ProxiedPlayer player; | ||
|
||
public BungeeProxyPlayerContainer(ProxiedPlayer player) { | ||
this.player = player; | ||
} | ||
|
||
public ProxiedPlayer getPlayer() { | ||
return this.player; | ||
} | ||
|
||
@Override | ||
public String getUUID() { | ||
return this.player.getUniqueId().toString(); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return this.player.getName(); | ||
} | ||
|
||
public void sendServerPluginMessage(byte[] data) { | ||
this.player.getServer().sendData(ProxyMessages.CHANNEL_NAME, data); | ||
} | ||
|
||
} |
34 changes: 17 additions & 17 deletions
34
...ava/com/sekwah/advancedportals/bungee/connector/container/BungeeProxyServerContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
package com.sekwah.advancedportals.bungee.connector.container; | ||
|
||
import com.sekwah.advancedportals.proxycore.connector.container.ProxyServerContainer; | ||
import net.md_5.bungee.api.connection.Server; | ||
|
||
public class BungeeProxyServerContainer implements ProxyServerContainer { | ||
private final Server server; | ||
|
||
public BungeeProxyServerContainer(Server server) { | ||
this.server = server; | ||
} | ||
|
||
@Override | ||
public String getServerName() { | ||
return this.server.getInfo().getName(); | ||
} | ||
} | ||
package com.sekwah.advancedportals.bungee.connector.container; | ||
|
||
import com.sekwah.advancedportals.proxycore.connector.container.ProxyServerContainer; | ||
import net.md_5.bungee.api.connection.Server; | ||
|
||
public class BungeeProxyServerContainer implements ProxyServerContainer { | ||
private final Server server; | ||
|
||
public BungeeProxyServerContainer(Server server) { | ||
this.server = server; | ||
} | ||
|
||
@Override | ||
public String getServerName() { | ||
return this.server.getInfo().getName(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
main: com.sekwah.advancedportals.bungee.AdvancedPortalsBungeePlugin | ||
name: AdvancedPortals | ||
version: ${pluginVersion} | ||
author: sekwah41 | ||
main: com.sekwah.advancedportals.bungee.AdvancedPortalsBungeePlugin | ||
name: AdvancedPortals | ||
version: ${pluginVersion} | ||
author: sekwah41 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 18 additions & 18 deletions
36
core/src/main/java/com/sekwah/advancedportals/core/ProxyMessages.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
package com.sekwah.advancedportals.core; | ||
|
||
/** | ||
* messages going to the proxy will start with proxy: messages going to the server will start with server: | ||
*/ | ||
public class ProxyMessages { | ||
|
||
/** | ||
* Could split by channel messages we will handle it ourselves | ||
*/ | ||
public static final String CHANNEL_NAME = "advancedportals:message"; | ||
|
||
public static final String PROXY_TRANSFER_DESTI = "proxy:transfer_desti"; | ||
public static final String PROXY_TRANSFER = "proxy:transfer"; | ||
public static final String PROXY_COMMAND = "proxy:command"; | ||
|
||
public static final String SERVER_DESTI = "server:destination"; | ||
} | ||
package com.sekwah.advancedportals.core; | ||
|
||
/** | ||
* messages going to the proxy will start with proxy: messages going to the server will start with server: | ||
*/ | ||
public class ProxyMessages { | ||
|
||
/** | ||
* Could split by channel messages we will handle it ourselves | ||
*/ | ||
public static final String CHANNEL_NAME = "advancedportals:message"; | ||
|
||
public static final String PROXY_TRANSFER_DESTI = "proxy:transfer_desti"; | ||
public static final String PROXY_TRANSFER = "proxy:transfer"; | ||
public static final String PROXY_COMMAND = "proxy:command"; | ||
|
||
public static final String SERVER_DESTI = "server:destination"; | ||
} |
10 changes: 5 additions & 5 deletions
10
core/src/main/java/com/sekwah/advancedportals/core/network/Packet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package com.sekwah.advancedportals.core.network; | ||
|
||
public interface Packet { | ||
byte[] encode(); | ||
} | ||
package com.sekwah.advancedportals.core.network; | ||
|
||
public interface Packet { | ||
byte[] encode(); | ||
} |
Oops, something went wrong.