From 6f4b2c83b2ef3203a0c200ca231c4473862b86d6 Mon Sep 17 00:00:00 2001 From: Thomas Vanmellaerts Date: Wed, 26 Sep 2018 19:56:47 +0200 Subject: [PATCH] Delete EventUtil --- .../client/ClientPlaySessionHandler.java | 12 ++++++++-- .../velocitypowered/proxy/util/EventUtil.java | 22 ------------------- 2 files changed, 10 insertions(+), 24 deletions(-) delete mode 100644 proxy/src/main/java/com/velocitypowered/proxy/util/EventUtil.java diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java index bd315ff1e..bc0856f8c 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java @@ -2,6 +2,7 @@ package com.velocitypowered.proxy.connection.client; import com.velocitypowered.api.event.connection.DisconnectEvent; import com.velocitypowered.api.event.connection.PluginMessageEvent; +import com.velocitypowered.api.event.player.PlayerChatEvent; import com.velocitypowered.api.proxy.messages.ChannelIdentifier; import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; @@ -11,7 +12,6 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket; import com.velocitypowered.proxy.protocol.ProtocolConstants; import com.velocitypowered.proxy.protocol.packet.*; import com.velocitypowered.proxy.protocol.util.PluginMessageUtil; -import com.velocitypowered.proxy.util.EventUtil; import com.velocitypowered.proxy.util.ThrowableUtils; import io.netty.buffer.ByteBuf; import net.kyori.text.TextComponent; @@ -94,7 +94,15 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler { return; } } else { - EventUtil.callPlayerChatEvent(server, player, msg, chat); + PlayerChatEvent event = new PlayerChatEvent(player, msg); + server.getEventManager().fire(event) + .thenAcceptAsync(pme -> { + if (pme.getResult().equals(PlayerChatEvent.ChatResult.allowed())){ + player.getConnectedServer().getMinecraftConnection().write(chat); + } else if (pme.getResult().isAllowed() && pme.getResult().getMessage().isPresent()){ + player.getConnectedServer().getMinecraftConnection().write(Chat.createServerbound(pme.getResult().getMessage().get())); + } + }, player.getConnectedServer().getMinecraftConnection().getChannel().eventLoop()); } return; } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/util/EventUtil.java b/proxy/src/main/java/com/velocitypowered/proxy/util/EventUtil.java deleted file mode 100644 index 9ceaed50b..000000000 --- a/proxy/src/main/java/com/velocitypowered/proxy/util/EventUtil.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.velocitypowered.proxy.util; - -import com.velocitypowered.api.event.player.PlayerChatEvent; -import com.velocitypowered.proxy.VelocityServer; -import com.velocitypowered.proxy.connection.client.ConnectedPlayer; -import com.velocitypowered.proxy.protocol.packet.Chat; - -public class EventUtil { - - public static void callPlayerChatEvent(VelocityServer server, ConnectedPlayer player, String message, Chat original){ - PlayerChatEvent event = new PlayerChatEvent(player, message); - server.getEventManager().fire(event) - .thenAcceptAsync(pme -> { - if (pme.getResult().equals(PlayerChatEvent.ChatResult.allowed())){ - player.getConnectedServer().getMinecraftConnection().write(original); - } else if (pme.getResult().isAllowed() && pme.getResult().getMessage().isPresent()){ - player.getConnectedServer().getMinecraftConnection().write(Chat.createServerbound(pme.getResult().getMessage().get())); - } - }, player.getConnectedServer().getMinecraftConnection().getChannel().eventLoop()); - } - -}