From 6f3d4d830078080e4100f788db83297648efe044 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Thu, 18 Jun 2020 13:44:37 +1200 Subject: [PATCH] Add command access checking for permtest --- .../commands/libsdisguises/LDPermTest.java | 23 +++++++++++++++++++ .../utilities/translations/LibsMsg.java | 8 +++++++ 2 files changed, 31 insertions(+) diff --git a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDPermTest.java b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDPermTest.java index 77bf9119..e90e5903 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDPermTest.java +++ b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDPermTest.java @@ -1,5 +1,6 @@ package me.libraryaddict.disguise.commands.libsdisguises; +import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.disguisetypes.DisguiseType; import me.libraryaddict.disguise.utilities.LibsPremium; import me.libraryaddict.disguise.utilities.parser.DisguisePerm; @@ -7,6 +8,7 @@ import me.libraryaddict.disguise.utilities.parser.DisguisePermissions; import me.libraryaddict.disguise.utilities.translations.LibsMsg; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; +import org.bukkit.command.PluginCommand; import org.bukkit.permissions.Permissible; import java.util.Arrays; @@ -60,6 +62,27 @@ public class LDPermTest implements LDCommand { } else { sender.sendMessage(LibsMsg.NORMAL_PERM_CHECK_FAIL.get()); } + + if (player.hasPermission("libsdisguises.disguise.zombie") || + permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.ZOMBIE))) { + sender.sendMessage(LibsMsg.LIBS_PERM_CHECK_ZOMBIE_PERMISSIONS.get()); + } + + PluginCommand command = LibsDisguises.getInstance().getCommand("disguise"); + + if (command == null) { + sender.sendMessage(LibsMsg.LIBS_PERM_CHECK_COMMAND_UNREGISTERED.get()); + } else if (player.hasPermission(command.getPermission())) { + sender.sendMessage(LibsMsg.LIBS_PERM_COMMAND_SUCCESS.get(command.getPermission())); + } else { + sender.sendMessage(LibsMsg.LIBS_PERM_COMMAND_FAIL.get(command.getPermission())); + } + + if (!sender.hasPermission("libsdisguises.seecmd.disguise")) { + sender.sendMessage(LibsMsg.LIBS_PERM_COMMAND_FAIL.get("libsdisguises.seecmd.disguise")); + } else { + sender.sendMessage(LibsMsg.LIBS_PERM_COMMAND_SUCCESS.get("libsdisguises.seecmd.disguise")); + } } @Override diff --git a/src/main/java/me/libraryaddict/disguise/utilities/translations/LibsMsg.java b/src/main/java/me/libraryaddict/disguise/utilities/translations/LibsMsg.java index 72b792cc..ac00be45 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/translations/LibsMsg.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/translations/LibsMsg.java @@ -278,6 +278,14 @@ public enum LibsMsg { ChatColor.GOLD + "Lib's Disguises permission check, success. Pig disguise should be usable!"), LIBS_PERM_CHECK_FAIL( ChatColor.GOLD + "Lib's Disguises permission check, fail. Your permission plugin isn't compliant!"), + LIBS_PERM_CHECK_ZOMBIE_PERMISSIONS(ChatColor.RED + + "Tested libsdisguises.disguise.zombie, which your player seems to have! There may be a problem in your " + + "permissions setup!"), + LIBS_PERM_CHECK_COMMAND_UNREGISTERED( + ChatColor.RED + "The /disguise command seems to be unregistered! Check your config!"), + LIBS_PERM_COMMAND_SUCCESS( + ChatColor.GOLD + "Tested permission '%s' for /disguise command access, permission success!"), + LIBS_PERM_COMMAND_FAIL(ChatColor.RED + "Tested permission '%s' for /disguise command access, permission failed!"), CANT_ATTACK_DISGUISED(ChatColor.RED + "Cannot fight while disguised!"), CANT_ATTACK_DISGUISED_RECENTLY(ChatColor.RED + "You were disguised recently! Can't attack yet!"), SWITCH_WORLD_DISGUISE_REMOVED(ChatColor.RED + "Disguise removed as you've switched worlds!"),