Merge remote-tracking branch 'origin/master'
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Dieser Commit ist enthalten in:
Commit
d35ef19ba3
@ -32,6 +32,7 @@ public class ChatWrapper8 implements ChatWrapper {
|
||||
return chatComponentConstructor.invoke(text);
|
||||
}
|
||||
|
||||
private static final Class<?> metadataPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityMetadata");
|
||||
private static final Reflection.FieldAccessor<Integer> metadataEntity = Reflection.getField(metadataPacket, int.class, 0);
|
||||
private static final Reflection.FieldAccessor<List> metadataMetadata = Reflection.getField(metadataPacket, List.class, 0);
|
||||
@Override
|
||||
|
@ -19,12 +19,9 @@
|
||||
|
||||
package de.steamwar.core;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
|
||||
public interface ChatWrapper {
|
||||
ChatWrapper impl = VersionDependent.getVersionImpl(Core.getInstance());
|
||||
|
||||
Class<?> metadataPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityMetadata");
|
||||
|
||||
Object stringToChatComponent(String text);
|
||||
|
||||
|
@ -70,7 +70,10 @@ public class ErrorHandler extends Handler {
|
||||
if(logRecord.getThrown() != null)
|
||||
logRecord.getThrown().printStackTrace(new PrintStream(stacktraceOutput));
|
||||
String stacktrace = stacktraceOutput.toString();
|
||||
if(stacktrace.contains("POI data mismatch"))
|
||||
if(stacktrace.contains("POI data mismatch") || stacktrace.contains("Newer version! Server downgrades are not supported!"))
|
||||
return;
|
||||
|
||||
if(message.isEmpty() && stacktrace.isEmpty())
|
||||
return;
|
||||
|
||||
try {
|
||||
@ -140,6 +143,12 @@ public class ErrorHandler extends Handler {
|
||||
startsWith.add("Biome with id");
|
||||
startsWith.add("1.16 and 1.16.1 clients are only partially supported");
|
||||
startsWith.add("Unable to parse CustomName from ");
|
||||
startsWith.add("java.util.ConcurrentModificationException");
|
||||
startsWith.add("com.destroystokyo.paper.exception.ServerInternalException: Attempted to place a tile entity");
|
||||
startsWith.add("World: minecraft:overworld");
|
||||
startsWith.add("Chunk coordinates: ");
|
||||
startsWith.add("Failed to save history");
|
||||
startsWith.add("\t... ");
|
||||
ignoreStartsWith = Collections.unmodifiableList(startsWith);
|
||||
|
||||
List<String> contains = new ArrayList<>();
|
||||
|
@ -27,12 +27,20 @@ import de.steamwar.techhider.ProtocolUtils;
|
||||
import de.steamwar.techhider.TechHider;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class AntiNocom {
|
||||
public class AntiNocom implements Listener {
|
||||
|
||||
private final Map<Player, Integer> flags = new ConcurrentHashMap<>();
|
||||
|
||||
public AntiNocom() {
|
||||
Bukkit.getServer().getPluginManager().registerEvents(this, Core.getInstance());
|
||||
TinyProtocol.instance.addFilter(blockDig, this::onDig);
|
||||
|
||||
if(Core.getVersion() > 8) {
|
||||
@ -40,6 +48,11 @@ public class AntiNocom {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent e) {
|
||||
flags.remove(e.getPlayer());
|
||||
}
|
||||
|
||||
private void registerUseItem() {
|
||||
Class<?> useItem = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseItem");
|
||||
|
||||
@ -56,16 +69,7 @@ public class AntiNocom {
|
||||
|
||||
TinyProtocol.instance.addFilter(useItem, (player, packet) -> {
|
||||
Object pos = getPosition.apply(packet);
|
||||
int x = TechHider.blockPositionX.get(pos);
|
||||
int z = TechHider.blockPositionZ.get(pos);
|
||||
|
||||
if(!player.getWorld().isChunkLoaded(ProtocolUtils.posToChunk(x), ProtocolUtils.posToChunk(z))) {
|
||||
Bukkit.getScheduler().runTask(Core.getInstance(), () -> player.kickPlayer(null));
|
||||
SWException.log(player.getName() + " kicked for using item on unloaded block (potential NoCom-DOS attack)", x + " " + z);
|
||||
return null;
|
||||
}
|
||||
|
||||
return packet;
|
||||
return isValid(player, "UseItem", TechHider.blockPositionX.get(pos), TechHider.blockPositionZ.get(pos)) ? packet : null;
|
||||
});
|
||||
}
|
||||
|
||||
@ -73,13 +77,20 @@ public class AntiNocom {
|
||||
private static final Reflection.FieldAccessor<?> digPosition = Reflection.getField(blockDig, TechHider.blockPosition, 0);
|
||||
private Object onDig(Player player, Object packet) {
|
||||
Object pos = digPosition.get(packet);
|
||||
int x = TechHider.blockPositionX.get(pos);
|
||||
int z = TechHider.blockPositionZ.get(pos);
|
||||
if((x != 0 || z != 0) && !player.getWorld().isChunkLoaded(ProtocolUtils.posToChunk(x), ProtocolUtils.posToChunk(z))) {
|
||||
Bukkit.getScheduler().runTask(Core.getInstance(), () -> player.kickPlayer(null));
|
||||
SWException.log(player.getName() + " kicked for digging an unloaded block (potential NoCom-DOS attack)", x + " " + z);
|
||||
return null;
|
||||
return isValid(player, "Dig", TechHider.blockPositionX.get(pos), TechHider.blockPositionZ.get(pos)) ? packet : null;
|
||||
}
|
||||
|
||||
private boolean isValid(Player player, String type, int x, int z) {
|
||||
if((x == 0 && z == 0) || player.getWorld().isChunkLoaded(ProtocolUtils.posToChunk(x), ProtocolUtils.posToChunk(z)))
|
||||
return true;
|
||||
|
||||
int amount = flags.compute(player, (p, a) -> a == null ? 1 : a+1);
|
||||
if(amount % 8 == 0) { // Only after 8 and every 8 to reduce false flags and spam
|
||||
if(amount == 8) // Schedule player kick only once
|
||||
Bukkit.getScheduler().runTask(Core.getInstance(), () -> player.kickPlayer(null));
|
||||
|
||||
SWException.log(player.getName() + " kicked for potential NoCom-DOS attack", x + " " + z + " " + type + " " + amount);
|
||||
}
|
||||
return packet;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren