feat: figuring out bungee support

This commit is contained in:
aro 2022-12-06 01:08:54 +01:00
parent 3f86c3c405
commit ba778db81a
8 changed files with 55 additions and 47 deletions

View file

@ -35,17 +35,11 @@
<configuration> <configuration>
<artifactSet> <artifactSet>
<includes> <includes>
<include>xyz.upperlevel.spigot.book:spigot-book-api</include>
<include>net.wesjd:anvilgui</include> <include>net.wesjd:anvilgui</include>
<include>de.studiocode.invui:*</include> <include>de.studiocode.invui:*</include>
<include>io.vavr:vavr</include>
</includes> </includes>
</artifactSet> </artifactSet>
<relocations> <relocations>
<relocation>
<pattern>xyz.upperlevel.spigot.book</pattern>
<shadedPattern>net.artelnatif.bookapi</shadedPattern>
</relocation>
<relocation> <relocation>
<pattern>net.wesjd.anvilgui</pattern> <pattern>net.wesjd.anvilgui</pattern>
<shadedPattern>net.artelnatif.anvilgui</shadedPattern> <shadedPattern>net.artelnatif.anvilgui</shadedPattern>
@ -84,7 +78,7 @@
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version> <version>1.19.2-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -93,6 +87,12 @@
<version>1.18-R0.1-SNAPSHOT</version> <version>1.18-R0.1-SNAPSHOT</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
@ -101,21 +101,21 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId> <artifactId>junit-jupiter</artifactId>
<version>5.9.0-M1</version> <version>5.9.0</version>
<scope>test</scope> <scope>test</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
<artifactId>opentest4j</artifactId> <artifactId>junit-jupiter-api</artifactId>
<groupId>org.opentest4j</groupId> <groupId>org.junit.jupiter</groupId>
</exclusion> </exclusion>
<exclusion> <exclusion>
<artifactId>junit-platform-commons</artifactId> <artifactId>junit-jupiter-params</artifactId>
<groupId>org.junit.platform</groupId> <groupId>org.junit.jupiter</groupId>
</exclusion> </exclusion>
<exclusion> <exclusion>
<artifactId>apiguardian-api</artifactId> <artifactId>junit-jupiter-engine</artifactId>
<groupId>org.apiguardian</groupId> <groupId>org.junit.jupiter</groupId>
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>

View file

@ -56,16 +56,16 @@
<artifactId>InvUI</artifactId> <artifactId>InvUI</artifactId>
<version>0.8.2</version> <version>0.8.2</version>
</dependency> </dependency>
<dependency>
<groupId>xyz.upperlevel.spigot.book</groupId>
<artifactId>spigot-book-api</artifactId>
<version>1.6</version>
</dependency>
<dependency> <dependency>
<groupId>net.wesjd</groupId> <groupId>net.wesjd</groupId>
<artifactId>anvilgui</artifactId> <artifactId>anvilgui</artifactId>
<version>1.5.3-SNAPSHOT</version> <version>1.5.3-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
@ -74,8 +74,8 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId> <artifactId>junit-jupiter</artifactId>
<version>5.9.0-M1</version> <version>5.9.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
@ -103,17 +103,11 @@
<configuration> <configuration>
<artifactSet> <artifactSet>
<includes> <includes>
<include>xyz.upperlevel.spigot.book:spigot-book-api</include>
<include>net.wesjd:anvilgui</include> <include>net.wesjd:anvilgui</include>
<include>de.studiocode.invui:*</include> <include>de.studiocode.invui:*</include>
<include>io.vavr:vavr</include>
</includes> </includes>
</artifactSet> </artifactSet>
<relocations> <relocations>
<relocation>
<pattern>xyz.upperlevel.spigot.book</pattern>
<shadedPattern>net.artelnatif.bookapi</shadedPattern>
</relocation>
<relocation> <relocation>
<pattern>net.wesjd.anvilgui</pattern> <pattern>net.wesjd.anvilgui</pattern>
<shadedPattern>net.artelnatif.anvilgui</shadedPattern> <shadedPattern>net.artelnatif.anvilgui</shadedPattern>

View file

