From d3bada58d4cb7d781041e088737258f14d390ad1 Mon Sep 17 00:00:00 2001 From: md_5 Date: Tue, 2 Jul 2013 10:45:04 +1000 Subject: [PATCH] Close #469 - chat event setMessage --- .../net/md_5/bungee/protocol/packet/Packet3Chat.java | 2 ++ .../net/md_5/bungee/connection/UpstreamBridge.java | 12 +++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Packet3Chat.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Packet3Chat.java index ad8b21f0..44a60738 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Packet3Chat.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Packet3Chat.java @@ -3,9 +3,11 @@ package net.md_5.bungee.protocol.packet; import io.netty.buffer.ByteBuf; import lombok.EqualsAndHashCode; import lombok.Getter; +import lombok.Setter; import lombok.ToString; @Getter +@Setter @ToString @EqualsAndHashCode(callSuper = false) public class Packet3Chat extends DefinedPacket diff --git a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java index 06cb073a..75c546a7 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java @@ -84,17 +84,15 @@ public class UpstreamBridge extends PacketHandler public void handle(Packet3Chat chat) throws Exception { ChatEvent chatEvent = new ChatEvent( con, con.getServer(), chat.getMessage() ); - if ( bungee.getPluginManager().callEvent( chatEvent ).isCancelled() ) + if ( !bungee.getPluginManager().callEvent( chatEvent ).isCancelled() ) { - throw new CancelSendSignal(); - } - if ( chatEvent.isCommand() ) - { - if ( bungee.getPluginManager().dispatchCommand( con, chat.getMessage().substring( 1 ) ) ) + chat.setMessage( chatEvent.getMessage() ); + if ( !chatEvent.isCommand() || !bungee.getPluginManager().dispatchCommand( con, chat.getMessage().substring( 1 ) ) ) { - throw new CancelSendSignal(); + con.getServer().unsafe().sendPacket( chat ); } } + throw new CancelSendSignal(); } @Override