Various fixes and tweaks.

This commit is contained in:
MattBDev
2016-06-01 16:50:35 -04:00
parent 042d8950ee
commit f21d159911
14 changed files with 149 additions and 127 deletions

View File

@ -100,7 +100,6 @@ public class PS {
private final int[] version;
private final String platform;
private final Thread thread;
public ILogger logger;
public HashMap<String, Set<PlotCluster>> clusters_tmp;
public HashMap<String, HashMap<PlotId, Plot>> plots_tmp;
public File styleFile;
@ -114,6 +113,7 @@ public class PS {
public TaskManager TASK;
public WorldEdit worldedit;
public URL update;
private ILogger logger;
private boolean plotAreaHasCollision = false;
/**
* All plot areas (quick global access).
@ -148,11 +148,6 @@ public class PS {
this.file = new File(this.IMP.getDirectory().getParentFile(), "PlotSquared-" + platform + ".jar");
}
}
if (getJavaVersion() < 1.7) {
PS.log(C.CONSOLE_JAVA_OUTDATED_1_7);
this.IMP.disable();
return;
}
if (getJavaVersion() < 1.8) {
PS.log(C.CONSOLE_JAVA_OUTDATED_1_8);
}
@ -176,8 +171,7 @@ public class PS {
new WE_Anywhere();
}
} catch (Throwable e) {
e.printStackTrace();
} catch (Exception e) {
PS.debug("Incompatible version of WorldEdit, please upgrade: http://builds.enginehub.org/job/worldedit?branch=master");
}
@ -238,8 +232,7 @@ public class PS {
PS.log("&aThanks for installing PlotSquared!");
} else if (!get().checkVersion(PS.this.lastVersion, PS.this.version)) {
PS.log("&aThanks for updating from " + StringMan.join(PS.this.lastVersion, ".") + " to " + StringMan
.join(PS.this.version, ".")
+ "!");
.join(PS.this.version, ".") + "!");
DBFunc.dbManager.updateTables(PS.this.lastVersion);
}
}
@ -291,9 +284,9 @@ public class PS {
}
/**
* Get the instance of PlotSquared.
* Get an instance of PlotSquared.
*
* @return the instance created by IPlotMain
* @return instance of PlotSquared
*/
public static PS get() {
return PS.instance;
@ -323,6 +316,7 @@ public class PS {
/**
* Get the current logger
*
* @return
*/
public ILogger getLogger() {
@ -418,19 +412,20 @@ public class PS {
}
/**
* <p>Get the server platform this plugin is running on this is running on.
* This will be either <b>Bukkit</b> or <b>Sponge</b></p>
* @return The server platform
* Get the server platform this plugin is running on this is running on.
*
* <p>This will be either <b>Bukkit</b> or <b>Sponge</b></p>
* @return the server implementation
*/
public String getPlatform() {
return this.platform;
}
/**
* Get the database object.
* Get the {@link Database} object.
*
* @return Database object
* @see Database#getConnection() To get the database connection
* @return the database
* @see Database#getConnection() to get the database connection
*/
public Database getDatabase() {
return this.database;
@ -643,7 +638,7 @@ public class PS {
/**
* Add a global reference to a plot world.
*
* @param plotArea The PlotArea
* @param plotArea the {@code PlotArea} to add.
* @see #removePlotArea(PlotArea) To remove the reference
*/
public void addPlotArea(PlotArea plotArea) {
@ -710,8 +705,7 @@ public class PS {
/**
* Remove a plot world reference.
*
* @param area The PlotArea
* @see #addPlotArea(PlotArea) To add a reference
* @param area the {@code PlotArea} to remove
*/
public void removePlotArea(PlotArea area) {
Set<PlotArea> areas = getPlotAreas(area.worldname);
@ -1135,8 +1129,7 @@ public class PS {
* @return Set of plot
*/
public Set<Plot> getPlots(String world, PlotPlayer player) {
UUID uuid = player.getUUID();
return getPlots(world, uuid);
return getPlots(world, player.getUUID());
}
/**
@ -1146,8 +1139,7 @@ public class PS {
* @return Set of plot
*/
public Set<Plot> getPlots(PlotArea area, PlotPlayer player) {
UUID uuid = player.getUUID();
return getPlots(area, uuid);
return getPlots(area, player.getUUID());
}
/**
@ -2209,10 +2201,10 @@ public class PS {
}
/**
* Get the java version.
* @return Java version as a double
* Get the Java version.
* @return the java version
*/
public double getJavaVersion() {
private double getJavaVersion() {
return Double.parseDouble(System.getProperty("java.specification.version"));
}

View File

@ -73,10 +73,10 @@ public enum C {
/*
* Static console
*/
CONSOLE_JAVA_OUTDATED_1_7("&cYour java version is outdated. Please update to at least 1.7.\n&cURL: &6https://java.com/en/download/index.jsp",
"static.console"),
CONSOLE_JAVA_OUTDATED_1_8("&cIt's really recommended to run Java 1.8, as it increases performance", "static.console"),
CONSOLE_PLEASE_ENABLE_METRICS("&dUsing metrics will allow us to improve the plugin, please consider it :)", "static.console"),
CONSOLE_JAVA_OUTDATED_1_8("&cYour version of java is outdated. It is highly recommended that you update to Java 8 as it increases performance "
+ "and security. PlotSquared will require Java 9 in a future update.", "static.console"),
CONSOLE_PLEASE_ENABLE_METRICS("&dPlease enable metrics for PlotSquared. Using metrics improves plugin stabability, performance, and features. "
+ "Bug fixes and new features are influenced on metrics.", "static.console"),
/*
* Confirm
*/
@ -111,8 +111,7 @@ public enum C {
*/
CLUSTER_AVAILABLE_ARGS(
"$1The following sub commands are available: $4list$2, $4create$2, $4delete$2, $4resize$2, $4invite$2, $4kick$2, $4leave$2, "
+ "$4members$2, $4info$2, $4tp$2, $4sethome",
"Cluster"),
+ "$4members$2, $4info$2, $4tp$2, $4sethome", "Cluster"),
CLUSTER_LIST_HEADING("$2There are $1%s$2 clusters in this world", "Cluster"),
CLUSTER_LIST_ELEMENT("$2 - $1%s&-", "Cluster"),
CLUSTER_INTERSECTION("$2The proposed area overlaps with: %s0", "Cluster"),
@ -262,12 +261,10 @@ public enum C {
SETUP_WORLD_TAKEN("$2%s is already a registered plotworld", "Setup"),
SETUP_MISSING_WORLD(
"$2You need to specify a world name ($1/plot setup &l<world>$1 <generator>$2)&-$1Additional commands:&-$2 - $1/plot setup <value>&-$2 -"
+ " $1/plot setup back&-$2 - $1/plot setup cancel",
"Setup"),
+ " $1/plot setup back&-$2 - $1/plot setup cancel", "Setup"),
SETUP_MISSING_GENERATOR(
"$2You need to specify a generator ($1/plot setup <world> &l<generator>&r$2)&-$1Additional commands:&-$2 - $1/plot setup <value>&-$2 - "
+ "$1/plot setup back&-$2 - $1/plot setup cancel",
"Setup"),
+ "$1/plot setup back&-$2 - $1/plot setup cancel", "Setup"),
SETUP_INVALID_GENERATOR("$2Invalid generator. Possible options: %s", "Setup"),
/*
* Schematic Stuff
@ -687,10 +684,6 @@ public enum C {
}
}
public String f(final Object... args) {
return format(s(), args);
}
public static String color(String string) {
return StringMan.replaceFromMap(string, replacements);
}
@ -779,6 +772,10 @@ public enum C {
}
}
public String f(final Object... args) {
return format(s(), args);
}
@Override
public String toString() {
return this.s;

View File

@ -5,6 +5,7 @@ import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.flag.StringFlag;
import com.intellectualcrafters.plot.object.BlockLoc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea;
@ -795,7 +796,7 @@ public class SQLManager implements AbstractDB {
if (k != 0) {
flag_string.append(',');
}
flag_string.append(flag.getKey().getName() + ':' + flag.getKey().valueToString(flag.getValue()).replaceAll(":", "¯")
flag_string.append(flag.getKey().getName()).append(':').append(flag.getKey().valueToString(flag.getValue()).replaceAll(":", "¯")
.replaceAll(",", "´"));
k++;
}
@ -832,7 +833,7 @@ public class SQLManager implements AbstractDB {
if (k != 0) {
flag_string.append(',');
}
flag_string.append(flag.getKey().getName() + ':' + flag.getKey().valueToString(flag.getValue()).replaceAll(":", "¯")
flag_string.append(flag.getKey().getName()).append(':').append(flag.getKey().valueToString(flag.getValue()).replaceAll(":", "¯")
.replaceAll(",", "´"));
k++;
}
@ -1814,12 +1815,15 @@ public class SQLManager implements AbstractDB {
String[] split = element.split(":");
try {
String flag_str = split[1].replaceAll("¯", ":").replaceAll("\u00B4", ",");
Flag<?> flag = FlagManager.getFlag(split[0],false);
Flag<?> flag = FlagManager.getFlag(split[0],true);
if (flag == null) {
PS.debug(String.format("No flag found for string value of: %s", split[0]));
} else {
flags.put(flag, flag.parseValue(flag_str));
flag = new StringFlag(split[0]) {
@Override public String getValueDescription() {
return "Generic Filler Flag";
}
};
}
flags.put(flag, flag.parseValue(flag_str));
} catch (Exception e) {
e.printStackTrace();
exception = true;
@ -1827,12 +1831,15 @@ public class SQLManager implements AbstractDB {
} else {
element = element.replaceAll("\u00AF", ":").replaceAll("\u00B4", ",");
if (StringMan.isAlpha(element.replaceAll("_", "").replaceAll("-", ""))) {
Flag flag = FlagManager.getFlag(element,false);
Flag flag = FlagManager.getFlag(element,true);
if (flag == null) {
PS.debug(String.format("No flag found for string value of: %s", element));
} else {
flags.put(flag, flag.parseValue(""));
flag = new StringFlag(element) {
@Override public String getValueDescription() {
return "Generic Filler Flag";
}
};
}
flags.put(flag, flag.parseValue(""));
} else {
PS.debug("INVALID FLAG: " + element);
}
@ -2630,19 +2637,25 @@ public class SQLManager implements AbstractDB {
if (element.contains(":")) {
String[] split = element.split(":");
String flag_str = split[1].replaceAll("\u00AF", ":").replaceAll("<EFBFBD>", ",");
Flag flag = FlagManager.getFlag(split[0],false);
Flag flag = FlagManager.getFlag(split[0],true);
if (flag == null) {
PS.debug(String.format("No flag found for string value of: %s", split[0]));
} else {
flags.put(flag, flag.parseValue(flag_str));
flag = new StringFlag(split[0]) {
@Override public String getValueDescription() {
return "Generic Filler Flag";
}
};
}
flags.put(flag, flag.parseValue(flag_str));
} else {
Flag flag = FlagManager.getFlag(element,false);
Flag flag = FlagManager.getFlag(element,true);
if (flag == null) {
PS.debug(String.format("No flag found for string value of: %s", element));
} else {
flags.put(flag, flag.parseValue(""));
flag = new StringFlag(element) {
@Override public String getValueDescription() {
return "Generic Filler Flag";
}
};
}
flags.put(flag, flag.parseValue(""));
}
}
cluster.settings.flags = flags;

View File

@ -152,15 +152,15 @@ public class Flags {
PS.get().foreachPlotArea(new RunnableVal<PlotArea>() {
@Override public void run(PlotArea value) {
if (dupFinal != null) {
Object remove = null;
Object remove;
if (value.DEFAULT_FLAGS.containsKey(dupFinal)) {
remove = value.DEFAULT_FLAGS.remove(dupFinal);
if (!(remove instanceof String)) {
//error message? maybe?
return;
}
value.DEFAULT_FLAGS.put(flag,flag.parseValue((String) remove));
}
if (!(remove instanceof String)) {
//error message? maybe?
return;
}
value.DEFAULT_FLAGS.put(flag,flag.parseValue((String) remove));
}
}
});

View File

@ -23,6 +23,7 @@ import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.listener.PlotListener;
import java.awt.Rectangle;
import java.awt.geom.Area;
import java.awt.geom.PathIterator;
@ -1957,8 +1958,8 @@ public class Plot {
}
/**
* Check if a plot can be claimed
* @param player
* Check if a plot can be claimed by the provided player.
* @param player the claiming player
* @return
*/
public boolean canClaim(PlotPlayer player) {

View File

@ -137,7 +137,7 @@ public abstract class PlotArea {
}
/**
* Returns the min PlotId.
* Returns the minimum value of a {@link PlotId}.
* @return
*/
public PlotId getMin() {
@ -491,19 +491,18 @@ public abstract class PlotArea {
}
public int getPlotCount(UUID uuid) {
int count = 0;
if (!Settings.DONE_COUNTS_TOWARDS_LIMIT) {
int count = 0;
for (Plot plot : getPlotsAbs(uuid)) {
if (!plot.hasFlag(Flags.DONE)) {
count++;
}
}
} else {
count += getPlotsAbs(uuid).size();
return count;
}
return count;
return getPlotsAbs(uuid).size();
}
public int getPlotCount(PlotPlayer player) {
return player != null ? getPlotCount(player.getUUID()) : 0;
}
@ -529,7 +528,12 @@ public abstract class PlotArea {
}
return plot.getBasePlot(false);
}
/**
* Retrieves the number of claimed plot in the {@code PlotArea}.
*
* @return the number of claimed plots
*/
public int getPlotCount() {
return this.plots.size();
}
@ -590,7 +594,11 @@ public abstract class PlotArea {
}
return null;
}
/**
* A collection of the claimed plots in this {@code PlotArea}.
* @return
*/
public Collection<Plot> getPlots() {
return this.plots.values();
}

View File

@ -58,7 +58,7 @@ public abstract class PlotPlayer implements CommandCaller {
}
/**
* Set some session only metadata for the player
* Set some session only metadata for the player.
* @param key
* @param value
*/
@ -70,7 +70,7 @@ public abstract class PlotPlayer implements CommandCaller {
}
/**
* Get the metadata for a key.
* Get the session metadata for a key.
* @param <T>
* @param key
* @return
@ -82,6 +82,13 @@ public abstract class PlotPlayer implements CommandCaller {
return null;
}
/**
*
* @param key
* @param def
* @param <T>
* @return
*/
public <T> T getMeta(String key, T def) {
if (this.meta != null) {
T value = (T) this.meta.get(key);
@ -161,7 +168,7 @@ public abstract class PlotPlayer implements CommandCaller {
/**
* Get the number of plots the player owns in the world.
* @param world
* @param world the name of the plotworld to check.
* @return
*/
public int getPlotCount(String world) {
@ -170,7 +177,7 @@ public abstract class PlotPlayer implements CommandCaller {
for (PlotArea area : PS.get().getPlotAreas(world)) {
if (!Settings.DONE_COUNTS_TOWARDS_LIMIT) {
for (Plot plot : area.getPlotsAbs(uuid)) {
if (!plot.getFlags().containsKey("done")) {
if (!plot.getFlag(Flags.DONE).isPresent()) {
count++;
}
}
@ -248,26 +255,26 @@ public abstract class PlotPlayer implements CommandCaller {
public abstract UUID getUUID();
/**
* Teleport the player to a location
* @param location
* Teleport the player to a location.
* @param location the target location
*/
public abstract void teleport(Location location);
/**
* Is the player online
* @return
* Checks if the player is online.
* @return true if the player is online
*/
public abstract boolean isOnline();
/**
* Get the player's name.
* @return
* Retrieves the name of the player.
* @return the players username
*/
public abstract String getName();
/**
* Set the compass target.
* @param location
* @param location the target location
*/
public abstract void setCompassTarget(Location location);
@ -283,8 +290,10 @@ public abstract class PlotPlayer implements CommandCaller {
/**
* The attribute will be either true or false.
* Retrieves the player attribute.
*
* @param key
* @return the attribute will be either true or false
*/
public boolean getAttribute(String key) {
if (!hasPersistentMeta("attrib_" + key)) {
@ -303,31 +312,31 @@ public abstract class PlotPlayer implements CommandCaller {
/**
* Set the player's local weather
* @param weather
* @param weather the weather visible to the player
*/
public abstract void setWeather(PlotWeather weather);
/**
* Get the player's gamemode.
* @return
* @return the gamemode of the player.
*/
public abstract PlotGameMode getGameMode();
/**
* Set the player's gameMode.
* @param gameMode
* @param gameMode the gamemode to set
*/
public abstract void setGameMode(PlotGameMode gameMode);
/**
* Set the player's local time (ticks).
* @param time
* @param time the time visible to the player
*/
public abstract void setTime(long time);
/**
* Set the player's fly mode.
* @param fly
* @param fly if the player can fly
*/
public abstract void setFlight(boolean fly);
@ -340,13 +349,13 @@ public abstract class PlotPlayer implements CommandCaller {
/**
* Check if the player is banned
* @return
* @return true if the player is banned, false otherwise.
*/
public abstract boolean isBanned();
/**
* Kick the player from the game.
* @param message
* @param message the reason for the kick
*/
public abstract void kick(String message);
@ -389,7 +398,7 @@ public abstract class PlotPlayer implements CommandCaller {
}
/**
* Get the amount of clusters a player owns
* Get the amount of clusters a player owns.
* @return
*/
public int getPlayerClusterCount() {
@ -404,9 +413,9 @@ public abstract class PlotPlayer implements CommandCaller {
}
/**
* Return a Set of all plots a player owns
* @param world
* @return
* Return a set of all plots a player owns in a certain world.
* @param world the world to retrieve plots from
* @return a set of plots the player owns in the provided world
*/
public Set<Plot> getPlots(String world) {
UUID uuid = getUUID();