Add permtest to /libsdisguises
This commit is contained in:
parent
ead5a23d65
commit
ef981b3787
@ -2,17 +2,22 @@ package me.libraryaddict.disguise.commands;
|
|||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||||
|
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
||||||
|
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.bukkit.permissions.Permissible;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -89,6 +94,40 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
|
|||||||
DisguiseConfig.loadConfig();
|
DisguiseConfig.loadConfig();
|
||||||
sender.sendMessage(LibsMsg.RELOADED_CONFIG.get());
|
sender.sendMessage(LibsMsg.RELOADED_CONFIG.get());
|
||||||
return true;
|
return true;
|
||||||
|
} else if (args[0].equalsIgnoreCase("permtest")) {
|
||||||
|
if (!sender.hasPermission("libsdisguises.permtest")) {
|
||||||
|
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Permissible player;
|
||||||
|
|
||||||
|
if (args.length > 1) {
|
||||||
|
player = Bukkit.getPlayer(args[1]);
|
||||||
|
|
||||||
|
if (player == null) {
|
||||||
|
sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[1]));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
player = sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
DisguisePermissions permissions = new DisguisePermissions(player, "disguise");
|
||||||
|
sender.sendMessage(LibsMsg.LIBS_PERM_CHECK_INFO_1.get());
|
||||||
|
sender.sendMessage(LibsMsg.LIBS_PERM_CHECK_INFO_2.get());
|
||||||
|
|
||||||
|
if (player.hasPermission("libsdisguises.disguise.pig")) {
|
||||||
|
sender.sendMessage(LibsMsg.NORMAL_PERM_CHECK_SUCCESS.get());
|
||||||
|
|
||||||
|
if (permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.PIG))) {
|
||||||
|
sender.sendMessage(LibsMsg.LIBS_PERM_CHECK_SUCCESS.get());
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(LibsMsg.LIBS_PERM_CHECK_FAIL.get());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(LibsMsg.NORMAL_PERM_CHECK_FAIL.get());
|
||||||
|
}
|
||||||
} else if (args[0].equalsIgnoreCase("metainfo") || args[0].equalsIgnoreCase("meta")) {
|
} else if (args[0].equalsIgnoreCase("metainfo") || args[0].equalsIgnoreCase("meta")) {
|
||||||
if (!sender.hasPermission("libsdisguises.metainfo")) {
|
if (!sender.hasPermission("libsdisguises.metainfo")) {
|
||||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||||
|
@ -113,7 +113,7 @@ public enum LibsMsg {
|
|||||||
PLEASE_WAIT(ChatColor.GRAY + "Please wait..."),
|
PLEASE_WAIT(ChatColor.GRAY + "Please wait..."),
|
||||||
INVALID_CLONE(ChatColor.DARK_RED + "Unknown option '%s' - Valid options are 'IgnoreEquipment' 'DoSneakSprint' " +
|
INVALID_CLONE(ChatColor.DARK_RED + "Unknown option '%s' - Valid options are 'IgnoreEquipment' 'DoSneakSprint' " +
|
||||||
"'DoSneak' 'DoSprint'"),
|
"'DoSneak' 'DoSprint'"),
|
||||||
LIBS_COMMAND_WRONG_ARG(ChatColor.RED + "[LibsDisguises] Did you mean 'reload' or 'metainfo'?"),
|
LIBS_COMMAND_WRONG_ARG(ChatColor.RED + "[LibsDisguises] Did you mean 'reload', 'permtest' or 'metainfo'?"),
|
||||||
LIMITED_RADIUS(ChatColor.RED + "Limited radius to %s! Don't want to make too much lag right?"),
|
LIMITED_RADIUS(ChatColor.RED + "Limited radius to %s! Don't want to make too much lag right?"),
|
||||||
LISTEN_ENTITY_ENTITY_DISG_ENTITY(ChatColor.RED + "Disguised %s as a %s!"),
|
LISTEN_ENTITY_ENTITY_DISG_ENTITY(ChatColor.RED + "Disguised %s as a %s!"),
|
||||||
LISTEN_ENTITY_ENTITY_DISG_ENTITY_FAIL(ChatColor.RED + "Failed to disguise %s as a %s!"),
|
LISTEN_ENTITY_ENTITY_DISG_ENTITY_FAIL(ChatColor.RED + "Failed to disguise %s as a %s!"),
|
||||||
@ -235,7 +235,16 @@ public enum LibsMsg {
|
|||||||
META_NOT_FOUND(ChatColor.RED + "No meta exists under that name!"),
|
META_NOT_FOUND(ChatColor.RED + "No meta exists under that name!"),
|
||||||
META_VALUES(ChatColor.BLUE + "Metas: " + ChatColor.DARK_AQUA),
|
META_VALUES(ChatColor.BLUE + "Metas: " + ChatColor.DARK_AQUA),
|
||||||
META_VALUE_SEPERATOR(ChatColor.AQUA + ", " + ChatColor.DARK_AQUA),
|
META_VALUE_SEPERATOR(ChatColor.AQUA + ", " + ChatColor.DARK_AQUA),
|
||||||
META_CLICK_SHOW(ChatColor.GOLD + "Click to show %s");
|
META_CLICK_SHOW(ChatColor.GOLD + "Click to show %s"),
|
||||||
|
LIBS_PERM_CHECK_INFO_1(ChatColor.AQUA + "Now checking for the permission 'libsdisguises.disguise.pig'"),
|
||||||
|
LIBS_PERM_CHECK_INFO_2(ChatColor.AQUA +
|
||||||
|
"If you did not give this permission, please set it. You can supply a player name to test another player."),
|
||||||
|
NORMAL_PERM_CHECK_SUCCESS(ChatColor.GOLD + "Normal permission check, success."),
|
||||||
|
NORMAL_PERM_CHECK_FAIL(ChatColor.RED + "Normal permission check, fail."),
|
||||||
|
LIBS_PERM_CHECK_SUCCESS(
|
||||||
|
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!");
|
||||||
|
|
||||||
private String string;
|
private String string;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user