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

@ -35,7 +35,7 @@ import java.util.UUID;
/** /**
* PlotSquared API. * PlotSquared API.
* *
* <p>Useful classes:</p> * <p>Useful classes:
* <ul> * <ul>
* <li>{@link BukkitUtil}</li> * <li>{@link BukkitUtil}</li>
* <li>{@link PlotPlayer}</li> * <li>{@link PlotPlayer}</li>
@ -655,7 +655,7 @@ public class PlotAPI {
/** /**
* Get the numbers of plots, which the player is able to build in. * Get the numbers of plots, which the player is able to build in.
* *
* @param player Player, for whom we're getting the plots * @param player player, for whom we're getting the plots
* *
* @return the number of allowed plots * @return the number of allowed plots
* *
@ -671,8 +671,8 @@ public class PlotAPI {
* *
* @see PlotPlayer#wrap(Object) * @see PlotPlayer#wrap(Object)
* *
* @param player The player to wrap * @param player the player to wrap
* @return A PlotPlayer * @return a {@code PlotPlayer}
*/ */
public PlotPlayer wrapPlayer(Player player) { public PlotPlayer wrapPlayer(Player player) {
return PlotPlayer.wrap(player); return PlotPlayer.wrap(player);
@ -682,12 +682,12 @@ public class PlotAPI {
* Get the PlotPlayer for a UUID. * Get the PlotPlayer for a UUID.
* *
* <p><i>Please note that PlotSquared can be configured to provide * <p><i>Please note that PlotSquared can be configured to provide
* different UUIDs than bukkit</i></p> * different UUIDs than bukkit</i>
* *
* @see PlotPlayer#wrap(Object) * @see PlotPlayer#wrap(Object)
* *
* @param uuid The uuid of the player to wrap * @param uuid the uuid of the player to wrap
* @return A PlotPlayer * @return a {@code PlotPlayer}
*/ */
public PlotPlayer wrapPlayer(UUID uuid) { public PlotPlayer wrapPlayer(UUID uuid) {
return PlotPlayer.wrap(uuid); return PlotPlayer.wrap(uuid);
@ -698,8 +698,8 @@ public class PlotAPI {
* *
* @see PlotPlayer#wrap(Object) * @see PlotPlayer#wrap(Object)
* *
* @param player The player to wrap * @param player the player to wrap
* @return The PlotPlayer * @return a {@code PlotPlayer}
*/ */
public PlotPlayer wrapPlayer(String player) { public PlotPlayer wrapPlayer(String player) {
return PlotPlayer.wrap(player); return PlotPlayer.wrap(player);
@ -707,13 +707,14 @@ public class PlotAPI {
/** /**
* Get the PlotPlayer for an offline player. * Get the PlotPlayer for an offline player.
*
* <p>Note that this will work if the player is offline, however not all * <p>Note that this will work if the player is offline, however not all
* functionality will work</p> * functionality will work.
* *
* @see PlotPlayer#wrap(Object) * @see PlotPlayer#wrap(Object)
* *
* @param player The player to wrap * @param player the player to wrap
* @return The PlotPlayer * @return a {@code PlotPlayer}
*/ */
public PlotPlayer wrapPlayer(OfflinePlayer player) { public PlotPlayer wrapPlayer(OfflinePlayer player) {
return PlotPlayer.wrap(player); return PlotPlayer.wrap(player);

View File

@ -70,7 +70,7 @@ import com.plotsquared.bukkit.uuid.FileUUIDHandler;
import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper; import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper; import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
import com.plotsquared.bukkit.uuid.SQLUUIDHandler; import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.WorldEdit;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Chunk; import org.bukkit.Chunk;
@ -95,7 +95,7 @@ import java.util.UUID;
public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain { public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
public static WorldEditPlugin worldEdit; public static WorldEdit worldEdit;
private int[] version; private int[] version;
@ -385,7 +385,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
@Override @Override
public boolean initWorldEdit() { public boolean initWorldEdit() {
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) { if (getServer().getPluginManager().getPlugin("WorldEdit") != null) {
worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit"); worldEdit = WorldEdit.getInstance();
return true; return true;
} }
return false; return false;

View File

@ -9,9 +9,9 @@ import java.util.Collection;
/** /**
* Represents a wrapper around an array class of an arbitrary reference type, * Represents a wrapper around an array class of an arbitrary reference type,
* which properly implements "value" hash code and equality functions. * which properly implements "value" hash code and equality functions.
* <p> *
* This class is intended for use as a key to a map. * <p>This class is intended for use as a key to a map.
* </p> *
* @author Glen Husman * @author Glen Husman
* @param <E> The type of elements in the array. * @param <E> The type of elements in the array.
* @see Arrays * @see Arrays

View File

@ -109,6 +109,7 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.projectiles.BlockProjectileSource; import org.bukkit.projectiles.BlockProjectileSource;
import org.bukkit.projectiles.ProjectileSource; import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
@ -303,7 +304,6 @@ public class PlayerEvents extends PlotListener implements Listener {
return true; return true;
} }
Plot plot = area.getPlotAbs(loc); Plot plot = area.getPlotAbs(loc);
//
ProjectileSource shooter = entity.getShooter(); ProjectileSource shooter = entity.getShooter();
if (shooter instanceof Player) { if (shooter instanceof Player) {
PlotPlayer pp = BukkitUtil.getPlayer((Player) shooter); PlotPlayer pp = BukkitUtil.getPlayer((Player) shooter);
@ -780,7 +780,6 @@ public class PlayerEvents extends PlotListener implements Listener {
return; return;
} }
Plot plot = area.getOwnedPlot(location); Plot plot = area.getOwnedPlot(location);
Optional<Boolean> flag;
switch (block.getType()) { switch (block.getType()) {
case GRASS: case GRASS:
if (Flags.GRASS_GROW.isFalse(plot)) { if (Flags.GRASS_GROW.isFalse(plot)) {

View File

@ -10,8 +10,8 @@ public class BukkitOfflinePlayer implements OfflinePlotPlayer {
public final OfflinePlayer player; public final OfflinePlayer player;
/** /**
* <p>Please do not use this method. Instead use BukkitUtil.getPlayer(Player), * Please do not use this method. Instead use BukkitUtil.getPlayer(Player),
* as it caches player objects.</p> * as it caches player objects.
* *
* @param player * @param player
*/ */

View File

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

View File

@ -73,10 +73,10 @@ public enum C {
/* /*
* Static console * 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", 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 "
"static.console"), + "and security. PlotSquared will require Java 9 in a future update.", "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("&dPlease enable metrics for PlotSquared. Using metrics improves plugin stabability, performance, and features. "
CONSOLE_PLEASE_ENABLE_METRICS("&dUsing metrics will allow us to improve the plugin, please consider it :)", "static.console"), + "Bug fixes and new features are influenced on metrics.", "static.console"),
/* /*
* Confirm * Confirm
*/ */
@ -111,8 +111,7 @@ public enum C {
*/ */
CLUSTER_AVAILABLE_ARGS( CLUSTER_AVAILABLE_ARGS(
"$1The following sub commands are available: $4list$2, $4create$2, $4delete$2, $4resize$2, $4invite$2, $4kick$2, $4leave$2, " "$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", + "$4members$2, $4info$2, $4tp$2, $4sethome", "Cluster"),
"Cluster"),
CLUSTER_LIST_HEADING("$2There are $1%s$2 clusters in this world", "Cluster"), CLUSTER_LIST_HEADING("$2There are $1%s$2 clusters in this world", "Cluster"),
CLUSTER_LIST_ELEMENT("$2 - $1%s&-", "Cluster"), CLUSTER_LIST_ELEMENT("$2 - $1%s&-", "Cluster"),
CLUSTER_INTERSECTION("$2The proposed area overlaps with: %s0", "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_WORLD_TAKEN("$2%s is already a registered plotworld", "Setup"),
SETUP_MISSING_WORLD( 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 -" "$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", + " $1/plot setup back&-$2 - $1/plot setup cancel", "Setup"),
"Setup"),
SETUP_MISSING_GENERATOR( 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 - " "$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", + "$1/plot setup back&-$2 - $1/plot setup cancel", "Setup"),
"Setup"),
SETUP_INVALID_GENERATOR("$2Invalid generator. Possible options: %s", "Setup"), SETUP_INVALID_GENERATOR("$2Invalid generator. Possible options: %s", "Setup"),
/* /*
* Schematic Stuff * 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) { public static String color(String string) {
return StringMan.replaceFromMap(string, replacements); return StringMan.replaceFromMap(string, replacements);
} }
@ -779,6 +772,10 @@ public enum C {
} }
} }
public String f(final Object... args) {
return format(s(), args);
}
@Override @Override
public String toString() { public String toString() {
return this.s; return this.s;

View File

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

View File

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

View File

@ -23,6 +23,7 @@ import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil; import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.listener.PlotListener; import com.plotsquared.listener.PlotListener;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.geom.Area; import java.awt.geom.Area;
import java.awt.geom.PathIterator; import java.awt.geom.PathIterator;
@ -1957,8 +1958,8 @@ public class Plot {
} }
/** /**
* Check if a plot can be claimed * Check if a plot can be claimed by the provided player.
* @param player * @param player the claiming player
* @return * @return
*/ */
public boolean canClaim(PlotPlayer player) { 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 * @return
*/ */
public PlotId getMin() { public PlotId getMin() {
@ -491,18 +491,17 @@ public abstract class PlotArea {
} }
public int getPlotCount(UUID uuid) { public int getPlotCount(UUID uuid) {
int count = 0;
if (!Settings.DONE_COUNTS_TOWARDS_LIMIT) { if (!Settings.DONE_COUNTS_TOWARDS_LIMIT) {
int count = 0;
for (Plot plot : getPlotsAbs(uuid)) { for (Plot plot : getPlotsAbs(uuid)) {
if (!plot.hasFlag(Flags.DONE)) { if (!plot.hasFlag(Flags.DONE)) {
count++; count++;
} }
} }
} else {
count += getPlotsAbs(uuid).size();
}
return count; return count;
} }
return getPlotsAbs(uuid).size();
}
public int getPlotCount(PlotPlayer player) { public int getPlotCount(PlotPlayer player) {
return player != null ? getPlotCount(player.getUUID()) : 0; return player != null ? getPlotCount(player.getUUID()) : 0;
@ -530,6 +529,11 @@ public abstract class PlotArea {
return plot.getBasePlot(false); return plot.getBasePlot(false);
} }
/**
* Retrieves the number of claimed plot in the {@code PlotArea}.
*
* @return the number of claimed plots
*/
public int getPlotCount() { public int getPlotCount() {
return this.plots.size(); return this.plots.size();
} }
@ -591,6 +595,10 @@ public abstract class PlotArea {
return null; return null;
} }
/**
* A collection of the claimed plots in this {@code PlotArea}.
* @return
*/
public Collection<Plot> getPlots() { public Collection<Plot> getPlots() {
return this.plots.values(); 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 key
* @param value * @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 <T>
* @param key * @param key
* @return * @return
@ -82,6 +82,13 @@ public abstract class PlotPlayer implements CommandCaller {
return null; return null;
} }
/**
*
* @param key
* @param def
* @param <T>
* @return
*/
public <T> T getMeta(String key, T def) { public <T> T getMeta(String key, T def) {
if (this.meta != null) { if (this.meta != null) {
T value = (T) this.meta.get(key); 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. * Get the number of plots the player owns in the world.
* @param world * @param world the name of the plotworld to check.
* @return * @return
*/ */
public int getPlotCount(String world) { public int getPlotCount(String world) {
@ -170,7 +177,7 @@ public abstract class PlotPlayer implements CommandCaller {
for (PlotArea area : PS.get().getPlotAreas(world)) { for (PlotArea area : PS.get().getPlotAreas(world)) {
if (!Settings.DONE_COUNTS_TOWARDS_LIMIT) { if (!Settings.DONE_COUNTS_TOWARDS_LIMIT) {
for (Plot plot : area.getPlotsAbs(uuid)) { for (Plot plot : area.getPlotsAbs(uuid)) {
if (!plot.getFlags().containsKey("done")) { if (!plot.getFlag(Flags.DONE).isPresent()) {
count++; count++;
} }
} }
@ -248,26 +255,26 @@ public abstract class PlotPlayer implements CommandCaller {
public abstract UUID getUUID(); public abstract UUID getUUID();
/** /**
* Teleport the player to a location * Teleport the player to a location.
* @param location * @param location the target location
*/ */
public abstract void teleport(Location location); public abstract void teleport(Location location);
/** /**
* Is the player online * Checks if the player is online.
* @return * @return true if the player is online
*/ */
public abstract boolean isOnline(); public abstract boolean isOnline();
/** /**
* Get the player's name. * Retrieves the name of the player.
* @return * @return the players username
*/ */
public abstract String getName(); public abstract String getName();
/** /**
* Set the compass target. * Set the compass target.
* @param location * @param location the target location
*/ */
public abstract void setCompassTarget(Location 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 * @param key
* @return the attribute will be either true or false
*/ */
public boolean getAttribute(String key) { public boolean getAttribute(String key) {
if (!hasPersistentMeta("attrib_" + key)) { if (!hasPersistentMeta("attrib_" + key)) {
@ -303,31 +312,31 @@ public abstract class PlotPlayer implements CommandCaller {
/** /**
* Set the player's local weather * Set the player's local weather
* @param weather * @param weather the weather visible to the player
*/ */
public abstract void setWeather(PlotWeather weather); public abstract void setWeather(PlotWeather weather);
/** /**
* Get the player's gamemode. * Get the player's gamemode.
* @return * @return the gamemode of the player.
*/ */
public abstract PlotGameMode getGameMode(); public abstract PlotGameMode getGameMode();
/** /**
* Set the player's gameMode. * Set the player's gameMode.
* @param gameMode * @param gameMode the gamemode to set
*/ */
public abstract void setGameMode(PlotGameMode gameMode); public abstract void setGameMode(PlotGameMode gameMode);
/** /**
* Set the player's local time (ticks). * Set the player's local time (ticks).
* @param time * @param time the time visible to the player
*/ */
public abstract void setTime(long time); public abstract void setTime(long time);
/** /**
* Set the player's fly mode. * Set the player's fly mode.
* @param fly * @param fly if the player can fly
*/ */
public abstract void setFlight(boolean fly); public abstract void setFlight(boolean fly);
@ -340,13 +349,13 @@ public abstract class PlotPlayer implements CommandCaller {
/** /**
* Check if the player is banned * Check if the player is banned
* @return * @return true if the player is banned, false otherwise.
*/ */
public abstract boolean isBanned(); public abstract boolean isBanned();
/** /**
* Kick the player from the game. * Kick the player from the game.
* @param message * @param message the reason for the kick
*/ */
public abstract void kick(String message); 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 * @return
*/ */
public int getPlayerClusterCount() { public int getPlayerClusterCount() {
@ -404,9 +413,9 @@ public abstract class PlotPlayer implements CommandCaller {
} }
/** /**
* Return a Set of all plots a player owns * Return a set of all plots a player owns in a certain world.
* @param world * @param world the world to retrieve plots from
* @return * @return a set of plots the player owns in the provided world
*/ */
public Set<Plot> getPlots(String world) { public Set<Plot> getPlots(String world) {
UUID uuid = getUUID(); UUID uuid = getUUID();

View File

@ -10,7 +10,7 @@ buildscript {
} }
dependencies { dependencies {
classpath 'net.minecrell:VanillaGradle:2.0.3_1' classpath 'net.minecrell:VanillaGradle:2.0.3_1'
classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT' classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
} }
} }
@ -19,7 +19,7 @@ apply plugin: 'com.github.johnrengelman.shadow'
dependencies { dependencies {
compile project(':Core') compile project(':Core')
compile 'org.spongepowered:spongeapi:4.+' compile 'org.spongepowered:spongeapi:5.0.0-SNAPSHOT'
//compile 'org.mcstats.sponge:metrics:R8-SNAPSHOT' //compile 'org.mcstats.sponge:metrics:R8-SNAPSHOT'
} }
@ -41,8 +41,8 @@ repositories {
} }
} }
minecraft { minecraft {
version = "1.8.9" version = "1.9.4"
mappings = "stable_22" mappings = "snapshot_20160530"
runDir = 'run' runDir = 'run'
} }

View File

@ -1,3 +1,5 @@
import org.ajoberstar.grgit.Grgit
buildscript { buildscript {
repositories { repositories {
mavenCentral() mavenCentral()
@ -14,7 +16,7 @@ buildscript {
group = 'com.intellectualcrafters' group = 'com.intellectualcrafters'
def revision = "" def revision = ""
ext { ext {
git = org.ajoberstar.grgit.Grgit.open(file(".git")) git = Grgit.open(file(".git"))
revision = "-${git.head().abbreviatedId}" revision = "-${git.head().abbreviatedId}"
} }
version = "3.4.0${revision}" version = "3.4.0${revision}"
@ -27,7 +29,7 @@ subprojects {
apply plugin: 'idea' apply plugin: 'idea'
dependencies { dependencies {
compile(group: 'com.sk89q', name: 'worldedit', version:'6.0.0-SNAPSHOT') { compile(group: 'com.sk89q.worldedit', name: 'worldedit-core', version:'6.1.3-SNAPSHOT') {
exclude(module: 'bukkit-classloader-check') exclude(module: 'bukkit-classloader-check')
} }
compile 'com.google.guava:guava:10.0' compile 'com.google.guava:guava:10.0'