Skip to content

Commit

Permalink
chore: pre-commit changes [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Nov 13, 2024
1 parent 6f3099f commit d757d41
Show file tree
Hide file tree
Showing 27 changed files with 692 additions and 694 deletions.
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();
}
}
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()));
}
}
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);
}
}
}
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);
}

}
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();
}
}
8 changes: 4 additions & 4 deletions bungee/src/main/resources/bungee.yml
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
1 change: 0 additions & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,3 @@ def generateTemplates = tasks.register('generateTemplates', Copy) { task ->
}

sourceSets.main.java.srcDir(generateTemplates.map { it.outputs })

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";
}
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();
}
Loading

0 comments on commit d757d41

Please sign in to comment.