Fix incorrect permission nodes

This commit is contained in:
Andrew 2013-11-19 00:53:22 +13:00
parent 9b1ba66efc
commit 209744fab3
5 changed files with 11 additions and 8 deletions

@ -23,6 +23,10 @@ import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
public abstract class BaseDisguiseCommand implements CommandExecutor { public abstract class BaseDisguiseCommand implements CommandExecutor {
protected ArrayList<String> getAllowedDisguises(CommandSender sender) {
String permissionNode = "libsdisguises." + getClass().getSimpleName().replace("Command", "").toLowerCase() + ".";
return getAllowedDisguises(sender, permissionNode);
}
protected ArrayList<String> getAllowedDisguises(CommandSender sender, String permissionNode) { protected ArrayList<String> getAllowedDisguises(CommandSender sender, String permissionNode) {
ArrayList<String> names = new ArrayList<String>(); ArrayList<String> names = new ArrayList<String>();
@ -117,8 +121,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
* disguise has been feed a proper disguisetype. * disguise has been feed a proper disguisetype.
*/ */
protected Disguise parseDisguise(CommandSender sender, String[] args) throws Exception { protected Disguise parseDisguise(CommandSender sender, String[] args) throws Exception {
String permissionNode = "libsdisguises." + getClass().getSimpleName().replace("Command", "").toLowerCase() + "."; ArrayList<String> allowedDisguises = getAllowedDisguises(sender);
ArrayList<String> allowedDisguises = getAllowedDisguises(sender, permissionNode);
if (allowedDisguises.isEmpty()) { if (allowedDisguises.isEmpty()) {
throw new Exception(ChatColor.RED + "You are forbidden to use this command."); throw new Exception(ChatColor.RED + "You are forbidden to use this command.");
} }

@ -38,7 +38,7 @@ public class DisguiseCommand extends BaseDisguiseCommand {
* Send the player the information * Send the player the information
*/ */
protected void sendCommandUsage(CommandSender sender) { protected void sendCommandUsage(CommandSender sender) {
ArrayList<String> allowedDisguises = getAllowedDisguises(sender, "disguise"); ArrayList<String> allowedDisguises = getAllowedDisguises(sender);
sender.sendMessage(ChatColor.DARK_GREEN + "Choose a disguise to become the disguise!"); sender.sendMessage(ChatColor.DARK_GREEN + "Choose a disguise to become the disguise!");
sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN
+ StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)); + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));

@ -44,7 +44,7 @@ public class DisguiseEntityCommand extends BaseDisguiseCommand {
* Send the player the information * Send the player the information
*/ */
protected void sendCommandUsage(CommandSender sender) { protected void sendCommandUsage(CommandSender sender) {
ArrayList<String> allowedDisguises = getAllowedDisguises(sender, "disguiseentity"); ArrayList<String> allowedDisguises = getAllowedDisguises(sender);
sender.sendMessage(ChatColor.DARK_GREEN + "Choose a disguise then slap a entity to disguise it!"); sender.sendMessage(ChatColor.DARK_GREEN + "Choose a disguise then slap a entity to disguise it!");
sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN
+ StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)); + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));

@ -15,7 +15,7 @@ public class DisguisePlayerCommand extends BaseDisguiseCommand {
@Override @Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
ArrayList<String> allowedDisguises = getAllowedDisguises(sender, "disguiseplayer"); ArrayList<String> allowedDisguises = getAllowedDisguises(sender);
if (allowedDisguises.isEmpty()) { if (allowedDisguises.isEmpty()) {
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command."); sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
return true; return true;
@ -58,7 +58,7 @@ public class DisguisePlayerCommand extends BaseDisguiseCommand {
* Send the player the information * Send the player the information
*/ */
protected void sendCommandUsage(CommandSender sender) { protected void sendCommandUsage(CommandSender sender) {
ArrayList<String> allowedDisguises = getAllowedDisguises(sender, "disguiseplayer"); ArrayList<String> allowedDisguises = getAllowedDisguises(sender);
sender.sendMessage(ChatColor.DARK_GREEN + "Disguise another player!"); sender.sendMessage(ChatColor.DARK_GREEN + "Disguise another player!");
sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN
+ StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)); + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));

@ -24,7 +24,7 @@ public class DisguiseRadiusCommand extends BaseDisguiseCommand {
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!"); sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
return true; return true;
} }
ArrayList<String> allowedDisguises = getAllowedDisguises(sender, "disguiseplayer"); ArrayList<String> allowedDisguises = getAllowedDisguises(sender);
if (allowedDisguises.isEmpty()) { if (allowedDisguises.isEmpty()) {
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command."); sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
return true; return true;
@ -76,7 +76,7 @@ public class DisguiseRadiusCommand extends BaseDisguiseCommand {
* Send the player the information * Send the player the information
*/ */
protected void sendCommandUsage(CommandSender sender) { protected void sendCommandUsage(CommandSender sender) {
ArrayList<String> allowedDisguises = getAllowedDisguises(sender, "disguiseradius"); ArrayList<String> allowedDisguises = getAllowedDisguises(sender);
sender.sendMessage(ChatColor.DARK_GREEN + "Disguise all entities in a radius! Caps at 30 blocks!"); sender.sendMessage(ChatColor.DARK_GREEN + "Disguise all entities in a radius! Caps at 30 blocks!");
sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN
+ StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)); + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));