From a2bf46d88675d5f640f7299698bbd76514684e08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=A3=E5=B0=8F=E5=91=86?= Date: Fri, 14 Aug 2015 12:12:49 +0800 Subject: [PATCH] =?UTF-8?q?+=20=E5=AF=B9ConsoleCommandSender=E7=9A=84?= =?UTF-8?q?=E5=88=A4=E6=96=AD=20x=20=E7=8E=B0=E5=9C=A8=E4=BD=BF=E7=94=A8Co?= =?UTF-8?q?nsoleCommandSender=E5=8F=91=E9=80=81=E5=8F=AA=E5=B1=9E=E4=BA=8E?= =?UTF-8?q?=E7=8E=A9=E5=AE=B6=E7=9A=84=E5=91=BD=E4=BB=A4=E4=B8=8D=E4=BC=9A?= =?UTF-8?q?=E7=88=86=E7=82=B8=E4=BA=86=20+=20/suicide=E5=92=8C/suicide=20c?= =?UTF-8?q?onfirm=20+=20suicide=20=E5=AF=B9=E5=BA=94=E7=9A=84=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=92=8C=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cn/citycraft/SimpleEssential/SimpleEssential.java | 3 +++ src/cn/citycraft/SimpleEssential/command/CommandBack.java | 3 +++ src/cn/citycraft/SimpleEssential/command/CommandHome.java | 3 +++ .../citycraft/SimpleEssential/command/CommandSetHome.java | 3 +++ src/cn/citycraft/SimpleEssential/command/CommandTop.java | 3 +++ src/cn/citycraft/SimpleEssential/command/CommandTpa.java | 3 +++ .../citycraft/SimpleEssential/command/CommandTpaccept.java | 3 +++ .../citycraft/SimpleEssential/command/CommandTpdeny.java | 3 +++ .../citycraft/SimpleEssential/command/CommandTphere.java | 3 +++ .../SimpleEssential/command/SimpleEssentialCommand.java | 5 +++++ src/plugin.yml | 7 +++++++ 11 files changed, 39 insertions(+) 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