From 457b78717951165bf6ec6e3fde87abf9000febea Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 16 Mar 2024 00:54:49 +0100 Subject: [PATCH] Update CommonCore, kick Litematica, kick MiniMaps Signed-off-by: Lixfel --- CommonCore | 2 +- .../bungeecore/listeners/PluginMessage.java | 37 ++++++++++--------- src/de/steamwar/bungeecore/mods/ModUtils.java | 1 + 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/CommonCore b/CommonCore index a473e59..20c22c4 160000 --- a/CommonCore +++ b/CommonCore @@ -1 +1 @@ -Subproject commit a473e59048a73aae4b40ecb5d6d6b79f0791a138 +Subproject commit 20c22c47f940c4510de17594b28eb0a96cb9da0c diff --git a/src/de/steamwar/bungeecore/listeners/PluginMessage.java b/src/de/steamwar/bungeecore/listeners/PluginMessage.java index 8bf7556..1734b9c 100644 --- a/src/de/steamwar/bungeecore/listeners/PluginMessage.java +++ b/src/de/steamwar/bungeecore/listeners/PluginMessage.java @@ -21,6 +21,7 @@ package de.steamwar.bungeecore.listeners; import com.lunarclient.apollo.ApolloManager; import de.steamwar.bungeecore.BungeeCore; +import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.commands.TeamCommand; import de.steamwar.bungeecore.mods.*; import de.steamwar.bungeecore.network.ServerMetaInfo; @@ -41,6 +42,7 @@ import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.protocol.DefinedPacket; import java.util.*; +import java.util.function.Consumer; import java.util.logging.Level; public class PluginMessage extends BasicListener { @@ -62,7 +64,7 @@ public class PluginMessage extends BasicListener { private final Lunar lunar = new Lunar(); private final Set knownBrands = new HashSet<>(); - private final Set knownChannels = new HashSet<>(); + private final Map> channelRegisterHandlers = new HashMap<>(); private final Map handlers = new HashMap<>(); public PluginMessage() { @@ -73,21 +75,20 @@ public class PluginMessage extends BasicListener { knownBrands.addAll(Arrays.asList("vanilla", "fabric", "quilt", "forge", "optifine", "Geyser", "labymod")); - knownChannels.addAll(Arrays.asList( + for(String channel : Arrays.asList( "fabric:container/open", "fabric:registry/sync/direct", "fabric:registry/sync", "fabric-screen-handler-api-v1:open_screen", FML.CHANNEL, "fml:loginwrapper", "fml:handshake", "fml:play", "forge:tier_sorting", "forge:split", "forge:login", "forge:handshake", - ApolloManager.PLUGIN_MESSAGE_CHANNEL, "labymod3:main", "labymod:neo", + "labymod3:main", "labymod:neo", "floodgate:skin", "floodgate:form", "floodgate:transfer", "floodgate:packet", "Replay|Restrict", "replaymod:restrict", "WDL|CONTROL", "wdl:control", "tpshud:handshake", "tpshud:tps", //https://github.com/mooziii/tpshud-fabric/tree/main - "xaerominimap:main", "methane_server:statepacket", //https://modrinth.com/mod/methane "servux:structures", //https://modrinth.com/mod/servux "architectury:spawn_entity_packet", //https://modrinth.com/mod/architectury-api @@ -101,7 +102,14 @@ public class PluginMessage extends BasicListener { //https://github.com/Noxcrew/noxesium "noxesium-v1:reset", "noxesium-v1:change_server_rules", "noxesium-v1:server_info", "noxesium-v1:mcc_server", "noxesium-v1:mcc_game_state", "noxesium-v1:reset_server_rules" - )); + )) + channelRegisterHandlers.put(channel, player -> {}); + + channelRegisterHandlers.put(ApolloManager.PLUGIN_MESSAGE_CHANNEL, lunar::sendRestrictions); + channelRegisterHandlers.put("xaerominimap:main", player -> player.sendMessage(ChatMessageType.SYSTEM, new TextComponent("§n§o§m§i§n§i§m§a§p"))); //https://www.curseforge.com/minecraft/mc-mods/xaeros-minimap + channelRegisterHandlers.put("litemoretica:init_easy_place", player -> player.disconnect(ChatSender.of(player).parseToComponent(false, new Message("MOD_YELLOW_SING", "litematica")))); //https://github.com/Earthcomputer/litemoretica/tree/master + channelRegisterHandlers.put("voxelmap:settings", player -> player.disconnect(ChatSender.of(player).parseToComponent(false, new Message("MOD_YELLOW_SING", "voxelmap")))); //https://modrinth.com/mod/voxelmap-updated undocumented + channelRegisterHandlers.put("worldinfo:world_id", player -> player.disconnect(ChatSender.of(player).parseToComponent(false, new Message("MOD_YELLOW_SING", "minimap")))); // JourneyMap and VoxelMap registerBiDirPassthrough("worldedit:cui"); @@ -167,7 +175,7 @@ public class PluginMessage extends BasicListener { private void registerPassthroughToClient(String... channels) { for(String channel : channels) { - knownChannels.add(channel); + channelRegisterHandlers.put(channel, player -> {}); register(channel, false, directional(PASS_THROUGH, UNKNOWN)); } } @@ -179,7 +187,7 @@ public class PluginMessage extends BasicListener { private void registerBiDirPassthrough(String... channels) { for(String channel : channels) { - knownChannels.add(channel); + channelRegisterHandlers.put(channel, player -> {}); register(channel, false, PASS_THROUGH); } } @@ -194,13 +202,7 @@ public class PluginMessage extends BasicListener { ProxiedPlayer player = (ProxiedPlayer) event.getSender(); for(String channel : new String(event.getData()).split("\0")) { - if(channel.equals(ApolloManager.PLUGIN_MESSAGE_CHANNEL)) - lunar.sendRestrictions(player); - else if(channel.equals("xaerominimap:main")) - player.sendMessage(ChatMessageType.SYSTEM, new TextComponent("§n§o§m§i§n§i§m§a§p")); // https://www.curseforge.com/minecraft/mc-mods/xaeros-minimap - - if(!knownChannels.contains(channel)) - BungeeCore.get().getLogger().log(Level.WARNING, () -> player.getName() + " registered unknown channel " + channel); + channelRegisterHandlers.getOrDefault(channel, p -> BungeeCore.get().getLogger().log(Level.WARNING, () -> p.getName() + " registered unknown channel " + channel)).accept(player); } PASS_THROUGH.handle(event); @@ -218,12 +220,11 @@ public class PluginMessage extends BasicListener { ProxiedPlayer player = (ProxiedPlayer) event.getSender(); ByteBuf buf = Unpooled.wrappedBuffer(event.getData()); String brand = DefinedPacket.readString(buf); + boolean lunarclient = brand.startsWith("lunarclient:"); - if(brand.startsWith("lunarclient:")) { + BungeeCore.get().getLogger().log(knownBrands.contains(brand) || lunarclient ? Level.INFO : Level.WARNING, () -> player.getName() + " joins with brand: " + brand); + if(lunarclient) lunar.sendRestrictions(player); - } else if(!knownBrands.contains(brand)) { - BungeeCore.get().getLogger().log(Level.WARNING, () -> player.getName() + " joined with unknown brand " + brand); - } PASS_THROUGH.handle(event); } diff --git a/src/de/steamwar/bungeecore/mods/ModUtils.java b/src/de/steamwar/bungeecore/mods/ModUtils.java index a9e45a1..40a1790 100644 --- a/src/de/steamwar/bungeecore/mods/ModUtils.java +++ b/src/de/steamwar/bungeecore/mods/ModUtils.java @@ -54,6 +54,7 @@ public class ModUtils { public static boolean handleMods(UUID uuid, Locale locale, Consumer disconnect, List mods){ SteamwarUser user = SteamwarUser.get(uuid); playerModMap.put(uuid,new ArrayList<>(mods)); + BungeeCore.get().getLogger().log(Level.INFO, user.getUserName() + " declares mods: " + mods.stream().map(mod -> mod.getPlatform() + ":" + mod.getModName()).collect(Collectors.joining(" "))); ModType max = ModType.YELLOW; Iterator it = mods.iterator();