-
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
Showing
52 changed files
with
978 additions
and
133 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
25 changes: 25 additions & 0 deletions
25
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 |
---|---|---|
@@ -0,0 +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(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
bungee/src/main/java/com/sekwah/advancedportals/bungee/BungeeInfoLogger.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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.sekwah.advancedportals.bungee; | ||
|
||
import com.sekwah.advancedportals.core.util.InfoLogger; | ||
|
||
import java.util.logging.Level; | ||
|
||
public class BungeeInfoLogger extends InfoLogger { | ||
private final AdvancedPortalsBungeePlugin plugin; | ||
|
||
public BungeeInfoLogger(AdvancedPortalsBungeePlugin plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
@Override | ||
public void warning(String s) { | ||
plugin.getLogger().warning(s); | ||
} | ||
|
||
@Override | ||
public void info(String s) { | ||
plugin.getLogger().info(s); | ||
} | ||
|
||
@Override | ||
public void error(Exception e) { | ||
plugin.getLogger().log(Level.SEVERE, e.getMessage(), e); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
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 |
---|---|---|
@@ -0,0 +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())); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...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 |
---|---|---|
@@ -0,0 +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); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...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 |
---|---|---|
@@ -0,0 +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); | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
...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 |
---|---|---|
@@ -0,0 +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(); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
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
Oops, something went wrong.