forked from unimatrix/web
Coordinate common and material pack ownership through Velocity
This commit is contained in:
parent
085e99d905
commit
62638f4957
6 changed files with 238 additions and 9 deletions
|
|
@ -46,6 +46,7 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
|
|||
private ExistingGuildService guild;
|
||||
private final GuildBookings bookings=new GuildBookings();
|
||||
private final Set<UUID> boarding=new HashSet<>();
|
||||
private ProxyPackBridge proxyPacks;
|
||||
private final Set<UUID> guiPackLoaded=new HashSet<>();
|
||||
private final Map<UUID,NetworkArtworkPolicy.Pack> offeredGuiPacks=new HashMap<>();
|
||||
private NetworkArtworkPolicy.Pack guiPack(Player player){
|
||||
|
|
@ -74,7 +75,8 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
|
|||
registrar=new NamespacedKey(this,"house_registrar");
|
||||
modernMenus=new MCGUIMenus(this);
|
||||
ecologyArtwork=new EcologyArtwork(this);
|
||||
new PlanetTexturePacks(this);
|
||||
proxyPacks=new ProxyPackBridge(this,this::receiveProxyArtworkStatus);
|
||||
new PlanetTexturePacks(this,proxyPacks);
|
||||
|
||||
sidebar=new PersonalSidebar(this);nameplates=new PublicNameplates(this);
|
||||
for(String command:List.of("start","spice","sellall","exchange","house","mentat","drgui","drscoreboard","guildtravel","clan","company","polgui"))Objects.requireNonNull(getCommand(command)).setExecutor(this);
|
||||
|
|
@ -265,6 +267,11 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
|
|||
private void offerGuiPack(Player p){offerGuiPack(p,true);}
|
||||
private void offerGuiPack(Player p,boolean force){
|
||||
if(!p.isOnline()||BedrockForms.isBedrock(p))return;
|
||||
if(proxyPacks.ownsCommon()){
|
||||
proxyPacks.requestStatus(p);
|
||||
if(lobby(p)){MCGUIMenus.offerPack(p);ecologyArtwork.offer(p);}
|
||||
return;
|
||||
}
|
||||
var pack=guiPack(p);
|
||||
if(!force&&pack.equals(offeredGuiPacks.get(p.getUniqueId())))return;
|
||||
guiPackLoaded.remove(p.getUniqueId());
|
||||
|
|
@ -281,8 +288,12 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
|
|||
giveCodex(p,false);
|
||||
if(sidebar.enabled(p))refreshSidebar(p);
|
||||
},40L);}
|
||||
private void receiveProxyArtworkStatus(Player player,boolean loaded){
|
||||
if(loaded)guiPackLoaded.add(player.getUniqueId());
|
||||
else guiPackLoaded.remove(player.getUniqueId());
|
||||
}
|
||||
@EventHandler public void packStatus(PlayerResourcePackStatusEvent e){
|
||||
if(!NetworkArtworkPolicy.PACK_ID.equals(e.getID()))return;
|
||||
if(proxyPacks.ownsCommon()||!NetworkArtworkPolicy.PACK_ID.equals(e.getID()))return;
|
||||
getLogger().info("GUI pack status for "+e.getPlayer().getName()+": "+e.getStatus());
|
||||
if(e.getStatus()==PlayerResourcePackStatusEvent.Status.SUCCESSFULLY_LOADED){guiPackLoaded.add(e.getPlayer().getUniqueId());e.getPlayer().sendMessage(Component.text("DuneRealms artwork loaded. Reopen your menu.",NamedTextColor.GREEN));return;}
|
||||
guiPackLoaded.remove(e.getPlayer().getUniqueId());
|
||||
|
|
|
|||
|
|
@ -23,14 +23,16 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||
final class PlanetTexturePacks implements Listener {
|
||||
static final UUID PACK_ID=PlanetMaterialPolicy.PACK_ID;
|
||||
private final JavaPlugin plugin;
|
||||
private final ProxyPackBridge proxy;
|
||||
private final Map<String,Pack> packs=new HashMap<>();
|
||||
private final Map<String,String> worlds=new HashMap<>();
|
||||
private final Map<UUID,String> offered=new HashMap<>();
|
||||
private final boolean enabled;
|
||||
record Pack(String url,String hash,String name){}
|
||||
|
||||
PlanetTexturePacks(JavaPlugin plugin){
|
||||
PlanetTexturePacks(JavaPlugin plugin,ProxyPackBridge proxy){
|
||||
this.plugin=plugin;
|
||||
this.proxy=proxy;
|
||||
File file=new File(plugin.getDataFolder(),"planet-textures.yml");
|
||||
if(!file.exists())plugin.saveResource("planet-textures.yml",false);
|
||||
var config=YamlConfiguration.loadConfiguration(file);
|
||||
|
|
@ -64,21 +66,48 @@ final class PlanetTexturePacks implements Listener {
|
|||
}
|
||||
}catch(IllegalArgumentException invalid){valid=false;plugin.getLogger().warning("Planet material packs disabled: invalid planet-textures.yml");}
|
||||
enabled=valid&&config.getBoolean("enabled",false);
|
||||
proxy.onOverlayDirective(this::applyProxyDirective);
|
||||
Bukkit.getPluginManager().registerEvents(this,plugin);
|
||||
Bukkit.getScheduler().runTaskLater(plugin,()->Bukkit.getOnlinePlayers().forEach(this::offer),40L);
|
||||
}
|
||||
|
||||
private void offer(Player player){
|
||||
if(!player.isOnline()||BedrockForms.isBedrock(player))return;
|
||||
String profile=enabled?PlanetMaterialPolicy.profile(player.getWorld().getName(),worlds):null;
|
||||
String profile=profile(player);
|
||||
if(proxy.deduplicatesOverlays()){
|
||||
proxy.send(player,"overlay-request\t"+pin(profile));
|
||||
return;
|
||||
}
|
||||
String desired=profile==null?"none":profile;
|
||||
if(desired.equals(offered.get(player.getUniqueId())))return;
|
||||
apply(player,profile);
|
||||
offered.put(player.getUniqueId(),desired);
|
||||
}
|
||||
|
||||
private String profile(Player player){
|
||||
return enabled?PlanetMaterialPolicy.profile(player.getWorld().getName(),worlds):null;
|
||||
}
|
||||
|
||||
private String pin(String profile){
|
||||
if(profile==null)return "-";
|
||||
Pack pack=packs.get(profile);
|
||||
return profile+"\t"+pack.url()+"\t"+pack.hash();
|
||||
}
|
||||
|
||||
private void applyProxyDirective(Player player,String requested){
|
||||
if(!player.isOnline()||BedrockForms.isBedrock(player))return;
|
||||
String profile=profile(player);
|
||||
if(!pin(profile).equals(requested))return;
|
||||
apply(player,profile);
|
||||
proxy.send(player,"overlay-applied\t"+requested);
|
||||
}
|
||||
|
||||
private void apply(Player player,String profile){
|
||||
player.removeResourcePack(PACK_ID);
|
||||
if(profile!=null){
|
||||
Pack pack=packs.get(profile);
|
||||
player.addResourcePack(PACK_ID,pack.url(),HexFormat.of().parseHex(pack.hash()),"DuneRealms · "+pack.name()+" materials",false);
|
||||
}
|
||||
offered.put(player.getUniqueId(),desired);
|
||||
}
|
||||
@EventHandler public void join(PlayerJoinEvent event){
|
||||
Player player=event.getPlayer();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
package com.dunerealms.gui;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.function.BiConsumer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
final class ProxyPackBridge {
|
||||
static final String CHANNEL = "dunerealms:pack_control";
|
||||
private final JavaPlugin plugin;
|
||||
private final boolean common;
|
||||
private final boolean overlays;
|
||||
private BiConsumer<Player,String> overlayDirective;
|
||||
|
||||
ProxyPackBridge(JavaPlugin plugin, BiConsumer<Player,Boolean> artworkStatus) {
|
||||
this.plugin = plugin;
|
||||
common = plugin.getConfig().getBoolean("development.proxy-owns-common-pack", false);
|
||||
overlays = plugin.getConfig().getBoolean("development.proxy-deduplicates-material-packs", false);
|
||||
if (!common && !overlays) return;
|
||||
var messenger = plugin.getServer().getMessenger();
|
||||
messenger.registerOutgoingPluginChannel(plugin, CHANNEL);
|
||||
messenger.registerIncomingPluginChannel(plugin, CHANNEL, (channel, player, bytes) -> {
|
||||
if (bytes.length > 256) return;
|
||||
String message = new String(bytes, StandardCharsets.US_ASCII);
|
||||
if (common && message.equals("common-loaded")) artworkStatus.accept(player, true);
|
||||
else if (common && message.equals("common-unavailable")) artworkStatus.accept(player, false);
|
||||
else if (overlays && message.startsWith("apply ") && overlayDirective != null)
|
||||
overlayDirective.accept(player, message.substring(6));
|
||||
});
|
||||
}
|
||||
|
||||
boolean ownsCommon() { return common; }
|
||||
boolean deduplicatesOverlays() { return overlays; }
|
||||
void onOverlayDirective(BiConsumer<Player,String> receiver) { overlayDirective = receiver; }
|
||||
void requestStatus(Player player) { send(player, "common-status"); }
|
||||
|
||||
void send(Player player, String message) {
|
||||
player.sendPluginMessage(plugin, CHANNEL, message.getBytes(StandardCharsets.US_ASCII));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
# Set both fields from the central pack release manifest after publishing the ZIP.
|
||||
# Keep disabled until the backend world overlays are replaced.
|
||||
# Pair with development.proxy-owns-common-pack on the backend.
|
||||
# The optional overlay mode also requires development.proxy-deduplicates-material-packs.
|
||||
url=
|
||||
sha1=
|
||||
deduplicate-material-packs=false
|
||||
|
|
|
|||
|
|
@ -3,16 +3,22 @@ package com.dunerealms.proxy;
|
|||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||
import com.velocitypowered.api.event.player.PlayerResourcePackStatusEvent;
|
||||
import com.velocitypowered.api.event.player.ServerPostConnectEvent;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.proxy.player.ResourcePackInfo;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.HexFormat;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
|
@ -23,6 +29,9 @@ import org.slf4j.Logger;
|
|||
@Plugin(id = "dunecentralpack", name = "DuneRealms Central Pack", version = "1.0.0")
|
||||
public final class CentralPackPlugin {
|
||||
private static final UUID PACK_ID=UUID.fromString("a7b5ab7d-d8d8-5b51-b016-71a5f4c00008");
|
||||
private static final MinecraftChannelIdentifier CHANNEL=MinecraftChannelIdentifier.from("dunerealms:pack_control");
|
||||
private final Map<UUID,OverlaySession> overlays=new ConcurrentHashMap<>();
|
||||
private volatile boolean deduplicateOverlays;
|
||||
private final ProxyServer proxy;
|
||||
private final Logger logger;
|
||||
private final Path directory;
|
||||
|
|
@ -44,6 +53,9 @@ public final class CentralPackPlugin {
|
|||
try(var source=Files.newBufferedReader(settings)){
|
||||
properties.load(source);
|
||||
String url=properties.getProperty("url",""),hash=properties.getProperty("sha1","");
|
||||
deduplicateOverlays=Boolean.parseBoolean(properties.getProperty("deduplicate-material-packs","false"));
|
||||
if(deduplicateOverlays||!url.isEmpty())proxy.getChannelRegistrar().register(CHANNEL);
|
||||
if(url.isEmpty()&&hash.isEmpty())return;
|
||||
if(!url.matches("https://www\\.dunerealms\\.com/downloads/DuneRealms-Central-v[1-9][0-9]*\\.zip")||!hash.matches("[a-f0-9]{40}")){
|
||||
throw new IllegalArgumentException("Expected a versioned DuneRealms pack URL and SHA-1");
|
||||
}
|
||||
|
|
@ -68,9 +80,80 @@ public final class CentralPackPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void packControl(PluginMessageEvent event){
|
||||
if(!CHANNEL.equals(event.getIdentifier()))return;
|
||||
event.setResult(PluginMessageEvent.ForwardResult.handled());
|
||||
if(!(event.getSource() instanceof ServerConnection backend)||!(event.getTarget() instanceof Player player)||
|
||||
!player.isActive()||backend.getPlayer()!=player||player.getCurrentServer().orElse(null)!=backend)return;
|
||||
byte[] bytes=event.getData();
|
||||
if(bytes.length>256)return;
|
||||
String message=new String(bytes,StandardCharsets.US_ASCII);
|
||||
if(message.equals("common-status")){
|
||||
ResourcePackInfo current=pack;
|
||||
boolean loaded=current!=null&&player.getAppliedResourcePacks().stream().anyMatch(applied->
|
||||
PACK_ID.equals(applied.getId())&&Arrays.equals(applied.getHash(),current.getHash()));
|
||||
tellArtworkStatus(backend,loaded);
|
||||
return;
|
||||
}
|
||||
if(!deduplicateOverlays)return;
|
||||
int split=message.indexOf('\t');
|
||||
if(split<0)return;
|
||||
String command=message.substring(0,split),pin=message.substring(split+1);
|
||||
if(!validOverlayPin(pin))return;
|
||||
synchronized(player){
|
||||
var session=overlays.compute(player.getUniqueId(),(id,current)->
|
||||
current!=null&¤t.player==player?current:new OverlaySession(player));
|
||||
if(command.equals("overlay-request")){
|
||||
if(pin.equals(session.applied)&&session.pending==null)return;
|
||||
if(backend==session.pendingBackend&&pin.equals(session.pending))return;
|
||||
if(backend.sendPluginMessage(CHANNEL,ascii("apply\t"+pin))){
|
||||
session.pending=pin;
|
||||
session.pendingBackend=backend;
|
||||
}
|
||||
}else if(command.equals("overlay-applied")&&backend==session.pendingBackend&&pin.equals(session.pending)){
|
||||
session.applied=pin;
|
||||
session.pending=null;
|
||||
session.pendingBackend=null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void packStatus(PlayerResourcePackStatusEvent event){
|
||||
if(pack==null||!PACK_ID.equals(event.getPackId())||offered.get(event.getPlayer().getUniqueId())!=event.getPlayer()||
|
||||
event.getStatus().isIntermediate())return;
|
||||
event.getPlayer().getCurrentServer().ifPresent(backend->tellArtworkStatus(backend,
|
||||
event.getStatus()==PlayerResourcePackStatusEvent.Status.SUCCESSFUL));
|
||||
}
|
||||
|
||||
private static void tellArtworkStatus(ServerConnection backend,boolean loaded){
|
||||
backend.sendPluginMessage(CHANNEL,ascii(loaded?"common-loaded":"common-unavailable"));
|
||||
}
|
||||
|
||||
private static byte[] ascii(String message){return message.getBytes(StandardCharsets.US_ASCII);}
|
||||
|
||||
static boolean validOverlayPin(String pin){
|
||||
if(pin.equals("-"))return true;
|
||||
String[] values=pin.split("\t",-1);
|
||||
if(values.length!=3)return false;
|
||||
String profile=values[0];
|
||||
return profile.matches("guild|arrakis|caladan|giedi_prime|giedi_prime_nether|kaitain|sigma_draconis_iv|sigma_draconis_iv_the_end")&&
|
||||
values[1].matches("https://www\\.dunerealms\\.com/downloads/DuneRealms-Materials-"+profile+"-v[1-9][0-9]*\\.zip")&&
|
||||
values[2].matches("[0-9a-f]{40}");
|
||||
}
|
||||
|
||||
private static final class OverlaySession{
|
||||
final Player player;
|
||||
String applied="-",pending;
|
||||
ServerConnection pendingBackend;
|
||||
OverlaySession(Player player){this.player=player;}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void disconnected(DisconnectEvent event){
|
||||
Player player=event.getPlayer();
|
||||
offered.remove(player.getUniqueId(),player);
|
||||
overlays.computeIfPresent(player.getUniqueId(),(id,current)->current.player==player?null:current);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,11 +2,15 @@ package com.dunerealms.proxy;
|
|||
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||
import com.velocitypowered.api.event.player.PlayerResourcePackStatusEvent;
|
||||
import com.velocitypowered.api.event.player.PlayerResourcePackStatusEvent.Status;
|
||||
import com.velocitypowered.api.event.player.ServerPostConnectEvent;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import com.velocitypowered.api.proxy.messages.ChannelRegistrar;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.proxy.player.ResourcePackInfo;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
|
|
@ -15,11 +19,15 @@ import java.lang.reflect.Proxy;
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.UUID;
|
||||
import java.util.Optional;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class CentralPackPluginTest {
|
||||
@TempDir Path directory;
|
||||
|
|
@ -60,13 +68,67 @@ class CentralPackPluginTest {
|
|||
assertEquals(1, connection.offers);
|
||||
}
|
||||
|
||||
@Test void overlayUsesTheCurrentBackendAndDeduplicatesIdenticalPins() throws Exception {
|
||||
var plugin = initializedPlugin();
|
||||
var connection = new Connection(UUID.randomUUID());
|
||||
var firstMessages = new ArrayList<String>();
|
||||
var first = backend(connection, firstMessages);
|
||||
connection.backend = first;
|
||||
String arrakis = overlayPin("arrakis", "1");
|
||||
String caladan = overlayPin("caladan", "2");
|
||||
control(plugin, first, connection, "overlay-request\t"+arrakis);
|
||||
control(plugin, first, connection, "overlay-request\t"+arrakis);
|
||||
assertEquals(List.of("apply\t"+arrakis), firstMessages);
|
||||
control(plugin, first, connection, "overlay-applied\t"+arrakis);
|
||||
|
||||
var secondMessages = new ArrayList<String>();
|
||||
var second = backend(connection, secondMessages);
|
||||
connection.backend = second;
|
||||
control(plugin, second, connection, "overlay-request\t"+arrakis);
|
||||
control(plugin, first, connection, "overlay-request\t"+caladan);
|
||||
control(plugin, connection.player, connection, "overlay-request\t"+caladan);
|
||||
control(plugin, second, connection, "overlay-request\t"+caladan.replace("www.dunerealms.com","example.com"));
|
||||
assertTrue(secondMessages.isEmpty());
|
||||
|
||||
control(plugin, second, connection, "overlay-request\t"+caladan);
|
||||
control(plugin, second, connection, "overlay-applied\t"+caladan);
|
||||
control(plugin, second, connection, "overlay-request\t-");
|
||||
control(plugin, second, connection, "overlay-applied\t-");
|
||||
control(plugin, second, connection, "overlay-request\t-");
|
||||
assertEquals(List.of("apply\t"+caladan, "apply\t-"), secondMessages);
|
||||
}
|
||||
|
||||
private static String overlayPin(String profile, String hex) {
|
||||
return profile+"\thttps://www.dunerealms.com/downloads/DuneRealms-Materials-"+profile+"-v3.zip\t"+hex.repeat(40);
|
||||
}
|
||||
|
||||
private static ServerConnection backend(Connection connection, List<String> messages) {
|
||||
return proxy(ServerConnection.class, (mock, method, args) -> switch (method.getName()) {
|
||||
case "getPlayer" -> connection.player;
|
||||
case "sendPluginMessage" -> {
|
||||
messages.add(new String((byte[])args[1], StandardCharsets.US_ASCII));
|
||||
yield true;
|
||||
}
|
||||
default -> throw new UnsupportedOperationException(method.getName());
|
||||
});
|
||||
}
|
||||
|
||||
private static void control(CentralPackPlugin plugin, com.velocitypowered.api.proxy.messages.ChannelMessageSource source,
|
||||
Connection connection, String message) throws Exception {
|
||||
var event = new PluginMessageEvent(source, connection.player, MinecraftChannelIdentifier.from("dunerealms:pack_control"),
|
||||
message.getBytes(StandardCharsets.US_ASCII));
|
||||
dispatch(plugin, event);
|
||||
assertFalse(event.getResult().isAllowed());
|
||||
}
|
||||
|
||||
private CentralPackPlugin initializedPlugin() throws Exception {
|
||||
Files.writeString(directory.resolve("pack.properties"),
|
||||
"url=https://www.dunerealms.com/downloads/DuneRealms-Central-v2.zip\nsha1=" + "1".repeat(40) + "\n");
|
||||
"url=https://www.dunerealms.com/downloads/DuneRealms-Central-v2.zip\nsha1=" + "1".repeat(40) + "\ndeduplicate-material-packs=true\n");
|
||||
var pack = proxy(ResourcePackInfo.class, (mock, method, args) -> null);
|
||||
var builder = proxy(ResourcePackInfo.Builder.class, (mock, method, args) ->
|
||||
method.getName().equals("build") ? pack : mock);
|
||||
var server = proxy(ProxyServer.class, (mock, method, args) -> builder);
|
||||
var registrar = proxy(ChannelRegistrar.class, (mock, method, args) -> null);
|
||||
var server = proxy(ProxyServer.class, (mock, method, args) -> method.getName().equals("getChannelRegistrar") ? registrar : builder);
|
||||
var log = proxy(Logger.class, (mock, method, args) -> null);
|
||||
var plugin = new CentralPackPlugin(server, log, directory);
|
||||
dispatch(plugin, new ProxyInitializeEvent());
|
||||
|
|
@ -89,12 +151,14 @@ class CentralPackPluginTest {
|
|||
int attempts;
|
||||
int offers;
|
||||
boolean failOnce;
|
||||
ServerConnection backend;
|
||||
|
||||
Connection(UUID id) {
|
||||
this.id = id;
|
||||
this.player = proxy(Player.class, (mock, method, args) -> switch (method.getName()) {
|
||||
case "isActive" -> true;
|
||||
case "getUniqueId" -> this.id;
|
||||
case "getCurrentServer" -> Optional.ofNullable(backend);
|
||||
case "equals" -> mock == args[0];
|
||||
case "hashCode" -> System.identityHashCode(mock);
|
||||
case "sendResourcePackOffer" -> {
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff