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

View file

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

View file

@ -1,5 +1,7 @@
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;
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_UPDATE);
getLogger().info("Registering listeners...");
getProxy().getPluginManager().registerListener(this, new ServerSwitchListener());
getProxy().getPluginManager().registerListener(this, new PluginMessageListener());
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;
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.connection.ProxiedPlayer;
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;
public class ServerSwitchListener implements Listener {
/*
* Nicko Message Format
* FETCH: nicko:skin/fetch
* - UUID
*
* UPDATE: nicko:skin/update
* - UUID
* - Skin
* - Name
*/
@EventHandler
public void onSwitch(ServerSwitchEvent event) {
final ServerInfo from = event.getFrom();
final ProxiedPlayer player = event.getPlayer();
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 net.md_5.bungee.api.config.ServerInfo;
public class PluginChannelHelper {
public static boolean sendMessage(final ServerInfo info, final String channel, final String... data) {
public class PluginMessageUtils {
public static void sendMessage(final ServerInfo info, final String channel, final String... data) {
if (info == null) { return; }
final ByteArrayDataOutput output = ByteStreams.newDataOutput();
output.writeUTF(channel);
for (String elt : data) {
output.writeUTF(elt);
}
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;
import net.artelnatif.nicko.NickoBukkit;
import org.apache.commons.lang.LocaleUtils;
import org.apache.commons.lang3.LocaleUtils;
import java.util.Arrays;
import java.util.Locale;

View file

@ -9,6 +9,7 @@ import org.bukkit.plugin.messaging.PluginMessageListener;
public class UpdateMessageHandler implements PluginMessageListener {
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
System.out.println("channel = " + channel);
if(!channel.equals(NickoBungee.NICKO_PLUGIN_CHANNEL_UPDATE)) {
return;
}
@ -16,7 +17,8 @@ public class UpdateMessageHandler implements PluginMessageListener {
final ByteArrayDataInput in = ByteStreams.newDataInput(message);
final String subchannel = in.readUTF();
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");
}
}
}