Add ability to require a presence in the mixin for commands.
This commit is contained in:
parent
ae2c1285d6
commit
0d5fb204a6
@ -8,5 +8,6 @@ public interface CommandMixin
|
||||
{
|
||||
public boolean dispatchCommand(CommandSender sender, String commandLine);
|
||||
public boolean dispatchCommand(SenderEntity<?> sender, String commandLine);
|
||||
public boolean dispatchCommand(String sender, String commandLine);
|
||||
public boolean dispatchCommand(String senderId, String commandLine);
|
||||
public boolean dispatchCommand(String presentId, String senderId, String commandLine); // This one is non-abstract
|
||||
}
|
||||
|
@ -1,21 +1,27 @@
|
||||
package com.massivecraft.mcore.mixin;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.mcore.store.SenderEntity;
|
||||
import com.massivecraft.mcore.util.SenderUtil;
|
||||
|
||||
public abstract class CommandMixinAbstract implements CommandMixin
|
||||
{
|
||||
@Override
|
||||
public boolean dispatchCommand(CommandSender sender, String commandLine)
|
||||
{
|
||||
return Bukkit.getServer().dispatchCommand(sender, commandLine);
|
||||
return this.dispatchCommand(SenderUtil.getSenderId(sender), SenderUtil.getSenderId(sender), commandLine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchCommand(SenderEntity<?> sender, String commandLine)
|
||||
{
|
||||
return this.dispatchCommand(sender.getId(), commandLine);
|
||||
return this.dispatchCommand(sender.getId(), sender.getId(), commandLine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchCommand(String senderId, String commandLine)
|
||||
{
|
||||
return this.dispatchCommand(senderId, senderId, commandLine);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.massivecraft.mcore.mixin;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.mcore.util.SenderUtil;
|
||||
@ -16,13 +17,21 @@ public class CommandMixinDefault extends CommandMixinAbstract
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
|
||||
@Override
|
||||
public boolean dispatchCommand(String sender, String commandLine)
|
||||
public boolean dispatchCommand(String presentId, String senderId, String commandLine)
|
||||
{
|
||||
CommandSender commandSender = SenderUtil.getSender(sender);
|
||||
if (commandSender == null) return false;
|
||||
return this.dispatchCommand(sender, commandLine);
|
||||
// Additional enforced presence
|
||||
CommandSender present = SenderUtil.getSender(presentId);
|
||||
if (present == null) return false;
|
||||
|
||||
// We must then of course have the presence of the sender
|
||||
CommandSender sender = SenderUtil.getSender(senderId);
|
||||
if (sender == null) return false;
|
||||
|
||||
// Great! Let's do it!
|
||||
Bukkit.getServer().dispatchCommand(sender, commandLine);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -720,9 +720,14 @@ public class Mixin
|
||||
return getCommandMixin().dispatchCommand(sender, commandLine);
|
||||
}
|
||||
|
||||
public static boolean dispatchCommand(String sender, String commandLine)
|
||||
public static boolean dispatchCommand(String senderId, String commandLine)
|
||||
{
|
||||
return getCommandMixin().dispatchCommand(sender, commandLine);
|
||||
return getCommandMixin().dispatchCommand(senderId, commandLine);
|
||||
}
|
||||
|
||||
public static boolean dispatchCommand(String presentId, String senderId, String commandLine)
|
||||
{
|
||||
return getCommandMixin().dispatchCommand(presentId, senderId, commandLine);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user