New Command event.

This commit is contained in:
LexManos 2012-08-15 02:01:38 -07:00
parent 60a9655602
commit d9423a4f25
2 changed files with 53 additions and 0 deletions

View file

@ -0,0 +1,21 @@
package net.minecraftforge.event;
import net.minecraft.src.ICommand;
import net.minecraft.src.ICommandSender;
@Cancelable
public class CommandEvent extends Event
{
public final ICommand command;
public final ICommandSender sender;
public String[] parameters;
public Throwable exception;
public CommandEvent(ICommand command, ICommandSender sender, String[] parameters)
{
this.command = command;
this.sender = sender;
this.parameters = parameters;
}
}

View file

@ -0,0 +1,32 @@
--- ../src_base/common/net/minecraft/src/CommandHandler.java
+++ ../src_work/common/net/minecraft/src/CommandHandler.java
@@ -8,6 +8,9 @@
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
+
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.CommandEvent;
public class CommandHandler implements ICommandManager
{
@@ -38,7 +41,18 @@
if (var5.canCommandSenderUseCommand(par1ICommandSender))
{
- var5.processCommand(par1ICommandSender, var3);
+ CommandEvent event = new CommandEvent(var5, par1ICommandSender, var3);
+ if (!MinecraftForge.EVENT_BUS.post(event))
+ {
+ var5.processCommand(par1ICommandSender, event.parameters);
+ }
+ else
+ {
+ if (event.exception != null)
+ {
+ throw event.exception;
+ }
+ }
}
else
{