diff --git a/Core/src/main/java/com/intellectualcrafters/plot/PS.java b/Core/src/main/java/com/intellectualcrafters/plot/PS.java
index 20638a8c5..f3ff33533 100644
--- a/Core/src/main/java/com/intellectualcrafters/plot/PS.java
+++ b/Core/src/main/java/com/intellectualcrafters/plot/PS.java
@@ -1318,14 +1318,18 @@ public class PS {
}
/**
- * This method is called by the PlotGenerator class normally
- * - Initializes the PlotArea and PlotManager classes
- * - Registers the PlotArea and PlotManager classes
- * - Loads (and/or generates) the PlotArea configuration
- * - Sets up the world border if configured
- * If loading an augmented plot world:
- * - Creates the AugmentedPopulator classes
- * - Injects the AugmentedPopulator classes if required
+ * This method is called by the PlotGenerator class normally.
+ *
+ * - Initializes the PlotArea and PlotManager classes
+ * - Registers the PlotArea and PlotManager classes
+ * - Loads (and/or generates) the PlotArea configuration
+ * - Sets up the world border if configured
+ *
+ * If loading an augmented plot world:
+ *
+ * - Creates the AugmentedPopulator classes
+ * - Injects the AugmentedPopulator classes if required
+ *
* @param world The world to load
* @param baseGenerator The generator for that world, or null if no generator
*/
@@ -1464,14 +1468,14 @@ public class PS {
}
for (String areaId : areasSection.getKeys(false)) {
PS.log(C.PREFIX + "&3 - " + areaId);
- int i1 = areaId.indexOf("-");
- int i2 = areaId.indexOf(";");
+ int i1 = areaId.indexOf('-');
+ int i2 = areaId.indexOf(';');
if (i1 == -1 || i2 == -1) {
throw new IllegalArgumentException("Invalid Area identifier: " + areaId + ". Expected form `--`");
}
String name = areaId.substring(0, i1);
String rest = areaId.substring(i1 + 1);
- int i3 = rest.indexOf("-", i2 - name.length() - 1);
+ int i3 = rest.indexOf('-', i2 - name.length() - 1);
PlotId pos1 = PlotId.fromString(rest.substring(0, i3));
PlotId pos2 = PlotId.fromString(rest.substring(i3 + 1));
if (pos1 == null || pos2 == null || name.isEmpty()) {
@@ -1537,8 +1541,10 @@ public class PS {
}
/**
- * Setup the configuration for a plot world based on world arguments
- * e.g. /mv create normal -g PlotSquared:
+ * Setup the configuration for a plot world based on world arguments.
+ *
+ * e.g. /mv create normal -g PlotSquared:
+ *
* @param world The name of the world
* @param args The arguments
* @return boolean | if valid arguments were provided
@@ -1794,7 +1800,7 @@ public class PS {
}
/**
- * Setup the default flags for PlotSquared
+ * Setup the default flags for PlotSquared.
* - Create the flags
* - Register with FlagManager and parse raw flag values
*/
diff --git a/Core/src/main/java/com/intellectualcrafters/plot/Updater.java b/Core/src/main/java/com/intellectualcrafters/plot/Updater.java
index 0e57d1ca4..f1e24c170 100644
--- a/Core/src/main/java/com/intellectualcrafters/plot/Updater.java
+++ b/Core/src/main/java/com/intellectualcrafters/plot/Updater.java
@@ -4,6 +4,7 @@ import static com.intellectualcrafters.plot.PS.log;
import com.intellectualcrafters.json.JSONArray;
import com.intellectualcrafters.json.JSONObject;
+import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.util.StringMan;
import java.io.BufferedReader;
@@ -28,8 +29,10 @@ public class Updater {
return buffer.toString();
} catch (IOException e) {
- log("&dCould not check for updates (0)");
- e.printStackTrace();
+ log("&dCould not check for updates");
+ if (Settings.DEBUG) {
+ e.printStackTrace();
+ }
} finally {
try {
if (reader != null) {
diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Info.java
index 45b10e096..b6adfa250 100644
--- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Info.java
+++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Info.java
@@ -82,6 +82,7 @@ public class Info extends SubCommand {
"&cAlias: &6" + plot.getAlias(),
"&cBiome: &6" + plot.getBiome().replaceAll("_", "").toLowerCase(),
"&cCan Build: &6" + plot.isAdded(uuid),
+ "&cExpires: &6" + plot.isAdded(uuid),
"&cIs Denied: &6" + plot.isDenied(uuid)));
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cTrusted", "&cAmount: &6" + plot.getTrusted().size(),
"&8Click to view a list of the trusted users"));
@@ -109,8 +110,8 @@ public class Info extends SubCommand {
info = getCaption(arg);
if (info == null) {
MainUtil.sendMessage(player,
- "&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, &aowner&7, "
- + "&arating");
+ "&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aexpires&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, "
+ + "&aowner&7, " + "&arating");
return false;
}
full = true;
@@ -148,6 +149,8 @@ public class Info extends SubCommand {
return C.PLOT_INFO_OWNER.s();
case "rating":
return C.PLOT_INFO_RATING.s();
+ case "expires":
+ return C.PLOT_INFO_EXPIRES.s();
default:
return null;
}
diff --git a/Core/src/main/java/com/intellectualcrafters/plot/config/C.java b/Core/src/main/java/com/intellectualcrafters/plot/config/C.java
index f120f9433..a33cb177f 100644
--- a/Core/src/main/java/com/intellectualcrafters/plot/config/C.java
+++ b/Core/src/main/java/com/intellectualcrafters/plot/config/C.java
@@ -453,6 +453,7 @@ public enum C {
* Info
*/
NONE("None", "Info"),
+ NEVER("Never", "Info"),
UNKNOWN("Unknown", "Info"),
EVERYONE("Everyone", "Info"),
PLOT_UNOWNED("$2The current plot must have an owner to perform this action", "Info"),
@@ -464,6 +465,7 @@ public enum C {
+ "$1Biome: $2%biome%$1&-"
+ "$1Can Build: $2%build%$1&-"
+ "$1Rating: $2%rating%&-"
+ + "$1Expires: $2%expires%&-"
+ "$1Trusted: $2%trusted%$1&-"
+ "$1Members: $2%members%$1&-"
+ "$1Denied: $2%denied%$1&-"
@@ -479,6 +481,7 @@ public enum C {
PLOT_INFO_ID("$1ID:$2 %id%", "Info"),
PLOT_INFO_ALIAS("$1Alias:$2 %alias%", "Info"),
PLOT_INFO_SIZE("$1Size:$2 %size%", "Info"),
+ PLOT_INFO_EXPIRES("$1Expires:$2 %expires%", "Info"),
PLOT_USER_LIST(" $1%user%$2,", "Info"),
INFO_SYNTAX_CONSOLE("$2/plot info X;Y", "Info"),
/*
diff --git a/Core/src/main/java/com/intellectualcrafters/plot/flag/Flag.java b/Core/src/main/java/com/intellectualcrafters/plot/flag/Flag.java
index d4ed1bd7f..f01694bdd 100644
--- a/Core/src/main/java/com/intellectualcrafters/plot/flag/Flag.java
+++ b/Core/src/main/java/com/intellectualcrafters/plot/flag/Flag.java
@@ -6,6 +6,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class Flag implements Cloneable {
+
private AbstractFlag key;
private Object value;
private String name;
@@ -33,7 +34,7 @@ public class Flag implements Cloneable {
throw new IllegalArgumentException(key.getValueDesc() + " (" + value + ")");
}
}
-
+
/**
* Warning: Unchecked
* @param key
@@ -47,7 +48,7 @@ public class Flag implements Cloneable {
public Flag(String name) {
this.name = name;
}
-
+
/**
* Get the AbstractFlag used in creating the flag.
*
@@ -56,7 +57,7 @@ public class Flag implements Cloneable {
public AbstractFlag getAbstractFlag() {
return this.key;
}
-
+
/**
* Get the key for the AbstractFlag.
*
@@ -81,11 +82,11 @@ public class Flag implements Cloneable {
public Object getValue() {
return this.value;
}
-
+
public String getValueString() {
return this.key.toString(this.value);
}
-
+
@Override
public String toString() {
if ("".equals(this.value)) {
@@ -93,7 +94,7 @@ public class Flag implements Cloneable {
}
return this.key + ":" + getValueString();
}
-
+
@Override
public boolean equals(Object obj) {
if (this == obj) {
@@ -108,12 +109,12 @@ public class Flag implements Cloneable {
Flag other = (Flag) obj;
return this.key.getKey().equals(other.key.getKey()) && this.value.equals(other.value);
}
-
+
@Override
public int hashCode() {
return this.key.getKey().hashCode();
}
-
+
@Override
protected Object clone() {
try {
@@ -128,7 +129,8 @@ public class Flag implements Cloneable {
return new Flag(this.key, method.invoke(this.value));
}
return new Flag(this.key, this.key.parseValueRaw(this.key.toString(this.value)));
- } catch (CloneNotSupportedException | IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | InvocationTargetException e) {
+ } catch (CloneNotSupportedException | IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException |
+ InvocationTargetException e) {
e.printStackTrace();
}
return this;
diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java
index 32a44b945..d494b8cdd 100644
--- a/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java
+++ b/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java
@@ -36,6 +36,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
+import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
/**
@@ -704,7 +705,32 @@ public class MainUtil {
String trusted = getPlayerList(plot.getTrusted());
String members = getPlayerList(plot.getMembers());
String denied = getPlayerList(plot.getDenied());
-
+ String expires = C.UNKNOWN.s();
+ if (Settings.AUTO_CLEAR) {
+ if (plot.hasOwner()) {
+ Flag keep = plot.getFlag("keep");
+ if (keep != null) {
+ Object value = keep.getValue();
+ if (value instanceof Boolean) {
+ if (Boolean.TRUE.equals(value)) {
+ expires = C.NONE.s();
+ }
+ } else if (value instanceof Long) {
+ if ((Long) value > System.currentTimeMillis()) {
+ long l = System.currentTimeMillis() - (long) value;
+ expires = String.format("%d days", TimeUnit.MILLISECONDS.toDays(l));
+ }
+ }
+ } else {
+ long timestamp = ExpireManager.IMP.getTimestamp(plot.owner);
+ long compared = System.currentTimeMillis() - timestamp;
+ long l = Settings.AUTO_CLEAR_DAYS - TimeUnit.MILLISECONDS.toDays(compared);
+ expires = String.format("%d days", l);
+ }
+ }
+ } else {
+ expires = C.NEVER.s();
+ }
Flag descriptionFlag = FlagManager.getPlotFlagRaw(plot, "description");
String description = descriptionFlag == null ? C.NONE.s() : descriptionFlag.getValueString();
@@ -730,6 +756,7 @@ public class MainUtil {
info = info.replaceAll("%trusted%", trusted);
info = info.replaceAll("%helpers%", members);
info = info.replaceAll("%denied%", denied);
+ info = info.replaceAll("%expires%", expires);
info = info.replaceAll("%flags%", Matcher.quoteReplacement(flags));
info = info.replaceAll("%build%", build + "");
info = info.replaceAll("%desc%", "No description set.");
@@ -747,6 +774,10 @@ public class MainUtil {
String rating = "";
String prefix = "";
double[] ratings = MainUtil.getAverageRatings(plot);
+ for (double v : ratings) {
+
+ }
+
for (int i = 0; i < ratings.length; i++) {
rating += prefix + Settings.RATING_CATEGORIES.get(i) + "=" + String.format("%.1f", ratings[i]);
prefix = ",";