Only display flags which the user is permitted to use.

This commit is contained in:
Sauilitired 2014-10-22 19:28:02 +02:00
parent 2f90adac52
commit d33f3ac409
2 changed files with 17 additions and 1 deletions

View File

@ -1,5 +1,7 @@
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot;
import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -57,6 +59,20 @@ public class FlagManager {
return flags; return flags;
} }
/**
* Get a list of registerd AbstragFlag objects based on player permissions
* @param player with permissions
* @return List (AbstractFlag)
*/
public static List<AbstractFlag> getFlags(Player player) {
List<AbstractFlag> returnFlags = new ArrayList<>();
for(AbstractFlag flag : flags) {
if(player.hasPermission("plots.set." + flag.getKey().toLowerCase()))
returnFlags.add(flag);
}
return returnFlags;
}
/** /**
* Get an AbstractFlag by a string Returns null if flag does not exist * Get an AbstractFlag by a string Returns null if flag does not exist
* *

View File

@ -78,7 +78,7 @@ public class Set extends SubCommand {
if (args[0].equalsIgnoreCase("flag")) { if (args[0].equalsIgnoreCase("flag")) {
if (args.length < 2) { if (args.length < 2) {
String message = StringUtils.join(FlagManager.getFlags(), "&c, &6"); String message = StringUtils.join(FlagManager.getFlags(plr), "&c, &6");
if (PlotMain.worldGuardListener != null) { if (PlotMain.worldGuardListener != null) {
if (message.equals("")) { if (message.equals("")) {
message = StringUtils.join(PlotMain.worldGuardListener.str_flags, "&c, &6"); message = StringUtils.join(PlotMain.worldGuardListener.str_flags, "&c, &6");