SteamWar/SpigotCore
Archiviert
13
0

Fix Insecure PopUp (zOnlyKroks made it) #219

Zusammengeführt
Lixfel hat 1 Commits von FixInsecurePopup nach master 2022-12-08 21:19:13 +01:00 zusammengeführt
5 geänderte Dateien mit 3 neuen und 26 gelöschten Zeilen
Nur Änderungen aus Commit 53ab403952 werden angezeigt - Alle Commits anzeigen

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);
}
}