Fixed #852 and small changes

Hid updater error when debugging is not enabled.
Javadoc changes
This commit is contained in:
MattBDev 2016-04-05 19:10:26 -04:00
parent 9c81dfa5c3
commit 3df772aa4e
6 changed files with 76 additions and 28 deletions

View File

@ -1318,14 +1318,18 @@ public class PS {
} }
/** /**
* This method is called by the PlotGenerator class normally<br> * This method is called by the PlotGenerator class normally.
* - Initializes the PlotArea and PlotManager classes<br> * <ul>
* - Registers the PlotArea and PlotManager classes<br> * <li>Initializes the PlotArea and PlotManager classes</li>
* - Loads (and/or generates) the PlotArea configuration<br> * <li>Registers the PlotArea and PlotManager classes</li>
* - Sets up the world border if configured<br> * <li>Loads (and/or generates) the PlotArea configuration</li>
* If loading an augmented plot world:<br> * <li>Sets up the world border if configured</li>
* - Creates the AugmentedPopulator classes<br> * </ul>
* - Injects the AugmentedPopulator classes if required * If loading an augmented plot world:
* <ul>
* <li>Creates the AugmentedPopulator classes</li>
* <li>Injects the AugmentedPopulator classes if required</li>
* </ul>
* @param world The world to load * @param world The world to load
* @param baseGenerator The generator for that world, or null if no generator * @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)) { for (String areaId : areasSection.getKeys(false)) {
PS.log(C.PREFIX + "&3 - " + areaId); PS.log(C.PREFIX + "&3 - " + areaId);
int i1 = areaId.indexOf("-"); int i1 = areaId.indexOf('-');
int i2 = areaId.indexOf(";"); int i2 = areaId.indexOf(';');
if (i1 == -1 || i2 == -1) { if (i1 == -1 || i2 == -1) {
throw new IllegalArgumentException("Invalid Area identifier: " + areaId + ". Expected form `<name>-<pos1>-<pos2>`"); throw new IllegalArgumentException("Invalid Area identifier: " + areaId + ". Expected form `<name>-<pos1>-<pos2>`");
} }
String name = areaId.substring(0, i1); String name = areaId.substring(0, i1);
String rest = areaId.substring(i1 + 1); 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 pos1 = PlotId.fromString(rest.substring(0, i3));
PlotId pos2 = PlotId.fromString(rest.substring(i3 + 1)); PlotId pos2 = PlotId.fromString(rest.substring(i3 + 1));
if (pos1 == null || pos2 == null || name.isEmpty()) { 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<br> * Setup the configuration for a plot world based on world arguments.
* e.g. /mv create <world> normal -g PlotSquared:<args> * <p>
* <i>e.g. /mv create <world> normal -g PlotSquared:<args></i>
* </p>
* @param world The name of the world * @param world The name of the world
* @param args The arguments * @param args The arguments
* @return boolean | if valid arguments were provided * @return boolean | if valid arguments were provided
@ -1794,7 +1800,7 @@ public class PS {
} }
/** /**
* Setup the default flags for PlotSquared<br> * Setup the default flags for PlotSquared.
* - Create the flags * - Create the flags
* - Register with FlagManager and parse raw flag values * - Register with FlagManager and parse raw flag values
*/ */

View File

@ -4,6 +4,7 @@ import static com.intellectualcrafters.plot.PS.log;
import com.intellectualcrafters.json.JSONArray; import com.intellectualcrafters.json.JSONArray;
import com.intellectualcrafters.json.JSONObject; import com.intellectualcrafters.json.JSONObject;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.StringMan;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -28,8 +29,10 @@ public class Updater {
return buffer.toString(); return buffer.toString();
} catch (IOException e) { } catch (IOException e) {
log("&dCould not check for updates (0)"); log("&dCould not check for updates");
e.printStackTrace(); if (Settings.DEBUG) {
e.printStackTrace();
}
} finally { } finally {
try { try {
if (reader != null) { if (reader != null) {

View File

@ -82,6 +82,7 @@ public class Info extends SubCommand {
"&cAlias: &6" + plot.getAlias(), "&cAlias: &6" + plot.getAlias(),
"&cBiome: &6" + plot.getBiome().replaceAll("_", "").toLowerCase(), "&cBiome: &6" + plot.getBiome().replaceAll("_", "").toLowerCase(),
"&cCan Build: &6" + plot.isAdded(uuid), "&cCan Build: &6" + plot.isAdded(uuid),
"&cExpires: &6" + plot.isAdded(uuid),
"&cIs Denied: &6" + plot.isDenied(uuid))); "&cIs Denied: &6" + plot.isDenied(uuid)));
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cTrusted", "&cAmount: &6" + plot.getTrusted().size(), inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cTrusted", "&cAmount: &6" + plot.getTrusted().size(),
"&8Click to view a list of the trusted users")); "&8Click to view a list of the trusted users"));
@ -109,8 +110,8 @@ public class Info extends SubCommand {
info = getCaption(arg); info = getCaption(arg);
if (info == null) { if (info == null) {
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
"&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, &aowner&7, " "&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aexpires&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, "
+ "&arating"); + "&aowner&7, " + "&arating");
return false; return false;
} }
full = true; full = true;
@ -148,6 +149,8 @@ public class Info extends SubCommand {
return C.PLOT_INFO_OWNER.s(); return C.PLOT_INFO_OWNER.s();
case "rating": case "rating":
return C.PLOT_INFO_RATING.s(); return C.PLOT_INFO_RATING.s();
case "expires":
return C.PLOT_INFO_EXPIRES.s();
default: default:
return null; return null;
} }

