mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-20 12:20:11 +00:00
New Command event.
This commit is contained in:
1 parent
60a9655602
commit
d9423a4f25
2 files changed
+53
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
Reference in new issue
Block a user