Add command access checking for permtest
This commit is contained in:
parent
1a659f8b09
commit
6f3d4d8300
@ -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
|
||||
|
@ -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!"),
|
||||
|
Loading…
Reference in New Issue
Block a user