13
0
geforkt von Mirrors/Velocity

Delete EventUtil

Dieser Commit ist enthalten in:
Thomas Vanmellaerts 2018-09-26 19:56:47 +02:00
Ursprung 3acc00de5e
Commit 6f4b2c83b2
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: E1E6E9CCAD13E556
2 geänderte Dateien mit 10 neuen und 24 gelöschten Zeilen

Datei anzeigen

@ -2,6 +2,7 @@ package com.velocitypowered.proxy.connection.client;
import com.velocitypowered.api.event.connection.DisconnectEvent; import com.velocitypowered.api.event.connection.DisconnectEvent;
import com.velocitypowered.api.event.connection.PluginMessageEvent; import com.velocitypowered.api.event.connection.PluginMessageEvent;
import com.velocitypowered.api.event.player.PlayerChatEvent;
import com.velocitypowered.api.proxy.messages.ChannelIdentifier; import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.VelocityServer;
import com.velocitypowered.proxy.connection.MinecraftSessionHandler; 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.ProtocolConstants;
import com.velocitypowered.proxy.protocol.packet.*; import com.velocitypowered.proxy.protocol.packet.*;
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil; import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
import com.velocitypowered.proxy.util.EventUtil;
import com.velocitypowered.proxy.util.ThrowableUtils; import com.velocitypowered.proxy.util.ThrowableUtils;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.kyori.text.TextComponent; import net.kyori.text.TextComponent;
@ -94,7 +94,15 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
return; return;
} }
} else { } 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; return;
} }

Datei anzeigen

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