From eaf12ef1a2546b0c24bacbb9996bbff011d09c78 Mon Sep 17 00:00:00 2001 From: YakumoReddo <3166458362@qq.com> Date: Sun, 27 Nov 2022 23:24:22 +0800 Subject: [PATCH] fix command permissions add three permissions for command using update README.md --- README.md | 16 +++++++++++++++- src/com/satsukirin/RinDeath/RDCommand.java | 13 +++++++++++++ src/config.yml | 7 +++++++ src/plugin.yml | 21 +++++++++++++++++++-- 4 files changed, 54 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index db56fe7..36ac731 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,16 @@ # RinDeath -A minecraft plugin for 1.16.5. \ No newline at end of file +A minecraft plugin for 1.16.5. +## 中文介绍 +### 插件功能 +在这个插件中,你可以通过设置启用坟墓选项。在非观察者玩家死亡后,会生成一个坟墓(通过CustomModelData实现)。在玩家死亡后,死亡玩家会变为观察者模式并在坟墓附近游荡。当有玩家复活死亡玩家时,死亡玩家可以原地复活。否则当复活时间过后,玩家将在出生点复活。 +### 插件特色 +可以设定三种剩余复活时间提示模式 + +可以选择使用指令复活或是使用物品复活 +### 权限设置 +``` +rindeath.cmd.respawn -使用/rindeath respawn命令的权限 +rindeath.cmd.revive -使用/rindeath revive命令的权限 +rindeath.cmd.reviveitem -使用/rindeath reviveitem命令的权限 +``` +### 发现Bug或有改进意见请前往[Issues](https://github.com/YakumoReddo/RinDeath/issues)提出 \ No newline at end of file diff --git a/src/com/satsukirin/RinDeath/RDCommand.java b/src/com/satsukirin/RinDeath/RDCommand.java index 859b1bd..e184207 100644 --- a/src/com/satsukirin/RinDeath/RDCommand.java +++ b/src/com/satsukirin/RinDeath/RDCommand.java @@ -5,6 +5,7 @@ import java.util.UUID; import java.util.stream.Collectors; +import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.command.Command; @@ -46,9 +47,17 @@ public boolean onCommand(CommandSender sender, Command command, String label, St } Player player = (Player)sender; if (args[0].equalsIgnoreCase("respawn")) { + if(!player.hasPermission("rindeath.cmd.respawn")) { + player.sendMessage(ChatColor.RED+"您没有使用此命令的权限!"); + return true; + } RDSecondThread.getInstance().removePlayer(player, true); } if(args[0].equalsIgnoreCase("reviveitem")) { + if( !player.hasPermission("rindeath.cmd.reviveitem")) { + player.sendMessage(ChatColor.RED+"您没有使用此命令的权限!"); + return true; + } if(player.getEquipment().getItemInMainHand().getType().equals(Material.AIR)) { player.sendMessage("你尚未持有物品"); return true; @@ -59,6 +68,10 @@ public boolean onCommand(CommandSender sender, Command command, String label, St handitem.setItemMeta(meta); } if(args[0].equalsIgnoreCase("revive")) { + if(!player.hasPermission("rindeath.cmd.revive")) { + player.sendMessage(ChatColor.RED+"您没有使用此命令的权限!"); + return true; + } RayTraceResult rtr= player.getWorld().rayTraceEntities(player.getEyeLocation(), player.getEyeLocation().getDirection(), 5,1.0,a -> a.getType().equals(EntityType.ARMOR_STAND)); if (rtr==null || rtr.getHitEntity()==null) { player.sendMessage("你还没有选中玩家坟墓"); diff --git a/src/config.yml b/src/config.yml index 7f5c811..d52a241 100644 --- a/src/config.yml +++ b/src/config.yml @@ -1,5 +1,12 @@ +# 鏄惁鍚敤鍧熷鍔熻兘 enable: true +# 鍧熷鐨勬ā鍨媔d锛岄粯璁や负绱弨鍧楁柟鍧 graveModel: 1025 +# 鍓╀綑澶嶆椿鏃堕棿锛屽崟浣: 绉 respawnTime: 60 +# 鐏甸瓊娓歌崱鑼冨洿锛岀洿绾胯窛绂 range: 10 +# 鎻愮ず妯″紡锛宎ctionbar涓虹墿鍝佹爮涓婃柟鐨勬潯 +# bossbar涓哄睆骞曚笂鏂圭殑boss鏉 +# title涓哄睆骞曚腑闂寸殑鏍囬 tipType: actionbar diff --git a/src/plugin.yml b/src/plugin.yml index 2f9d280..8ba3a8a 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: RinDeath author: Yakumo_Reddo -version: 1.0.0 +version: 1.0.1 main: com.satsukirin.RinDeath.RinDeath api-version: 1.16 commands: @@ -9,4 +9,21 @@ commands: usage: /rind help rindeath: description: RinDeath. - usage: /rindeath help \ No newline at end of file + usage: /rindeath help +permissions: + rindeath.cmd.respawn: + description: Allows respawn + default: true + rindeath.cmd.revive: + description: Allows revive command + default: op + rindeath.cmd.reviveitem: + description: Allows reviveitem command + default: op + rindeath.cmd.*: + description: Wildcard command permission + default: op + children: + rindeath.cmd.respawn: true + rindeath.cmd.revive: true + rindeath.cmd.reviveitem: true \ No newline at end of file