diff --git a/src/cn/citycraft/SimpleEssential/SimpleEssential.java b/src/cn/citycraft/SimpleEssential/SimpleEssential.java index 654f3dc..ae5b5dc 100644 --- a/src/cn/citycraft/SimpleEssential/SimpleEssential.java +++ b/src/cn/citycraft/SimpleEssential/SimpleEssential.java @@ -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 { diff --git a/src/cn/citycraft/SimpleEssential/command/CommandBack.java b/src/cn/citycraft/SimpleEssential/command/CommandBack.java index 63ce7ac..a6e2195 100644 --- a/src/cn/citycraft/SimpleEssential/command/CommandBack.java +++ b/src/cn/citycraft/SimpleEssential/command/CommandBack.java @@ -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 { diff --git a/src/cn/citycraft/SimpleEssential/command/CommandHome.java b/src/cn/citycraft/SimpleEssential/command/CommandHome.java index ff58944..cc70f7c 100644 --- a/src/cn/citycraft/SimpleEssential/command/CommandHome.java +++ b/src/cn/citycraft/SimpleEssential/command/CommandHome.java @@ -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 { diff --git a/src/cn/citycraft/SimpleEssential/command/CommandSetHome.java b/src/cn/citycraft/SimpleEssential/command/CommandSetHome.java index 4dfb8aa..643c0e7 100644 --- a/src/cn/citycraft/SimpleEssential/command/CommandSetHome.java +++ b/src/cn/citycraft/SimpleEssential/command/CommandSetHome.java @@ -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 { diff --git a/src/cn/citycraft/SimpleEssential/command/CommandTop.java b/src/cn/citycraft/SimpleEssential/command/CommandTop.java index 15df0cf..a8b76ed 100644 --- a/src/cn/citycraft/SimpleEssential/command/CommandTop.java +++ b/src/cn/citycraft/SimpleEssential/command/CommandTop.java @@ -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() { diff --git a/src/cn/citycraft/SimpleEssential/command/CommandTpa.java b/src/cn/citycraft/SimpleEssential/command/CommandTpa.java index 914d1a5..105cef7 100644 --- a/src/cn/citycraft/SimpleEssential/command/CommandTpa.java +++ b/src/cn/citycraft/SimpleEssential/command/CommandTpa.java @@ -26,6 +26,9 @@ public class CommandTpa extends SimpleEssentialCommand { super("tpa"); this.plugin = main; } + + @Override + public boolean isOnlyPlayerExecutable() {return true;}; @Override public String getPossibleArguments() { diff --git a/src/cn/citycraft/SimpleEssential/command/CommandTpaccept.java b/src/cn/citycraft/SimpleEssential/command/CommandTpaccept.java index a9e3b4c..9692fa2 100644 --- a/src/cn/citycraft/SimpleEssential/command/CommandTpaccept.java +++ b/src/cn/citycraft/SimpleEssential/command/CommandTpaccept.java @@ -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() { diff --git a/src/cn/citycraft/SimpleEssential/command/CommandTpdeny.java b/src/cn/citycraft/SimpleEssential/command/CommandTpdeny.java index 1c41414..e269e4a 100644 --- a/src/cn/citycraft/SimpleEssential/command/CommandTpdeny.java +++ b/src/cn/citycraft/SimpleEssential/command/CommandTpdeny.java @@ -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() { diff --git a/src/cn/citycraft/SimpleEssential/command/CommandTphere.java b/src/cn/citycraft/SimpleEssential/command/CommandTphere.java index bb00a4f..8aa82ba 100644 --- a/src/cn/citycraft/SimpleEssential/command/CommandTphere.java +++ b/src/cn/citycraft/SimpleEssential/command/CommandTphere.java @@ -37,6 +37,9 @@ public class CommandTphere extends SimpleEssentialCommand { "§c输入命令/tpdeny 或 /tpno 拒绝传送" }); } + + @Override + public boolean isOnlyPlayerExecutable() {return true;}; @Override public int getMinimumArguments() { diff --git a/src/cn/citycraft/SimpleEssential/command/SimpleEssentialCommand.java b/src/cn/citycraft/SimpleEssential/command/SimpleEssentialCommand.java index b6111ff..7be18bf 100644 --- a/src/cn/citycraft/SimpleEssential/command/SimpleEssentialCommand.java +++ b/src/cn/citycraft/SimpleEssential/command/SimpleEssentialCommand.java @@ -93,6 +93,11 @@ public abstract class SimpleEssentialCommand { * - 命令异常 */ public abstract void execute(CommandSender sender, String label, String[] args) throws CommandException; + + /** + * 是否只有玩家才能执行此命令 + */ + public abstract boolean isOnlyPlayerExecutable(); /** * 命令匹配检测 diff --git a/src/plugin.yml b/src/plugin.yml index f877910..82bbcec 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -57,6 +57,12 @@ commands: usage: §b使用/sethome 设置当前位置为家! permission: se.sethome permission-message: §c你没有 的权限来执行此命令! + suicide: + description: 自杀 + aliases: [sesuicide,sd] + usage: §b使用/suicide结束自己的生命! + permission: se.suicide + permission-message: §c你没有 的权限来执行此命令! permissions: se.*: description: 简单基础插件所有权限! @@ -72,4 +78,5 @@ permissions: se.tpaccept: true se.tpdeny: true se.back: true + se.suicide: true