[Bleeding] Added support for amending help topic visibility permissions in help.yml. Addresses BUKKIT-1113

This commit is contained in:
rmichela
2012-03-10 18:08:12 -05:00
committed by EvilSeph
parent a8b2c6d04e
commit 996832ff6c
6 changed files with 45 additions and 24 deletions

View File

@@ -1,7 +1,6 @@
package org.bukkit.craftbukkit.help;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.help.HelpMap;
import org.bukkit.help.HelpTopic;
@@ -9,13 +8,11 @@ import org.bukkit.help.HelpTopic;
public class CommandAliasHelpTopic extends HelpTopic {
private String aliasFor;
private Command command;
private HelpMap helpMap;
public CommandAliasHelpTopic(String alias, String aliasFor, Command command, HelpMap helpMap) {
public CommandAliasHelpTopic(String alias, String aliasFor, HelpMap helpMap) {
this.aliasFor = aliasFor.startsWith("/") ? aliasFor : "/" + aliasFor;
this.helpMap = helpMap;
this.command = command;
this.name = alias.startsWith("/") ? alias : "/" + alias;
this.shortText = ChatColor.YELLOW + "Alias for " + ChatColor.WHITE + this.aliasFor;
}
@@ -33,11 +30,15 @@ public class CommandAliasHelpTopic extends HelpTopic {
@Override
public boolean canSee(CommandSender commandSender) {
HelpTopic aliasForTopic = helpMap.getHelpTopic(aliasFor);
if (aliasForTopic != null) {
return aliasForTopic.canSee(commandSender);
if (amendedPermission == null) {
HelpTopic aliasForTopic = helpMap.getHelpTopic(aliasFor);
if (aliasForTopic != null) {
return aliasForTopic.canSee(commandSender);
} else {
return false;
}
} else {
return false;
return commandSender.hasPermission(amendedPermission);
}
}
}