mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2024-11-29 05:26:19 +01:00
IRCCommandEvent should be cancellable.
This commit is contained in:
parent
e765453811
commit
e975975688
@ -61,24 +61,19 @@ public class CommandQueueWatcher {
|
||||
isCommandBookCommand = plugin.commandBookHook.isCommandBookCommand(cmd);
|
||||
plugin.logDebug("Is this is a CommandBook command? " + Boolean.toString(isCommandBookCommand));
|
||||
}
|
||||
if (
|
||||
(plugin.getServer().getVersion().contains("MC: 1.8")
|
||||
if ((plugin.getServer().getVersion().contains("MC: 1.8")
|
||||
&& (plugin.getServer().getVersion().contains("Spigot"))
|
||||
&& plugin.getServer().getPluginCommand(cmd) == null
|
||||
&& !isCommandBookCommand)
|
||||
||
|
||||
(plugin.getServer().getVersion().contains("MC: 1.9")
|
||||
|| (plugin.getServer().getVersion().contains("MC: 1.9")
|
||||
&& plugin.getServer().getPluginCommand(cmd) == null
|
||||
&& !isCommandBookCommand)
|
||||
||
|
||||
(plugin.getServer().getVersion().contains("MC: 1.10")
|
||||
|| (plugin.getServer().getVersion().contains("MC: 1.10")
|
||||
&& plugin.getServer().getPluginCommand(cmd) == null
|
||||
&& !isCommandBookCommand)
|
||||
||
|
||||
(plugin.getServer().getVersion().contains("MC: 1.11")
|
||||
|| (plugin.getServer().getVersion().contains("MC: 1.11")
|
||||
&& plugin.getServer().getPluginCommand(cmd) == null
|
||||
&& !isCommandBookCommand)
|
||||
) {
|
||||
&& !isCommandBookCommand)) {
|
||||
plugin.logDebug("Dispatching command as ConsoleSender: " + ircCommand.getGameCommand());
|
||||
|
||||
plugin.getServer().dispatchCommand(ircCommand.getIRCConsoleCommandSender(), ircCommand.getGameCommand());
|
||||
@ -90,7 +85,10 @@ public class CommandQueueWatcher {
|
||||
} catch (CommandException ce) {
|
||||
plugin.logError("Error running command: " + ce.getMessage());
|
||||
}
|
||||
plugin.getServer().getPluginManager().callEvent(new IRCCommandEvent(ircCommand));
|
||||
IRCCommandEvent event = new IRCCommandEvent(ircCommand);
|
||||
if (!event.isCancelled()) {
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
package com.cnaude.purpleirc.Events;
|
||||
|
||||
import com.cnaude.purpleirc.IRCCommand;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@ -25,10 +26,11 @@ import org.bukkit.event.HandlerList;
|
||||
* @author Chris Naude Event listener for plugins that want to catch command events
|
||||
* from PurpleIRC
|
||||
*/
|
||||
public class IRCCommandEvent extends Event {
|
||||
public class IRCCommandEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final IRCCommand ircCommand;
|
||||
private boolean cancelled;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -62,4 +64,14 @@ public class IRCCommandEvent extends Event {
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
cancelled = cancel;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user