Merge branch 'main' into SpigotCore/RDisplay

This commit is contained in:
2025-03-11 21:49:27 +01:00
195 changed files with 10297 additions and 580 deletions
@@ -22,10 +22,8 @@ package com.comphenix.tinyprotocol;
import de.steamwar.Reflection;
import de.steamwar.Reflection.Field;
import de.steamwar.core.Core;
import io.netty.channel.Channel;
import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
import io.netty.channel.*;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -57,15 +55,14 @@ public class TinyProtocol implements Listener {
private static final Class<?> networkManager = Reflection.getClass("net.minecraft.network.NetworkManager");
public static final Field<List> networkManagers = Reflection.getField(serverConnection, List.class, 0, networkManager);
private static final String HANDLER_NAME = "tiny-steamwar";
public static final TinyProtocol instance = new TinyProtocol(Core.getInstance());
private static int id = 0;
public static void init() {
//enforce init
}
private final Plugin plugin;
private final String handlerName;
private final List<?> connections;
private boolean closed;
@@ -74,7 +71,6 @@ public class TinyProtocol implements Listener {
private TinyProtocol(final Plugin plugin) {
this.plugin = plugin;
this.handlerName = "tiny-" + plugin.getName() + "-" + ++id;
this.connections = networkManagers.get(getServerConnection(plugin));
plugin.getServer().getPluginManager().registerEvents(this, plugin);
@@ -148,7 +144,7 @@ public class TinyProtocol implements Listener {
this.player = player;
channel = getChannel.get(connections.stream().filter(connection -> player.getUniqueId().equals(getUUID.get(connection))).findAny().orElseThrow(() -> {
player.kickPlayer("An injection failure happend.");
Bukkit.getScheduler().runTask(plugin, () -> player.kickPlayer("Connection failure."));
return new SecurityException("Could not find channel for player " + player.getName());
}));
@@ -159,7 +155,12 @@ public class TinyProtocol implements Listener {
playerInterceptors.put(player, this);
}
channel.pipeline().addBefore("packet_handler", handlerName, this);
try {
channel.pipeline().addBefore("packet_handler", HANDLER_NAME, this);
} catch (IllegalArgumentException e) {
Bukkit.getScheduler().runTask(plugin, () -> player.kickPlayer("Connection failure."));
throw new SecurityException(e);
}
}
private void sendPacket(Object packet) {
@@ -174,7 +175,7 @@ public class TinyProtocol implements Listener {
if(channel.isActive()) {
channel.eventLoop().execute(() -> {
try {
channel.pipeline().remove(handlerName);
channel.pipeline().remove(HANDLER_NAME);
} catch (NoSuchElementException e) {
// ignore
}
@@ -35,7 +35,7 @@ public class PlayerJoinedEvent implements Listener{
@EventHandler(priority = EventPriority.LOWEST)
private void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
SteamwarUser user = Statement.productionDatabase() ? SteamwarUser.get(player.getUniqueId()) : SteamwarUser.getOrCreate(player.getUniqueId(), player.getName(), uuid -> {}, (oldName, newName) -> {});
SteamwarUser user = Statement.productionDatabase() ? SteamwarUser.get(player.getUniqueId()) : SteamwarUser.getOrCreate(player.getUniqueId(), player.getName(), uuid -> {});
UserPerm.Prefix prefix = user.prefix();
if(prefix != UserPerm.emptyPrefix) {
@@ -19,22 +19,15 @@
package de.steamwar.providers;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import java.util.UUID;
public class BauServerInfo {
private static Integer bauOwner = null;
static {
try {
bauOwner = Integer.parseInt(Bukkit.getWorlds().get(0).getName());
} catch (NumberFormatException e) {
try {
bauOwner = SteamwarUser.get(UUID.fromString(Bukkit.getWorlds().get(0).getName())).getId();
} catch (IllegalArgumentException ignored) {}
}
} catch (NumberFormatException ignored) {}
}
public static Integer getOwnerId() {
@@ -19,15 +19,16 @@
package de.steamwar.techhider;
import de.steamwar.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.Reflection;
import de.steamwar.core.Core;
import lombok.Getter;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.UnaryOperator;
@@ -91,9 +92,9 @@ public class TechHider {
}
if(Core.getVersion() > 8){
techhiders.put(Reflection.getClass("net.minecraft.network.protocol.game.ServerboundUseItemOnPacket"), (p, packet) -> p.getGameMode() == GameMode.SPECTATOR ? null : packet);
techhiders.put(Reflection.getClass("net.minecraft.network.protocol.game.ServerboundUseItemOnPacket"), (p, packet) -> locationEvaluator.suppressInteractions(p) ? null : packet);
}
techhiders.put(Reflection.getClass("net.minecraft.network.protocol.game.ServerboundInteractPacket"), (p, packet) -> p.getGameMode() == GameMode.SPECTATOR ? null : packet);
techhiders.put(Reflection.getClass("net.minecraft.network.protocol.game.ServerboundInteractPacket"), (p, packet) -> locationEvaluator.suppressInteractions(p) ? null : packet);
}
@@ -161,6 +162,10 @@ public class TechHider {
}
public interface LocationEvaluator {
default boolean suppressInteractions(Player player) {
return false;
}
boolean skipChunk(Player player, int x, int z);
default boolean skipChunkSection(Player player, int x, int y, int z) {
return skipChunk(player, x, z);