Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-20 06:50:08 +01:00
Fix PacketWrapper#sendToServer bypassing ProtocolLib (#2229)
Dieser Commit ist enthalten in:
Ursprung
8de26a0ad3
Commit
24c56a239e
@ -17,6 +17,7 @@ import us.myles.ViaVersion.api.platform.ViaPlatform;
|
|||||||
import us.myles.ViaVersion.bukkit.classgenerator.ClassGenerator;
|
import us.myles.ViaVersion.bukkit.classgenerator.ClassGenerator;
|
||||||
import us.myles.ViaVersion.bukkit.commands.BukkitCommandHandler;
|
import us.myles.ViaVersion.bukkit.commands.BukkitCommandHandler;
|
||||||
import us.myles.ViaVersion.bukkit.commands.BukkitCommandSender;
|
import us.myles.ViaVersion.bukkit.commands.BukkitCommandSender;
|
||||||
|
import us.myles.ViaVersion.bukkit.listeners.ProtocolLibEnableListener;
|
||||||
import us.myles.ViaVersion.bukkit.platform.BukkitTaskId;
|
import us.myles.ViaVersion.bukkit.platform.BukkitTaskId;
|
||||||
import us.myles.ViaVersion.bukkit.platform.BukkitViaAPI;
|
import us.myles.ViaVersion.bukkit.platform.BukkitViaAPI;
|
||||||
import us.myles.ViaVersion.bukkit.platform.BukkitViaConfig;
|
import us.myles.ViaVersion.bukkit.platform.BukkitViaConfig;
|
||||||
@ -48,13 +49,19 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform<Player>
|
|||||||
|
|
||||||
// Command handler
|
// Command handler
|
||||||
commandHandler = new BukkitCommandHandler();
|
commandHandler = new BukkitCommandHandler();
|
||||||
|
|
||||||
// Init platform
|
// Init platform
|
||||||
|
BukkitViaInjector injector = new BukkitViaInjector();
|
||||||
|
injector.setProtocolLib(Bukkit.getPluginManager().getPlugin("ProtocolLib") != null);
|
||||||
|
Bukkit.getPluginManager().registerEvents(new ProtocolLibEnableListener(injector), this);
|
||||||
|
|
||||||
Via.init(ViaManager.builder()
|
Via.init(ViaManager.builder()
|
||||||
.platform(this)
|
.platform(this)
|
||||||
.commandHandler(commandHandler)
|
.commandHandler(commandHandler)
|
||||||
.injector(new BukkitViaInjector())
|
.injector(injector)
|
||||||
.loader(new BukkitViaLoader(this))
|
.loader(new BukkitViaLoader(this))
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
// Config magic
|
// Config magic
|
||||||
conf = new BukkitViaConfig();
|
conf = new BukkitViaConfig();
|
||||||
|
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
package us.myles.ViaVersion.bukkit.listeners;
|
||||||
|
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.server.PluginDisableEvent;
|
||||||
|
import org.bukkit.event.server.PluginEnableEvent;
|
||||||
|
import us.myles.ViaVersion.bukkit.platform.BukkitViaInjector;
|
||||||
|
|
||||||
|
public class ProtocolLibEnableListener implements Listener {
|
||||||
|
private final BukkitViaInjector injector;
|
||||||
|
|
||||||
|
public ProtocolLibEnableListener(BukkitViaInjector injector) {
|
||||||
|
this.injector = injector;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPluginEnable(PluginEnableEvent e) {
|
||||||
|
if (e.getPlugin().getName().equals("ProtocolLib")) {
|
||||||
|
injector.setProtocolLib(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPluginDisable(PluginDisableEvent e) {
|
||||||
|
if (e.getPlugin().getName().equals("ProtocolLib")) {
|
||||||
|
injector.setProtocolLib(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -26,6 +26,8 @@ public class BukkitViaInjector implements ViaInjector {
|
|||||||
private final List<ChannelFuture> injectedFutures = new ArrayList<>();
|
private final List<ChannelFuture> injectedFutures = new ArrayList<>();
|
||||||
private final List<Pair<Field, Object>> injectedLists = new ArrayList<>();
|
private final List<Pair<Field, Object>> injectedLists = new ArrayList<>();
|
||||||
|
|
||||||
|
private boolean protocolLib;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inject() throws Exception {
|
public void inject() throws Exception {
|
||||||
try {
|
try {
|
||||||
@ -214,7 +216,7 @@ public class BukkitViaInjector implements ViaInjector {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDecoderName() {
|
public String getDecoderName() {
|
||||||
return "decoder";
|
return protocolLib ? "protocol_lib_decoder" : "decoder";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object getServerConnection() throws Exception {
|
public static Object getServerConnection() throws Exception {
|
||||||
@ -339,4 +341,8 @@ public class BukkitViaInjector implements ViaInjector {
|
|||||||
field.set(connection, list);
|
field.set(connection, list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setProtocolLib(boolean protocolLib) {
|
||||||
|
this.protocolLib = protocolLib;
|
||||||
|
}
|
||||||
}
|
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren