mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 06:36:44 +01:00
Only display flags which the user is permitted to use.
This commit is contained in:
parent
2f90adac52
commit
d33f3ac409
@ -1,5 +1,7 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -57,6 +59,20 @@ public class FlagManager {
|
||||
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
|
||||
*
|
||||
|
@ -78,7 +78,7 @@ public class Set extends SubCommand {
|
||||
|
||||
if (args[0].equalsIgnoreCase("flag")) {
|
||||
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 (message.equals("")) {
|
||||
message = StringUtils.join(PlotMain.worldGuardListener.str_flags, "&c, &6");
|
||||
|
Loading…
Reference in New Issue
Block a user