SteamWar/SpigotCore
Archiviert
13
0

ServerDataHandler
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
zOnlyKroks 2022-08-06 19:29:56 +02:00
Ursprung ed89d2b37b
Commit f1a99b0938
5 geänderte Dateien mit 39 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -23,6 +23,7 @@ import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol;
import net.minecraft.network.chat.IChatMutableComponent;
import net.minecraft.network.chat.contents.LiteralContents;
import net.minecraft.network.protocol.game.ClientboundServerDataPacket;
public class ChatWrapper19 implements ChatWrapper {
@Override
@ -35,4 +36,10 @@ public class ChatWrapper19 implements ChatWrapper {
public String getNameByLoginPacket(Object packet) {
return getName.get(packet);
}
@Override
public Object modifyServerDataPacket(Object o) {
ClientboundServerDataPacket clientboundServerDataPacket = (ClientboundServerDataPacket) o;
return new ClientboundServerDataPacket(clientboundServerDataPacket.b().get(),clientboundServerDataPacket.c().get(),true);
}
}

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.core;
import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol;
import com.mojang.authlib.GameProfile;
import org.bukkit.entity.Player;
public class ChatWrapper8 implements ChatWrapper {
@ -36,4 +37,9 @@ public class ChatWrapper8 implements ChatWrapper {
public String getNameByLoginPacket(Object packet) {
return getGameProfile.get(packet).getName();
}
@Override
public Object modifyServerDataPacket(Object o) {
return null;
}
}

Datei anzeigen

@ -24,4 +24,6 @@ public interface ChatWrapper {
Object stringToChatComponent(String text);
String getNameByLoginPacket(Object packet);
Object modifyServerDataPacket(Object o);
}

Datei anzeigen

@ -31,6 +31,7 @@ import de.steamwar.core.events.PlayerJoinedEvent;
import de.steamwar.core.events.WorldLoadEvent;
import de.steamwar.message.Message;
import de.steamwar.network.NetworkReceiver;
import de.steamwar.network.handlers.ServerDataHandler;
import de.steamwar.sql.Statement;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
@ -132,6 +133,9 @@ public class Core extends JavaPlugin{
if(Core.getVersion() < 17 && Bukkit.getPluginManager().getPlugin("ViaVersion") != null)
new PartialChunkFixer();
if(Core.getVersion() < 18)
new ServerDataHandler();
try {
getLogger().log(Level.INFO, "Running on: " + new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec("hostname").getInputStream())).readLine());
} catch (IOException e) {

Datei anzeigen

@ -0,0 +1,20 @@
package de.steamwar.network.handlers;
import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.core.ChatWrapper;
import de.steamwar.core.CraftbukkitWrapper;
import org.bukkit.entity.Player;
public class ServerDataHandler {
private Class<?> explosionPacket = Reflection.getClass("{nms.network.protocol.game}.ClientboundServerDataPacket");
public ServerDataHandler() {
TinyProtocol.instance.addFilter(explosionPacket, this::packetFilter);
}
private Object packetFilter(Player player, Object o) {
return ChatWrapper.impl.modifyServerDataPacket(o);
}
}