@ -1,5 +1,7 @@
package net.artelnatif.nicko.bungee; package net.artelnatif.nicko.bungee;
import net.artelnatif.nicko.bungee.event.PluginMessageListener;
import net.artelnatif.nicko.bungee.event.ServerSwitchListener;
import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.api.plugin.Plugin;
public class NickoBungee extends Plugin { public class NickoBungee extends Plugin {
@ -17,6 +19,10 @@ public class NickoBungee extends Plugin {
getProxy().registerChannel(NICKO_PLUGIN_CHANNEL_FETCH); getProxy().registerChannel(NICKO_PLUGIN_CHANNEL_FETCH);
getProxy().registerChannel(NICKO_PLUGIN_CHANNEL_UPDATE); getProxy().registerChannel(NICKO_PLUGIN_CHANNEL_UPDATE);
getLogger().info("Registering listeners...");
getProxy().getPluginManager().registerListener(this, new ServerSwitchListener());
getProxy().getPluginManager().registerListener(this, new PluginMessageListener());
getLogger().info("Nicko (Bungee) has been enabled."); getLogger().info("Nicko (Bungee) has been enabled.");
} }

View file

@ -0,0 +1,15 @@
package net.artelnatif.nicko.bungee.event;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
import java.util.Arrays;
public class PluginMessageListener implements Listener {
@EventHandler
public void onSwitch(PluginMessageEvent event) {
final String message = Arrays.toString(event.getData());
System.out.println("message = " + message);
}
}

View file

@ -1,7 +1,7 @@
package net.artelnatif.nicko.bungee.event; package net.artelnatif.nicko.bungee.event;
import net.artelnatif.nicko.bungee.NickoBungee; import net.artelnatif.nicko.bungee.NickoBungee;
import net.artelnatif.nicko.bungee.pluginchannel.PluginChannelHelper; import net.artelnatif.nicko.bungee.pluginchannel.PluginMessageUtils;
import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server; import net.md_5.bungee.api.connection.Server;
@ -10,23 +10,12 @@ import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventHandler;
public class ServerSwitchListener implements Listener { public class ServerSwitchListener implements Listener {
/*
* Nicko Message Format
* FETCH: nicko:skin/fetch
* - UUID
*
* UPDATE: nicko:skin/update
* - UUID
* - Skin
* - Name
*/
@EventHandler @EventHandler
public void onSwitch(ServerSwitchEvent event) { public void onSwitch(ServerSwitchEvent event) {
final ServerInfo from = event.getFrom(); final ServerInfo from = event.getFrom();
final ProxiedPlayer player = event.getPlayer(); final ProxiedPlayer player = event.getPlayer();
final Server to = player.getServer(); final Server to = player.getServer();
PluginChannelHelper.sendMessage(from, NickoBungee.NICKO_PLUGIN_CHANNEL_FETCH, player.getUniqueId().toString()); System.out.println("NickoBungee.NICKO_PLUGIN_CHANNEL_UPDATE = " + NickoBungee.NICKO_PLUGIN_CHANNEL_UPDATE);
PluginMessageUtils.sendMessage(from, NickoBungee.NICKO_PLUGIN_CHANNEL_UPDATE, player.getUniqueId().toString());
} }
} }

View file

@ -4,14 +4,16 @@ import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.config.ServerInfo;
public class PluginChannelHelper { public class PluginMessageUtils {
public static boolean sendMessage(final ServerInfo info, final String channel, final String... data) { public static void sendMessage(final ServerInfo info, final String channel, final String... data) {
if (info == null) { return; }
final ByteArrayDataOutput output = ByteStreams.newDataOutput(); final ByteArrayDataOutput output = ByteStreams.newDataOutput();
output.writeUTF(channel); output.writeUTF(channel);
for (String elt : data) { for (String elt : data) {
output.writeUTF(elt); output.writeUTF(elt);
} }
System.out.printf("(%s) PluginMessage <-> %s", info.getSocketAddress().toString(), output); System.out.printf("(%s) PluginMessage <-> %s", info.getSocketAddress().toString(), output);
return info.sendData(channel, output.toByteArray(), false); info.sendData(channel, output.toByteArray(), true);
} }
} }

View file

@ -1,7 +1,7 @@
package net.artelnatif.nicko.i18n; package net.artelnatif.nicko.i18n;
import net.artelnatif.nicko.NickoBukkit; import net.artelnatif.nicko.NickoBukkit;
import org.apache.commons.lang.LocaleUtils; import org.apache.commons.lang3.LocaleUtils;
import java.util.Arrays; import java.util.Arrays;
import java.util.Locale; import java.util.Locale;

View file

@ -9,6 +9,7 @@ import org.bukkit.plugin.messaging.PluginMessageListener;
public class UpdateMessageHandler implements PluginMessageListener { public class UpdateMessageHandler implements PluginMessageListener {
@Override @Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) { public void onPluginMessageReceived(String channel, Player player, byte[] message) {
System.out.println("channel = " + channel);
if(!channel.equals(NickoBungee.NICKO_PLUGIN_CHANNEL_UPDATE)) { if(!channel.equals(NickoBungee.NICKO_PLUGIN_CHANNEL_UPDATE)) {
return; return;
} }
@ -16,7 +17,8 @@ public class UpdateMessageHandler implements PluginMessageListener {
final ByteArrayDataInput in = ByteStreams.newDataInput(message); final ByteArrayDataInput in = ByteStreams.newDataInput(message);
final String subchannel = in.readUTF(); final String subchannel = in.readUTF();
if(subchannel.equals(NickoBungee.NICKO_PLUGIN_CHANNEL_UPDATE)) { if(subchannel.equals(NickoBungee.NICKO_PLUGIN_CHANNEL_UPDATE)) {
// TODO: 10/20/22 update player System.out.println("subchannel = " + subchannel);
System.out.println("Received " + NickoBungee.NICKO_PLUGIN_CHANNEL_UPDATE + " msg");
} }
} }
} }