# 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:
Commit
751a986b3b
@ -19,12 +19,23 @@
|
||||
|
||||
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 {
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -28,4 +28,9 @@ public class ChatWrapper8 implements ChatWrapper {
|
||||
public Object stringToChatComponent(String text) {
|
||||
return chatComponentConstructor.invoke(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object modifyServerDataPacket(Object o) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -23,4 +23,6 @@ public interface ChatWrapper {
|
||||
ChatWrapper impl = VersionDependent.getVersionImpl(Core.getInstance());
|
||||
|
||||
Object stringToChatComponent(String text);
|
||||
|
||||
Object modifyServerDataPacket(Object o);
|
||||
}
|
||||
|
@ -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;
|
||||
@ -131,6 +132,9 @@ public class Core extends JavaPlugin{
|
||||
if(Core.getVersion() < 17 && Bukkit.getPluginManager().getPlugin("ViaVersion") != null)
|
||||
new PartialChunkFixer();
|
||||
|
||||
if(Core.getVersion() >= 19)
|
||||
new ServerDataHandler();
|
||||
|
||||
try {
|
||||
getLogger().log(Level.INFO, "Running on: " + new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec("hostname").getInputStream())).readLine());
|
||||
} catch (IOException e) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren