13
0
geforkt von Mirrors/Paper

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

By: rmichela <deltahat@gmail.com>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2012-03-10 18:07:56 -05:00
Ursprung 430de62323
Commit b891ec330b
3 geänderte Dateien mit 23 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -70,6 +70,10 @@ public class GenericCommandHelpTopic extends HelpTopic {
return true; return true;
} }
if (amendedPermission != null) {
return sender.hasPermission(amendedPermission);
} else {
return command.testPermissionSilent(sender); return command.testPermissionSilent(sender);
} }
} }
}

Datei anzeigen

@ -17,15 +17,27 @@ public abstract class HelpTopic {
protected String name; protected String name;
protected String shortText; protected String shortText;
protected String fullText; protected String fullText;
protected String amendedPermission;
/** /**
* Determines if a {@link Player} is allowed to see this help topic. * Determines if a {@link Player} is allowed to see this help topic. HelpTopic implementations should take
* server administrator wishes into account as set by the {@link HelpTopic#amendCanSee(String)} function.
* *
* @param player The Player in question. * @param player The Player in question.
* @return True of the Player can see this help topic, false otherwise. * @return True of the Player can see this help topic, false otherwise.
*/ */
public abstract boolean canSee(CommandSender player); public abstract boolean canSee(CommandSender player);
/**
* Allows the server administrator to override the permission required to see a help topic. HelpTopic
* implementations should take this into account when determining topic visibility on the
* {@link HelpTopic#canSee(org.bukkit.command.CommandSender)} function.
* @param amendedPermission The permission node the server administrator wishes to apply to this topic.
*/
public void amendCanSee(String amendedPermission) {
this.amendedPermission = amendedPermission;
}
/** /**
* Returns the name of this help topic. * Returns the name of this help topic.
* @return The topic name. * @return The topic name.

Datei anzeigen

@ -41,6 +41,11 @@ public class IndexHelpTopic extends HelpTopic {
return sender.hasPermission(permission); return sender.hasPermission(permission);
} }
@Override
public void amendCanSee(String amendedPermission) {
permission = amendedPermission;
}
public String getFullText(CommandSender sender) { public String getFullText(CommandSender sender) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();