SteamWar/SpigotCore
Archiviert
13
0

Merge branch 'master' into coreEntity

Dieser Commit ist enthalten in:
Lixfel 2023-01-09 10:59:30 +01:00
Commit cc65253364
6 geänderte Dateien mit 4 neuen und 27 gelöschten Zeilen

@ -1 +1 @@
Subproject commit 4706c1525ceb40d8ea21aaeed4857ca8a32fd623
Subproject commit c6da22f0bee3865b7b3283bc17275e12c5de14af

Datei anzeigen

@ -19,10 +19,8 @@
package de.steamwar.core;
import com.comphenix.tinyprotocol.Reflection;
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 {
@ -30,12 +28,4 @@ public class ChatWrapper19 implements ChatWrapper {
public Object stringToChatComponent(String 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,9 +28,4 @@ public class ChatWrapper8 implements ChatWrapper {
public Object stringToChatComponent(String text) {
return chatComponentConstructor.invoke(text);
}
@Override
public Object modifyServerDataPacket(Object o) {
return null;
}
}

Datei anzeigen

@ -23,6 +23,4 @@ public interface ChatWrapper {
ChatWrapper impl = VersionDependent.getVersionImpl(Core.getInstance());
Object stringToChatComponent(String text);
Object modifyServerDataPacket(Object o);
}

Datei anzeigen

@ -28,6 +28,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.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.internal.Statement;
@ -122,7 +123,7 @@ public class Core extends JavaPlugin{
Bukkit.getScheduler().runTaskTimer(Core.getInstance(), SchematicNode::clear, 20L * 30, 20L * 30);
if(Core.getVersion() >= 19)
//new ServerDataHandler();
new ServerDataHandler();
try {
getLogger().log(Level.INFO, "Running on: " + new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec("hostname").getInputStream())).readLine());

Datei anzeigen

@ -2,19 +2,12 @@ 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);
TinyProtocol.instance.addFilter(serverDataPacket, (p, o) -> null);
}
}