SteamWar/SpigotCore
Archiviert
13
0

Merge branch 'ServerDataHandler'
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

# Conflicts:
#	SpigotCore_19/src/de/steamwar/core/ChatWrapper19.java
#	SpigotCore_8/src/de/steamwar/core/ChatWrapper8.java
#	SpigotCore_Main/src/de/steamwar/core/ChatWrapper.java
Dieser Commit ist enthalten in:
Lixfel 2022-08-27 11:12:29 +02:00
Commit 751a986b3b
5 geänderte Dateien mit 42 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -19,12 +19,23 @@
package de.steamwar.core; package de.steamwar.core;
import com.comphenix.tinyprotocol.Reflection;
import net.minecraft.network.chat.IChatMutableComponent; import net.minecraft.network.chat.IChatMutableComponent;
import net.minecraft.network.chat.contents.LiteralContents; import net.minecraft.network.chat.contents.LiteralContents;
import net.minecraft.network.protocol.game.ClientboundServerDataPacket;
public class ChatWrapper19 implements ChatWrapper { public class ChatWrapper19 implements ChatWrapper {
@Override @Override
public Object stringToChatComponent(String text) { public Object stringToChatComponent(String text) {
return IChatMutableComponent.a(new LiteralContents(text)); return IChatMutableComponent.a(new LiteralContents(text));
} }
private static final Reflection.FieldAccessor<Boolean> accessor = Reflection.getField(ClientboundServerDataPacket.class, boolean.class,0);
@Override
public Object modifyServerDataPacket(Object o) {
ClientboundServerDataPacket clientboundServerDataPacket = (ClientboundServerDataPacket) o;
accessor.set(clientboundServerDataPacket,true);
return clientboundServerDataPacket;
}
} }

Datei anzeigen

@ -28,4 +28,9 @@ public class ChatWrapper8 implements ChatWrapper {
public Object stringToChatComponent(String text) { public Object stringToChatComponent(String text) {
return chatComponentConstructor.invoke(text); return chatComponentConstructor.invoke(text);
} }
@Override
public Object modifyServerDataPacket(Object o) {
return null;
}
} }

Datei anzeigen

@ -23,4 +23,6 @@ public interface ChatWrapper {
ChatWrapper impl = VersionDependent.getVersionImpl(Core.getInstance()); ChatWrapper impl = VersionDependent.getVersionImpl(Core.getInstance());
Object stringToChatComponent(String text); Object stringToChatComponent(String text);
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.core.events.WorldLoadEvent;
import de.steamwar.message.Message; import de.steamwar.message.Message;
import de.steamwar.network.NetworkReceiver; import de.steamwar.network.NetworkReceiver;
import de.steamwar.network.handlers.ServerDataHandler;
import de.steamwar.sql.Statement; import de.steamwar.sql.Statement;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -131,6 +132,9 @@ public class Core extends JavaPlugin{
if(Core.getVersion() < 17 && Bukkit.getPluginManager().getPlugin("ViaVersion") != null) if(Core.getVersion() < 17 && Bukkit.getPluginManager().getPlugin("ViaVersion") != null)
new PartialChunkFixer(); new PartialChunkFixer();
if(Core.getVersion() >= 19)
new ServerDataHandler();
try { try {
getLogger().log(Level.INFO, "Running on: " + new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec("hostname").getInputStream())).readLine()); getLogger().log(Level.INFO, "Running on: " + new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec("hostname").getInputStream())).readLine());
} catch (IOException e) { } 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<?> serverDataPacket = Reflection.getClass("{nms.network.protocol.game}.ClientboundServerDataPacket");
public ServerDataHandler() {
TinyProtocol.instance.addFilter(serverDataPacket, this::packetFilter);
}
private Object packetFilter(Player player, Object o) {
return ChatWrapper.impl.modifyServerDataPacket(o);
}
}