View File

@ -453,6 +453,7 @@ public enum C {
* Info * Info
*/ */
NONE("None", "Info"), NONE("None", "Info"),
NEVER("Never", "Info"),
UNKNOWN("Unknown", "Info"), UNKNOWN("Unknown", "Info"),
EVERYONE("Everyone", "Info"), EVERYONE("Everyone", "Info"),
PLOT_UNOWNED("$2The current plot must have an owner to perform this action", "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&-" + "$1Biome: $2%biome%$1&-"
+ "$1Can Build: $2%build%$1&-" + "$1Can Build: $2%build%$1&-"
+ "$1Rating: $2%rating%&-" + "$1Rating: $2%rating%&-"
+ "$1Expires: $2%expires%&-"
+ "$1Trusted: $2%trusted%$1&-" + "$1Trusted: $2%trusted%$1&-"
+ "$1Members: $2%members%$1&-" + "$1Members: $2%members%$1&-"
+ "$1Denied: $2%denied%$1&-" + "$1Denied: $2%denied%$1&-"
@ -479,6 +481,7 @@ public enum C {
PLOT_INFO_ID("$1ID:$2 %id%", "Info"), PLOT_INFO_ID("$1ID:$2 %id%", "Info"),
PLOT_INFO_ALIAS("$1Alias:$2 %alias%", "Info"), PLOT_INFO_ALIAS("$1Alias:$2 %alias%", "Info"),
PLOT_INFO_SIZE("$1Size:$2 %size%", "Info"), PLOT_INFO_SIZE("$1Size:$2 %size%", "Info"),
PLOT_INFO_EXPIRES("$1Expires:$2 %expires%", "Info"),
PLOT_USER_LIST(" $1%user%$2,", "Info"), PLOT_USER_LIST(" $1%user%$2,", "Info"),
INFO_SYNTAX_CONSOLE("$2/plot info X;Y", "Info"), INFO_SYNTAX_CONSOLE("$2/plot info X;Y", "Info"),
/* /*

View File

@ -6,6 +6,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
public class Flag<T> implements Cloneable { public class Flag<T> implements Cloneable {
private AbstractFlag key; private AbstractFlag key;
private Object value; private Object value;
private String name; private String name;
@ -128,7 +129,8 @@ public class Flag<T> implements Cloneable {
return new Flag(this.key, method.invoke(this.value)); return new Flag(this.key, method.invoke(this.value));
} }
return new Flag(this.key, this.key.parseValueRaw(this.key.toString(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(); e.printStackTrace();
} }
return this; return this;

View File

@ -36,6 +36,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher; import java.util.regex.Matcher;
/** /**
@ -704,7 +705,32 @@ public class MainUtil {
String trusted = getPlayerList(plot.getTrusted()); String trusted = getPlayerList(plot.getTrusted());
String members = getPlayerList(plot.getMembers()); String members = getPlayerList(plot.getMembers());
String denied = getPlayerList(plot.getDenied()); 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"); Flag descriptionFlag = FlagManager.getPlotFlagRaw(plot, "description");
String description = descriptionFlag == null ? C.NONE.s() : descriptionFlag.getValueString(); String description = descriptionFlag == null ? C.NONE.s() : descriptionFlag.getValueString();
@ -730,6 +756,7 @@ public class MainUtil {
info = info.replaceAll("%trusted%", trusted); info = info.replaceAll("%trusted%", trusted);
info = info.replaceAll("%helpers%", members); info = info.replaceAll("%helpers%", members);
info = info.replaceAll("%denied%", denied); info = info.replaceAll("%denied%", denied);
info = info.replaceAll("%expires%", expires);
info = info.replaceAll("%flags%", Matcher.quoteReplacement(flags)); info = info.replaceAll("%flags%", Matcher.quoteReplacement(flags));
info = info.replaceAll("%build%", build + ""); info = info.replaceAll("%build%", build + "");
info = info.replaceAll("%desc%", "No description set."); info = info.replaceAll("%desc%", "No description set.");
@ -747,6 +774,10 @@ public class MainUtil {
String rating = ""; String rating = "";
String prefix = ""; String prefix = "";
double[] ratings = MainUtil.getAverageRatings(plot); double[] ratings = MainUtil.getAverageRatings(plot);
for (double v : ratings) {
}
for (int i = 0; i < ratings.length; i++) { for (int i = 0; i < ratings.length; i++) {
rating += prefix + Settings.RATING_CATEGORIES.get(i) + "=" + String.format("%.1f", ratings[i]); rating += prefix + Settings.RATING_CATEGORIES.get(i) + "=" + String.format("%.1f", ratings[i]);
prefix = ","; prefix = ",";