CommandMixin plz
This commit is contained in:
parent
62b0e8f8b3
commit
f0dfc539ba
12
src/com/massivecraft/mcore/mixin/CommandMixin.java
Normal file
12
src/com/massivecraft/mcore/mixin/CommandMixin.java
Normal file
@ -0,0 +1,12 @@
|
||||
package com.massivecraft.mcore.mixin;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.mcore.store.SenderEntity;
|
||||
|
||||
public interface CommandMixin
|
||||
{
|
||||
public boolean dispatchCommand(CommandSender sender, String commandLine);
|
||||
public boolean dispatchCommand(SenderEntity<?> sender, String commandLine);
|
||||
public boolean dispatchCommand(String sender, String commandLine);
|
||||
}
|
21
src/com/massivecraft/mcore/mixin/CommandMixinAbstract.java
Normal file
21
src/com/massivecraft/mcore/mixin/CommandMixinAbstract.java
Normal file
@ -0,0 +1,21 @@
|
||||
package com.massivecraft.mcore.mixin;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.mcore.store.SenderEntity;
|
||||
|
||||
public abstract class CommandMixinAbstract implements CommandMixin
|
||||
{
|
||||
public boolean dispatchCommand(CommandSender sender, String commandLine)
|
||||
{
|
||||
return Bukkit.getServer().dispatchCommand(sender, commandLine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchCommand(SenderEntity<?> sender, String commandLine)
|
||||
{
|
||||
return this.dispatchCommand(sender.getId(), commandLine);
|
||||
}
|
||||
|
||||
}
|
28
src/com/massivecraft/mcore/mixin/CommandMixinDefault.java
Normal file
28
src/com/massivecraft/mcore/mixin/CommandMixinDefault.java
Normal file
@ -0,0 +1,28 @@
|
||||
package com.massivecraft.mcore.mixin;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.mcore.util.SenderUtil;
|
||||
|
||||
public class CommandMixinDefault extends CommandMixinAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static CommandMixinDefault i = new CommandMixinDefault();
|
||||
public static CommandMixinDefault get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public boolean dispatchCommand(String sender, String commandLine)
|
||||
{
|
||||
CommandSender commandSender = SenderUtil.getSender(sender);
|
||||
if (commandSender == null) return false;
|
||||
return this.dispatchCommand(sender, commandLine);
|
||||
}
|
||||
|
||||
}
|
@ -66,6 +66,10 @@ public class Mixin
|
||||
public static ActualMixin getActualMixin() { return actualMixin; }
|
||||
public static void setActualMixin(ActualMixin val) { actualMixin = val; }
|
||||
|
||||
private static CommandMixin commandMixin = CommandMixinDefault.get();
|
||||
public static CommandMixin getCommandMixin() { return commandMixin; }
|
||||
public static void setCommandMixin(CommandMixin val) { commandMixin = val; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// STATIC EXPOSE: WORLD
|
||||
// -------------------------------------------- //
|
||||
@ -702,4 +706,23 @@ public class Mixin
|
||||
return getActualMixin().isActualLeave(event);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// STATIC EXPOSE: COMMAND
|
||||
// -------------------------------------------- //
|
||||
|
||||
public boolean dispatchCommand(CommandSender sender, String commandLine)
|
||||
{
|
||||
return getCommandMixin().dispatchCommand(sender, commandLine);
|
||||
}
|
||||
|
||||
public boolean dispatchCommand(SenderEntity<?> sender, String commandLine)
|
||||
{
|
||||
return getCommandMixin().dispatchCommand(sender, commandLine);
|
||||
}
|
||||
|
||||
public boolean dispatchCommand(String sender, String commandLine)
|
||||
{
|
||||
return getCommandMixin().dispatchCommand(sender, commandLine);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user