Revert add entity translator shenanigans, re-add viaproxy console command event handler to deal with console commands

This commit is contained in:
onebeastchris 2024-04-20 13:21:41 +02:00
parent 8245b0f8a5
commit 55ebb95270
2 changed files with 11 additions and 3 deletions

View File

@ -30,6 +30,7 @@ import net.raphimc.viaproxy.ViaProxy;
import net.raphimc.viaproxy.cli.options.Options;
import net.raphimc.viaproxy.plugins.PluginManager;
import net.raphimc.viaproxy.plugins.ViaProxyPlugin;
import net.raphimc.viaproxy.plugins.events.ConsoleCommandEvent;
import net.raphimc.viaproxy.plugins.events.ProxyStartEvent;
import net.raphimc.viaproxy.plugins.events.ProxyStopEvent;
import net.raphimc.viaproxy.plugins.events.ShouldVerifyOnlineModeEvent;
@ -83,6 +84,16 @@ public class GeyserViaProxyPlugin extends ViaProxyPlugin implements GeyserBootst
this.onGeyserShutdown();
}
@EventHandler
private void onConsoleCommand(final ConsoleCommandEvent event) {
final String command = event.getCommand().startsWith("/") ? event.getCommand().substring(1) : event.getCommand();
CommandRegistry registry = this.getCommandRegistry();
if (registry.cloud().rootCommands().contains(command)) {
registry.runCommand(this.getGeyserLogger(), command + " " + String.join(" ", event.getArgs()));
event.setCancelled(true);
}
}
@EventHandler
private void onShouldVerifyOnlineModeEvent(final ShouldVerifyOnlineModeEvent event) {
final UUID uuid = event.getProxyConnection().getGameProfile().getId();

View File

@ -112,9 +112,6 @@ public class JavaAddEntityTranslator extends PacketTranslator<ClientboundAddEnti
} else {
return;
}
} else if (packet.getType() == EntityType.EXPERIENCE_ORB) {
//TODO: spawn exp orb here; we dont have a factory.
return;
} else {
entity = definition.factory().create(session, packet.getEntityId(), session.getEntityCache().getNextEntityId().incrementAndGet(),
packet.getUuid(), definition, position, motion, yaw, pitch, headYaw);