mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-04-27 08:59:45 +00:00
Reimplement 'private' keywords.
This commit is contained in:
parent
36c61eaa06
commit
df5d9a4db8
1 changed files with 36 additions and 11 deletions
|
@ -34,7 +34,7 @@ public class KeywordReplacer implements IText
|
||||||
private final transient IText input;
|
private final transient IText input;
|
||||||
private final transient List<String> replaced;
|
private final transient List<String> replaced;
|
||||||
private final transient IEssentials ess;
|
private final transient IEssentials ess;
|
||||||
private final transient boolean extended;
|
private final transient boolean includePrivate;
|
||||||
private transient ExecuteTimer execTimer;
|
private transient ExecuteTimer execTimer;
|
||||||
private final static Pattern KEYWORD = Pattern.compile("\\{([^\\{\\}]+)\\}");
|
private final static Pattern KEYWORD = Pattern.compile("\\{([^\\{\\}]+)\\}");
|
||||||
private final static Pattern KEYWORDSPLIT = Pattern.compile("\\:");
|
private final static Pattern KEYWORDSPLIT = Pattern.compile("\\:");
|
||||||
|
@ -45,16 +45,16 @@ public class KeywordReplacer implements IText
|
||||||
this.input = input;
|
this.input = input;
|
||||||
this.replaced = new ArrayList<String>(this.input.getLines().size());
|
this.replaced = new ArrayList<String>(this.input.getLines().size());
|
||||||
this.ess = ess;
|
this.ess = ess;
|
||||||
this.extended = true;
|
this.includePrivate = true;
|
||||||
replaceKeywords(sender);
|
replaceKeywords(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeywordReplacer(final IText input, final CommandSender sender, final IEssentials ess, final boolean extended)
|
public KeywordReplacer(final IText input, final CommandSender sender, final IEssentials ess, final boolean showPrivate)
|
||||||
{
|
{
|
||||||
this.input = input;
|
this.input = input;
|
||||||
this.replaced = new ArrayList<String>(this.input.getLines().size());
|
this.replaced = new ArrayList<String>(this.input.getLines().size());
|
||||||
this.ess = ess;
|
this.ess = ess;
|
||||||
this.extended = extended;
|
this.includePrivate = showPrivate;
|
||||||
replaceKeywords(sender);
|
replaceKeywords(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,6 +122,10 @@ public class KeywordReplacer implements IText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (validKeyword.isPrivate() && !includePrivate) {
|
||||||
|
replacer = "";
|
||||||
|
}
|
||||||
|
|
||||||
if (replacer == null)
|
if (replacer == null)
|
||||||
{
|
{
|
||||||
|
@ -194,8 +198,16 @@ public class KeywordReplacer implements IText
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
final boolean showHidden;
|
||||||
|
if (user == null) {
|
||||||
|
showHidden = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
showHidden = user.isAuthorized("essentials.list.hidden") || user.isAuthorized("essentials.vanish.interact");
|
||||||
|
}
|
||||||
|
|
||||||
//First lets build the per group playerlist
|
//First lets build the per group playerlist
|
||||||
final Map<String, List<User>> playerList = PlayerList.getPlayerLists(ess, extended);
|
final Map<String, List<User>> playerList = PlayerList.getPlayerLists(ess, showHidden);
|
||||||
outputList = new HashMap<String, String>();
|
outputList = new HashMap<String, String>();
|
||||||
for (String groupName : playerList.keySet())
|
for (String groupName : playerList.keySet())
|
||||||
{
|
{
|
||||||
|
@ -356,7 +368,7 @@ enum KeywordType
|
||||||
ONLINE(KeywordCachable.CACHEABLE),
|
ONLINE(KeywordCachable.CACHEABLE),
|
||||||
UNIQUE(KeywordCachable.CACHEABLE),
|
UNIQUE(KeywordCachable.CACHEABLE),
|
||||||
WORLDS(KeywordCachable.CACHEABLE),
|
WORLDS(KeywordCachable.CACHEABLE),
|
||||||
PLAYERLIST(KeywordCachable.SUBVALUE),
|
PLAYERLIST(KeywordCachable.SUBVALUE, true),
|
||||||
TIME(KeywordCachable.CACHEABLE),
|
TIME(KeywordCachable.CACHEABLE),
|
||||||
DATE(KeywordCachable.CACHEABLE),
|
DATE(KeywordCachable.CACHEABLE),
|
||||||
WORLDTIME12(KeywordCachable.CACHEABLE),
|
WORLDTIME12(KeywordCachable.CACHEABLE),
|
||||||
|
@ -365,21 +377,34 @@ enum KeywordType
|
||||||
COORDS(KeywordCachable.CACHEABLE),
|
COORDS(KeywordCachable.CACHEABLE),
|
||||||
TPS(KeywordCachable.CACHEABLE),
|
TPS(KeywordCachable.CACHEABLE),
|
||||||
UPTIME(KeywordCachable.CACHEABLE),
|
UPTIME(KeywordCachable.CACHEABLE),
|
||||||
IP(KeywordCachable.CACHEABLE),
|
IP(KeywordCachable.CACHEABLE, true),
|
||||||
ADDRESS(KeywordCachable.CACHEABLE),
|
ADDRESS(KeywordCachable.CACHEABLE, true),
|
||||||
PLUGINS(KeywordCachable.CACHEABLE),
|
PLUGINS(KeywordCachable.CACHEABLE, true),
|
||||||
VERSION(KeywordCachable.CACHEABLE);
|
VERSION(KeywordCachable.CACHEABLE, true);
|
||||||
|
|
||||||
private final KeywordCachable type;
|
private final KeywordCachable type;
|
||||||
|
private final boolean isPrivate;
|
||||||
|
|
||||||
KeywordType(KeywordCachable type)
|
KeywordType(KeywordCachable type)
|
||||||
{
|
{
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
this.isPrivate = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
KeywordType(KeywordCachable type, boolean isPrivate)
|
||||||
|
{
|
||||||
|
this.type = type;
|
||||||
|
this.isPrivate = isPrivate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeywordCachable getType()
|
public KeywordCachable getType()
|
||||||
{
|
{
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isPrivate() {
|
||||||
|
return isPrivate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum KeywordCachable
|
enum KeywordCachable
|
||||||
|
|
Loading…
Reference in a new issue