Merge pull request 'Add techhiderbug command.' (#36) from FightSystem/techhiderbug into main

Reviewed-on: SteamWar/SteamWar#36
Reviewed-by: YoyoNow <yoyonow@noreply.localhost>
This commit is contained in:
2025-04-07 21:22:39 +02:00
10 changed files with 89 additions and 1 deletions
@@ -29,4 +29,5 @@ dependencies {
compileOnly(libs.worldedit15) compileOnly(libs.worldedit15)
compileOnly(libs.fastutil) compileOnly(libs.fastutil)
compileOnly(libs.authlib) compileOnly(libs.authlib)
compileOnly(libs.netty)
} }
@@ -156,6 +156,7 @@ public class FightSystem extends JavaPlugin {
new LockschemCommand(); new LockschemCommand();
new StateCommand(); new StateCommand();
new SkipCommand(); new SkipCommand();
new TechhiderbugCommand();
new TPSWarpCommand(); new TPSWarpCommand();
new UnrankCommand(); new UnrankCommand();
new WinCommand(); new WinCommand();
@@ -0,0 +1,71 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.commands;
import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand;
import de.steamwar.sql.SWException;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import java.io.StringWriter;
import java.util.Arrays;
public class TechhiderbugCommand implements CommandExecutor {
public TechhiderbugCommand() {
new StateDependentCommand(ArenaMode.All, FightState.All, "techhiderbug", this);
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) {
StringWriter writer = new StringWriter();
writer.append("ArenaMode: ").append(Config.mode.name()).append('\n');
writer.append("FightState: ").append(FightState.getFightState().name()).append('\n');
writer.append("TechHider enabled: ").append(FightState.getStateDependentFeatures().get(FightSystem.getTechHider()).toString()).append('\n');
writer.append("Arena region: ").append(Config.ArenaRegion.toString()).append('\n');
writer.append("Team regions: ");
Fight.teams().forEach(t -> writer.append(t.getName()).append(':').append(t.getExtendRegion().toString()).append(' '));
writer.append('\n');
writer.append("HullHider regions: ");
FightSystem.getHullHider().getHullMap().forEach((t, h) -> writer.append(t.getName()).append(':').append(h.getRegion().toString()).append(' '));
writer.append('\n');
writer.append("Hidden regions: ");
FightSystem.getTechHider().getHiddenRegion().forEach((p, r) -> writer.append(p.getName()).append(':').append(r.toString()).append(' '));
writer.append('\n');
writer.append('\n').append("Netty pipelines:\n");
Bukkit.getOnlinePlayers().forEach(p -> writer.append(p.getName()).append(": ").append(String.join(" ", TinyProtocol.instance.getPlayerInterceptors().get(p).getChannel().pipeline().names())).append('\n'));
SWException.log("Techhider-Bug reported by " + sender.getName() + ": " + Arrays.toString(args), writer.toString());
return false;
}
}
@@ -49,6 +49,7 @@ public enum FightState {
public static final Set<FightState> AntiIngame = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PRE_RUNNING, RUNNING))); public static final Set<FightState> AntiIngame = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PRE_RUNNING, RUNNING)));
public static final Set<FightState> AntiSpectate = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(SPECTATE))); public static final Set<FightState> AntiSpectate = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(SPECTATE)));
@Getter
private static final Map<IStateDependent, Boolean> stateDependentFeatures = new HashMap<>(); private static final Map<IStateDependent, Boolean> stateDependentFeatures = new HashMap<>();
@Getter @Getter
private static FightState fightState = PRE_LEADER_SETUP; private static FightState fightState = PRE_LEADER_SETUP;
@@ -45,6 +45,7 @@ public class Hull {
return material.isOccluding() || Config.HiddenBlocks.contains(material); return material.isOccluding() || Config.HiddenBlocks.contains(material);
} }
@Getter
private final Region region; private final Region region;
private final boolean groundVisible; private final boolean groundVisible;
private final IntVector[] directions; private final IntVector[] directions;
@@ -33,6 +33,7 @@ import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.states.StateDependentTask; import de.steamwar.fightsystem.states.StateDependentTask;
import de.steamwar.techhider.TechHider; import de.steamwar.techhider.TechHider;
import lombok.Getter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@@ -56,6 +57,7 @@ import java.util.function.Function;
public class HullHider implements Listener { public class HullHider implements Listener {
@Getter
private final Map<FightTeam, Hull> hullMap = new HashMap<>(); private final Map<FightTeam, Hull> hullMap = new HashMap<>();
private final Hull[] hulls; private final Hull[] hulls;
private final Map<Class<?>, BiFunction<Player, Object, Object>> packetHiders = new HashMap<>(); private final Map<Class<?>, BiFunction<Player, Object, Object>> packetHiders = new HashMap<>();
@@ -159,4 +159,9 @@ public class Region {
public interface TriConsumer<T, V, U>{ public interface TriConsumer<T, V, U>{
void accept(T x, V y, U z); void accept(T x, V y, U z);
} }
@Override
public String toString() {
return minX + "," + minY + "," + minZ + "->" + maxX + "," + maxY + "," + maxZ;
}
} }
@@ -32,6 +32,7 @@ import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.techhider.TechHider; import de.steamwar.techhider.TechHider;
import lombok.Getter;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@@ -51,6 +52,7 @@ public class TechHiderWrapper extends StateDependent implements TechHider.Locati
public static final boolean ENABLED = !Config.OnlyPublicSchematics && !Config.test() && Config.TechhiderActive; public static final boolean ENABLED = !Config.OnlyPublicSchematics && !Config.test() && Config.TechhiderActive;
@Getter
private final ConcurrentHashMap<Player, Region> hiddenRegion = new ConcurrentHashMap<>(); private final ConcurrentHashMap<Player, Region> hiddenRegion = new ConcurrentHashMap<>();
private final ConcurrentHashMap<Player, Long> patterns = new ConcurrentHashMap<>(); private final ConcurrentHashMap<Player, Long> patterns = new ConcurrentHashMap<>();
private final TechHider techHider; private final TechHider techHider;
@@ -27,4 +27,5 @@ commands:
resettb: resettb:
tpslimit: tpslimit:
tpswarp: tpswarp:
techhiderbug:
unrank: unrank:
@@ -23,6 +23,7 @@ import de.steamwar.Reflection;
import de.steamwar.Reflection.Field; import de.steamwar.Reflection.Field;
import de.steamwar.core.Core; import de.steamwar.core.Core;
import io.netty.channel.*; import io.netty.channel.*;
import lombok.Getter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@@ -67,6 +68,7 @@ public class TinyProtocol implements Listener {
private boolean closed; private boolean closed;
private final Map<Class<?>, List<BiFunction<Player, Object, Object>>> packetFilters = new HashMap<>(); private final Map<Class<?>, List<BiFunction<Player, Object, Object>>> packetFilters = new HashMap<>();
@Getter
private final Map<Player, PacketInterceptor> playerInterceptors = new HashMap<>(); private final Map<Player, PacketInterceptor> playerInterceptors = new HashMap<>();
private TinyProtocol(final Plugin plugin) { private TinyProtocol(final Plugin plugin) {
@@ -136,8 +138,9 @@ public class TinyProtocol implements Listener {
private static final Field<Channel> getChannel = Reflection.getField(networkManager, Channel.class, 0); private static final Field<Channel> getChannel = Reflection.getField(networkManager, Channel.class, 0);
private static final Field<UUID> getUUID = Reflection.getField(networkManager, UUID.class, 0); private static final Field<UUID> getUUID = Reflection.getField(networkManager, UUID.class, 0);
private final class PacketInterceptor extends ChannelDuplexHandler { public final class PacketInterceptor extends ChannelDuplexHandler {
private final Player player; private final Player player;
@Getter
private final Channel channel; private final Channel channel;
private PacketInterceptor(Player player) { private PacketInterceptor(Player player) {