Fix issue #129 - make chat event fire for commands, and add isCommand method.
This commit is contained in:
parent
fea3642550
commit
92c1450909
@ -30,4 +30,14 @@ public class ChatEvent extends TargetedEvent implements Cancellable
|
|||||||
super( sender, receiver );
|
super( sender, receiver );
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether this message is valid as a command
|
||||||
|
*
|
||||||
|
* @return if this message is a command
|
||||||
|
*/
|
||||||
|
public boolean isCommand()
|
||||||
|
{
|
||||||
|
return message.charAt( 0 ) == '/';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,16 +67,14 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
@Override
|
@Override
|
||||||
public void handle(Packet3Chat chat) throws Exception
|
public void handle(Packet3Chat chat) throws Exception
|
||||||
{
|
{
|
||||||
if ( chat.message.charAt( 0 ) == '/' )
|
ChatEvent chatEvent = new ChatEvent( con, con.getServer(), chat.message );
|
||||||
{
|
if ( bungee.getPluginManager().callEvent( chatEvent ).isCancelled() )
|
||||||
if ( bungee.getPluginManager().dispatchCommand( con, chat.message.substring( 1 ) ) )
|
|
||||||
{
|
{
|
||||||
throw new CancelSendSignal();
|
throw new CancelSendSignal();
|
||||||
}
|
}
|
||||||
} else
|
if ( chatEvent.isCommand() )
|
||||||
{
|
{
|
||||||
ChatEvent chatEvent = new ChatEvent( con, con.getServer(), chat.message );
|
if ( bungee.getPluginManager().dispatchCommand( con, chat.message.substring( 1 ) ) )
|
||||||
if ( bungee.getPluginManager().callEvent( chatEvent ).isCancelled() )
|
|
||||||
{
|
{
|
||||||
throw new CancelSendSignal();
|
throw new CancelSendSignal();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user