summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorrmichela <deltahat@gmail.com>2012-03-10 18:07:56 -0500
committerEvilSeph <evilseph@gmail.com>2012-03-10 18:21:57 -0500
commit316869fb997b1ae7f02b63700358505c0887500d (patch)
tree03e6039d1fca8822876a781285d3b9abba9f29d9 /src/main/java
parent26fbd1228d2f50418126f012c26a2071b04029c1 (diff)
downloadbukkit-316869fb997b1ae7f02b63700358505c0887500d.tar
bukkit-316869fb997b1ae7f02b63700358505c0887500d.tar.gz
bukkit-316869fb997b1ae7f02b63700358505c0887500d.tar.lz
bukkit-316869fb997b1ae7f02b63700358505c0887500d.tar.xz
bukkit-316869fb997b1ae7f02b63700358505c0887500d.zip
[Bleeding] Added support for amending help topic visibility permissions in help.yml. Addresses BUKKIT-1113
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/bukkit/help/GenericCommandHelpTopic.java6
-rw-r--r--src/main/java/org/bukkit/help/HelpTopic.java14
-rw-r--r--src/main/java/org/bukkit/help/IndexHelpTopic.java5
3 files changed, 23 insertions, 2 deletions
diff --git a/src/main/java/org/bukkit/help/GenericCommandHelpTopic.java b/src/main/java/org/bukkit/help/GenericCommandHelpTopic.java
index 1bcf4719..639fd316 100644
--- a/src/main/java/org/bukkit/help/GenericCommandHelpTopic.java
+++ b/src/main/java/org/bukkit/help/GenericCommandHelpTopic.java
@@ -70,6 +70,10 @@ public class GenericCommandHelpTopic extends HelpTopic {
return true;
}
- return command.testPermissionSilent(sender);
+ if (amendedPermission != null) {
+ return sender.hasPermission(amendedPermission);
+ } else {
+ return command.testPermissionSilent(sender);
+ }
}
}
diff --git a/src/main/java/org/bukkit/help/HelpTopic.java b/src/main/java/org/bukkit/help/HelpTopic.java
index 885ae23b..34d10dbb 100644
--- a/src/main/java/org/bukkit/help/HelpTopic.java
+++ b/src/main/java/org/bukkit/help/HelpTopic.java
@@ -17,9 +17,11 @@ public abstract class HelpTopic {
protected String name;
protected String shortText;
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.
* @return True of the Player can see this help topic, false otherwise.
@@ -27,6 +29,16 @@ public abstract class HelpTopic {
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.
* @return The topic name.
*/
diff --git a/src/main/java/org/bukkit/help/IndexHelpTopic.java b/src/main/java/org/bukkit/help/IndexHelpTopic.java
index 559d2e68..161e8e81 100644
--- a/src/main/java/org/bukkit/help/IndexHelpTopic.java
+++ b/src/main/java/org/bukkit/help/IndexHelpTopic.java
@@ -41,6 +41,11 @@ public class IndexHelpTopic extends HelpTopic {
return sender.hasPermission(permission);
}
+ @Override
+ public void amendCanSee(String amendedPermission) {
+ permission = amendedPermission;
+ }
+
public String getFullText(CommandSender sender) {
StringBuilder sb = new StringBuilder();