flags + meta

This commit is contained in:
boy0001 2015-05-04 19:52:37 +10:00
parent f1a7e0d73f
commit 1ad65122b7
8 changed files with 50 additions and 19 deletions

View File

@ -23,6 +23,7 @@ package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
import java.util.Collection;
import java.util.UUID;
import java.util.regex.Matcher;
import org.apache.commons.lang.StringUtils;
@ -94,7 +95,7 @@ public class Info extends SubCommand {
}
}
if ((args.length == 1) && args[0].equalsIgnoreCase("inv")) {
new InfoInventory(plot, player).build().display();
new InfoInventory(plot, player).build().display();
return true;
}
final boolean hasOwner = plot.hasOwner();
@ -189,7 +190,7 @@ public class Info extends SubCommand {
info = info.replaceAll("%trusted%", trusted);
info = info.replaceAll("%denied%", denied);
info = info.replaceAll("%rating%", rating);
info = info.replaceAll("%flags%", flags);
info = info.replaceAll("%flags%", Matcher.quoteReplacement(flags));
info = info.replaceAll("%build%", build + "");
info = info.replaceAll("%desc%", "No description set.");
return info;

View File

@ -187,7 +187,7 @@ public enum C {
/*
* Core Stuff
*/
PREFIX("$3[$1P2$3] "),
PREFIX("$3[$1P2$3] $2"),
ENABLED("$1PlotSquared is now enabled"),
EXAMPLE_MESSAGE("$2This is an example message &k!!!"),
/*

View File

@ -909,7 +909,7 @@ public class SQLManager implements AbstractDB {
}
final Set<Flag> flags = new HashSet<Flag>();
boolean exception = false;
for (final String element : flags_string) {
for (String element : flags_string) {
if (element.contains(":")) {
final String[] split = element.split(":");
try {
@ -921,7 +921,13 @@ public class SQLManager implements AbstractDB {
exception = true;
}
} else {
flags.add(new Flag(FlagManager.getFlag(element, true), ""));
element = element.replaceAll("\u00AF", ":").replaceAll("\u00B4", ",");
if (StringUtils.isAlpha(element.replaceAll("_", "").replaceAll("-", ""))) {
flags.add(new Flag(FlagManager.getFlag(element, true), ""));
}
else {
System.out.print("INVALID FLAG: " + element);
}
}
}
if (exception) {

View File

@ -36,13 +36,8 @@ public class Flag {
* @throws IllegalArgumentException if you provide inadequate inputs
*/
public Flag(final AbstractFlag key, final String value) {
final char[] allowedCharacters = new char[] { '[', ']', '(', ')', ',', '_', '-', '.', ',', '?', '!', '&', ':', '\u00A7' };
String tempValue = value;
for (final char c : allowedCharacters) {
tempValue = tempValue.replace(c, 'c');
}
if (!StringUtils.isAlphanumericSpace(tempValue)) {
throw new IllegalArgumentException("Flag must be alphanumerical (colours and some special characters are allowed)");
if (!StringUtils.isAsciiPrintable(value)) {
throw new IllegalArgumentException("Flag must be ascii");
}
if (value.length() > 128) {
throw new IllegalArgumentException("Value must be <= 128 characters");

View File

@ -329,6 +329,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
if (plot.isDenied(pp.getUUID())) {
if (!Permissions.hasPermission(pp, "plots.admin.entry.denied")) {
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.entry.denied");
player.teleport(event.getFrom());
event.setCancelled(true);
return;
}

View File

@ -1,5 +1,6 @@
package com.intellectualcrafters.plot.object;
import java.util.HashMap;
import java.util.HashSet;
import java.util.UUID;
@ -14,10 +15,12 @@ public class BukkitPlayer implements PlotPlayer {
public final Player player;
UUID uuid;
String name;
public HashSet<String> hasPerm = new HashSet<>();
public HashSet<String> noPerm = new HashSet<>();
private int op = 0;
private long last = 0;
public HashSet<String> hasPerm = new HashSet<>();
public HashSet<String> noPerm = new HashSet<>();
private HashMap<String, Object> meta;
/**
* Please do not use this method. Instead use BukkitUtil.getPlayer(Player), as it caches player objects.
@ -118,4 +121,27 @@ public class BukkitPlayer implements PlotPlayer {
public Location getLocationFull() {
return BukkitUtil.getLocationFull(this.player);
}
@Override
public void setMeta(String key, Object value) {
if (this.meta == null) {
this.meta = new HashMap<String, Object>();
}
this.meta.put(key, value);
}
@Override
public Object getMeta(String key) {
if (this.meta != null) {
return this.meta.get(key);
}
return null;
}
@Override
public void deleteMeta(String key) {
if (this.meta != null) {
this.meta.remove(key);
}
}
}

View File

@ -30,4 +30,8 @@ public interface PlotPlayer {
public String getName();
public void setCompassTarget(Location loc);
public void setMeta(String key, Object value);
public Object getMeta(String key);
public void deleteMeta(String key);
}

View File

@ -110,10 +110,8 @@ public class UUIDHandler {
if (CACHED) {
return;
}
PlotSquared.log(C.PREFIX.s() + "&6Starting player data caching");
long start = System.currentTimeMillis();
PlotSquared.log(C.PREFIX.s() + "&6Starting player data caching: " + world);
UUIDHandler.CACHED = true;
if (Settings.TWIN_MODE_UUID) {
HashSet<UUID> all = getAllUUIDS();
final File playerdataFolder = new File(world + File.separator + "playerdata");
@ -123,12 +121,13 @@ public class UUIDHandler {
return s.endsWith(".dat");
}
});
boolean check = all.size() == 0;
if (dat != null) {
for (final String current : dat) {
final String s = current.replaceAll(".dat$", "");
try {
final UUID uuid = UUID.fromString(s);
if (all.contains(uuid)) {
if (check || all.contains(uuid)) {
OfflinePlayer op = Bukkit.getOfflinePlayer(uuid);
add(new StringWrapper(op.getName()), uuid);
}
@ -140,7 +139,6 @@ public class UUIDHandler {
PlotSquared.log(C.PREFIX.s() + "&6Cached a total of: " + UUIDHandler.uuidMap.size() + " UUIDs");
return;
}
final HashSet<String> worlds = new HashSet<>();
worlds.add(world);
worlds.add("world");