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