Merge pull request #1 from diauweb/master

add ConsoleCommandSender check...
pull/1/HEAD
502647092 2015-08-14 13:33:08 +08:00
commit 809e6f5cec
11 changed files with 39 additions and 0 deletions

View File

@ -10,6 +10,7 @@ import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
@ -48,6 +49,8 @@ public class SimpleEssential extends JavaPlugin {
if (!command.hasPermission(sender)) {
sender.sendMessage(ChatColor.RED + "你没有此命令的权限.");
return true;
}else if(command.isOnlyPlayerExecutable() && !(sender instanceof Player)){
sender.sendMessage(ChatColor.RED + "此命令只能由玩家执行.");
}
if (args.length >= command.getMinimumArguments()) {
try {

View File

@ -22,6 +22,9 @@ public class CommandBack extends SimpleEssentialCommand {
super("back", "seback");
this.plugin = main;
}
@Override
public boolean isOnlyPlayerExecutable() {return true;};
@Override
public void execute(CommandSender sender, String label, String[] args) throws CommandException {

View File

@ -23,6 +23,9 @@ public class CommandHome extends SimpleEssentialCommand {
super("home", "eshome");
this.plugin = main;
}
@Override
public boolean isOnlyPlayerExecutable() {return true;};
@Override
public void execute(CommandSender sender, String label, String[] args) throws CommandException {

View File

@ -24,6 +24,9 @@ public class CommandSetHome extends SimpleEssentialCommand {
super("sethome", "essethome");
this.plugin = main;
}
@Override
public boolean isOnlyPlayerExecutable() {return true;};
@Override
public void execute(CommandSender sender, String label, String[] args) throws CommandException {

View File

@ -25,6 +25,9 @@ public class CommandTop extends SimpleEssentialCommand {
super("top", "estop");
this.plugin = main;
}
@Override
public boolean isOnlyPlayerExecutable() {return true;};
@Override
public String getPossibleArguments() {

View File

@ -26,6 +26,9 @@ public class CommandTpa extends SimpleEssentialCommand {
super("tpa");
this.plugin = main;
}
@Override
public boolean isOnlyPlayerExecutable() {return true;};
@Override
public String getPossibleArguments() {

View File

@ -24,6 +24,9 @@ public class CommandTpaccept extends SimpleEssentialCommand {
super("tpaccept", "tpok");
this.plugin = main;
}
@Override
public boolean isOnlyPlayerExecutable() {return true;};
@Override
public String getPossibleArguments() {

View File

@ -24,6 +24,9 @@ public class CommandTpdeny extends SimpleEssentialCommand {
super("tpdeny", "tpno");
this.plugin = main;
}
@Override
public boolean isOnlyPlayerExecutable() {return true;};
@Override
public String getPossibleArguments() {

View File

@ -37,6 +37,9 @@ public class CommandTphere extends SimpleEssentialCommand {
"§c输入命令/tpdeny 或 /tpno 拒绝传送"
});
}
@Override
public boolean isOnlyPlayerExecutable() {return true;};
@Override
public int getMinimumArguments() {

View File

@ -93,6 +93,11 @@ public abstract class SimpleEssentialCommand {
* -
*/
public abstract void execute(CommandSender sender, String label, String[] args) throws CommandException;
/**
*
*/
public abstract boolean isOnlyPlayerExecutable();
/**
*

View File

@ -57,6 +57,12 @@ commands:
usage: §b使用/sethome 设置当前位置为家!
permission: se.sethome
permission-message: §c你没有 <permission> 的权限来执行此命令!
suicide:
description: 自杀
aliases: [sesuicide,sd]
usage: §b使用/suicide结束自己的生命!
permission: se.suicide
permission-message: §c你没有 <permission> 的权限来执行此命令!
permissions:
se.*:
description: 简单基础插件所有权限!
@ -72,4 +78,5 @@ permissions:
se.tpaccept: true
se.tpdeny: true
se.back: true
se.suicide: true