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>
* - Initializes the PlotArea and PlotManager classes<br>
* - Registers the PlotArea and PlotManager classes<br>
* - Loads (and/or generates) the PlotArea configuration<br>
* - Sets up the world border if configured<br>
* If loading an augmented plot world:<br>
* - Creates the AugmentedPopulator classes<br>
* - Injects the AugmentedPopulator classes if required
* This method is called by the PlotGenerator class normally.
* <ul>
* <li>Initializes the PlotArea and PlotManager classes</li>
* <li>Registers the PlotArea and PlotManager classes</li>
* <li>Loads (and/or generates) the PlotArea configuration</li>
* <li>Sets up the world border if configured</li>
* </ul>
* 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 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 `<name>-<pos1>-<pos2>`");
}
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<br>
* e.g. /mv create <world> normal -g PlotSquared:<args>
* Setup the configuration for a plot world based on world arguments.
* <p>
* <i>e.g. /mv create <world> normal -g PlotSquared:<args></i>
* </p>
* @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<br>
* Setup the default flags for PlotSquared.
* - Create the flags
* - 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.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) {

View File

@ -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;
}

View File

@ -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"),
/*

View File

@ -6,6 +6,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class Flag<T> implements Cloneable {
private AbstractFlag key;
private Object value;
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, 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;

View File

@ -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 = ",";