From 9572347419a7869775adc3fca33803d3f742339d Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 14 Mar 2024 22:52:50 +0100 Subject: [PATCH] Fix sw:bridge, axiom, bau.steamwar.de Signed-off-by: Lixfel --- .../bungeecore/listeners/PluginMessage.java | 9 ++++----- .../bungeecore/mods/FabricModSender.java | 20 +++++++++++-------- src/de/steamwar/bungeecore/mods/Hostname.java | 4 ++-- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/PluginMessage.java b/src/de/steamwar/bungeecore/listeners/PluginMessage.java index 6c6f0ad..8bf7556 100644 --- a/src/de/steamwar/bungeecore/listeners/PluginMessage.java +++ b/src/de/steamwar/bungeecore/listeners/PluginMessage.java @@ -116,7 +116,7 @@ public class PluginMessage extends BasicListener { "axiom:hello", "axiom:set_gamemode", "axiom:set_fly_speed", "axiom:set_world_time", "axiom:set_world_property", "axiom:set_block", "axiom:set_hotbar_slot", "axiom:switch_active_hotbar", "axiom:teleport", "axiom:set_editor_views", "axiom:request_chunk_data", "axiom:spawn_entity", - "axiom:manipulate_entity", "axiom:delete_entity", "axiom:marker_nbt_request" + "axiom:manipulate_entity", "axiom:delete_entity", "axiom:marker_nbt_request", "axiom:set_buffer" ); register("REGISTER", false, directional(this::serverRegistersChannel, this::clientRegistersChannel)); @@ -129,7 +129,8 @@ public class PluginMessage extends BasicListener { register("MC|Brand", false, directional(this::steamWarBrand, this::userBrand)); register("minecraft:brand", false, directional(this::steamWarBrand, this::userBrand)); - register("sw:bridge", false, directional(onlySWSource(async(event -> NetworkPacket.handle(new ServerMetaInfo(((Server) event.getSender()).getInfo()), event.getData()))), UNKNOWN)); + //Needs to be registered cause paper refuses to send PluginMessages on unregistered channels... + register("sw:bridge", true, directional(onlySWSource(async(event -> NetworkPacket.handle(new ServerMetaInfo(((Server) event.getSender()).getInfo()), event.getData()))), UNKNOWN)); register("sw:hotkeys", false, directional(UNKNOWN, PASS_THROUGH)); register("fabricmodsender:mods", true, directional(UNKNOWN, async(fabricModSender::handlePluginMessage))); @@ -172,10 +173,8 @@ public class PluginMessage extends BasicListener { } private void registerPassthroughToServer(String... channels) { - for(String channel : channels) { - knownChannels.add(channel); + for(String channel : channels) register(channel, false, directional(UNKNOWN, PASS_THROUGH)); - } } private void registerBiDirPassthrough(String... channels) { diff --git a/src/de/steamwar/bungeecore/mods/FabricModSender.java b/src/de/steamwar/bungeecore/mods/FabricModSender.java index e75e470..d064861 100644 --- a/src/de/steamwar/bungeecore/mods/FabricModSender.java +++ b/src/de/steamwar/bungeecore/mods/FabricModSender.java @@ -43,13 +43,17 @@ import java.util.concurrent.TimeUnit; public class FabricModSender extends BasicListener { - private final Set neededMods = new HashSet<>(); + private final Set neededFabricMods = new HashSet<>(); + private final Set neededQuiltMods = new HashSet<>(); public FabricModSender() { - neededMods.add("java"); - neededMods.add("minecraft"); - neededMods.add("fabricloader"); - neededMods.add("steamwarmodsender"); + neededFabricMods.add("java"); + neededFabricMods.add("minecraft"); + neededFabricMods.add("steamwarmodsender"); + neededQuiltMods.addAll(neededFabricMods); + + neededFabricMods.add("fabricloader"); + neededQuiltMods.add("quilt_loader"); BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> { synchronized (Storage.fabricExpectPluginMessage) { @@ -95,7 +99,7 @@ public class FabricModSender extends BasicListener { mods.add(Mod.getOrCreate(mod.getAsString(), Mod.Platform.FABRIC)); } - if(!neededModsContained(mods)) { + if(!neededModsContained(neededFabricMods, mods) && !neededModsContained(neededQuiltMods, mods)) { logMessage(user, "Needed mods are not contained", data); return; } @@ -128,11 +132,11 @@ public class FabricModSender extends BasicListener { } } - private boolean neededModsContained(List mods) { + private boolean neededModsContained(Set neededMods, List mods) { return mods.stream() .map(Mod::getModName) .filter(neededMods::contains) - .count() == neededMods.size(); + .count() == neededFabricMods.size(); } private void logMessage(SteamwarUser user, String reason, String data) { diff --git a/src/de/steamwar/bungeecore/mods/Hostname.java b/src/de/steamwar/bungeecore/mods/Hostname.java index 0c28183..2639094 100644 --- a/src/de/steamwar/bungeecore/mods/Hostname.java +++ b/src/de/steamwar/bungeecore/mods/Hostname.java @@ -54,12 +54,12 @@ public class Hostname extends BasicListener { @EventHandler public void onHandshake(PlayerHandshakeEvent event) { + String hostname = event.getHandshake().getHost().toLowerCase(); String extraDataInHandshake = ((InitialHandler) event.getConnection()).getExtraDataInHandshake(); - if (!knownHostnames.contains(event.getHandshake().getHost().toLowerCase())) { + if (!knownHostnames.contains(hostname) && !hostname.endsWith(".steamwar.de")) { BungeeCore.get().getLogger().log(Level.WARNING, () -> event.getConnection().getSocketAddress() + " connected with unknown hostname " + event.getHandshake() + " " + extraDataInHandshake); } else if (!knownExtraData.contains(extraDataInHandshake)) { BungeeCore.get().getLogger().log(Level.WARNING, () -> event.getConnection().getSocketAddress() + " connected with unknown extra data " + event.getHandshake() + " " + extraDataInHandshake); - } } }