diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml
index 04768f347..7c3dfedbc 100644
--- a/PlotSquared/pom.xml
+++ b/PlotSquared/pom.xml
@@ -6,7 +6,7 @@
com.intellectualcrafters
PlotSquared
- 2.5.6
+ 2.5.7
PlotSquared
jar
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java
index e42cd871b..fc217beb2 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java
@@ -180,7 +180,7 @@ import java.util.UUID;
String owner = "none";
if (plot.owner != null) {
- owner = UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner).getName();
+ owner = UUIDHandler.getName(plot.owner);
}
if (owner == null) {
owner = plot.owner.toString();
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java
index 8fb61493f..72fc9333e 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java
@@ -30,17 +30,20 @@ import com.intellectualcrafters.plot.flag.AbstractFlag;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.listeners.PlotListener;
+import com.intellectualcrafters.plot.object.BlockLoc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotBlock;
-import com.intellectualcrafters.plot.object.PlotHomePosition;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import com.intellectualcrafters.plot.util.StringComparison;
+
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
+import org.bukkit.Location;
import org.bukkit.Material;
+import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.entity.Player;
@@ -174,23 +177,24 @@ public class Set extends SubCommand {
}
if (args[0].equalsIgnoreCase("home")) {
- if (args.length < 2) {
- PlayerFunctions.sendMessage(plr, C.MISSING_POSITION);
- return false;
- }
- PlotHomePosition position = null;
- for (final PlotHomePosition p : PlotHomePosition.values()) {
- if (p.isMatching(args[1])) {
- position = p;
+ if (args.length > 1) {
+ if (args[1].equalsIgnoreCase("none")) {
+ plot.settings.setPosition(null);
+ DBFunc.setPosition(plr.getWorld().getName(), plot, "");
+ return true;
}
+ return PlayerFunctions.sendMessage(plr, C.HOME_ARGUMENT);
}
- if (position == null) {
- PlayerFunctions.sendMessage(plr, C.INVALID_POSITION);
- return false;
- }
- DBFunc.setPosition(plr.getWorld().getName(), plot, position.toString());
- PlayerFunctions.sendMessage(plr, C.POSITION_SET);
- return true;
+ //set to current location
+ World world = plr.getWorld();
+ Location base = PlotHelper.getPlotBottomLoc(world, plot.id);
+ int y = PlotHelper.getHeighestBlock(world, base.getBlockX(), base.getBlockZ());
+ base.setY(y);
+ Location relative = plr.getLocation().subtract(base);
+ BlockLoc blockloc = new BlockLoc(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ());
+ plot.settings.setPosition(blockloc);
+ DBFunc.setPosition(plr.getWorld().getName(), plot, relative.getBlockX() + "," + relative.getBlockY() + "," + relative.getBlockZ());
+ return PlayerFunctions.sendMessage(plr, C.POSITION_SET);
}
if (args[0].equalsIgnoreCase("alias")) {
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java
index df4819f5f..6f152af59 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java
@@ -147,8 +147,9 @@ public enum C {
/*
* Position
*/
- MISSING_POSITION("&cYou need to specify a position. Possible values: &6default&c, &6center"),
- POSITION_SET("&cPlot home position set"),
+ MISSING_POSITION("&cYou need to specify a position. Possible values: &6none"),
+ POSITION_SET("&cPlot home position set to your current location"),
+ HOME_ARGUMENT("&cUse /plot set home [none]"),
INVALID_POSITION("&cThat is not a valid position value"),
/*
* Time
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java
index 336010446..b7ce4c65f 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java
@@ -24,9 +24,9 @@ package com.intellectualcrafters.plot.database;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
+import com.intellectualcrafters.plot.object.BlockLoc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotComment;
-import com.intellectualcrafters.plot.object.PlotHomePosition;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
@@ -540,7 +540,7 @@ public class SQLManager implements AbstractDB {
user = UUID.fromString(o);
uuids.put(o, user);
}
- p = new Plot(plot_id, user, new ArrayList(), new ArrayList(), new ArrayList(), "", PlotHomePosition.DEFAULT, null, worldname, new boolean[]{false, false, false, false});
+ p = new Plot(plot_id, user, new ArrayList(), new ArrayList(), new ArrayList(), "", null, null, worldname, new boolean[]{false, false, false, false});
plots.put(id, p);
}
// stmt.close();
@@ -632,15 +632,20 @@ public class SQLManager implements AbstractDB {
}
final String pos = r.getString("position");
- if (pos != null) {
- for (final PlotHomePosition plotHomePosition : PlotHomePosition.values()) {
- if (plotHomePosition.isMatching(pos)) {
- if (plotHomePosition != PlotHomePosition.DEFAULT) {
- plot.settings.setPosition(plotHomePosition);
- }
- break;
+
+ switch (pos.toLowerCase()) {
+ case "":
+ case "default":
+ case "0,0,0":
+ case "center":
+ break;
+ default:
+ try {
+ String[] split = pos.split(",");
+ BlockLoc loc = new BlockLoc(Integer.parseInt(split[0]),Integer.parseInt(split[1]),Integer.parseInt(split[2]));
+ plot.settings.setPosition(loc);
}
- }
+ catch (Exception e) {}
}
final Integer m = r.getInt("merged");
if (m != null) {
@@ -886,7 +891,6 @@ public class SQLManager implements AbstractDB {
*/
@Override
public void setPosition(final String world, final Plot plot, final String position) {
- plot.settings.setPosition(PlotHomePosition.valueOf(position));
TaskManager.runTask(new Runnable() {
@Override
public void run() {
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockLoc.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockLoc.java
index 5c6659f8d..25fe9fb26 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockLoc.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockLoc.java
@@ -1,5 +1,8 @@
package com.intellectualcrafters.plot.object;
+import org.bukkit.Location;
+import org.bukkit.World;
+
public class BlockLoc {
public int x;
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java
index 1a65ee042..37012667d 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java
@@ -109,7 +109,6 @@ import java.util.UUID;
this.denied = denied;
this.trusted = new ArrayList<>();
this.settings.setAlias("");
- this.settings.setPosition(PlotHomePosition.DEFAULT);
this.delete = false;
this.settings.flags = new HashSet();
this.world = world;
@@ -132,7 +131,6 @@ import java.util.UUID;
this.denied = denied;
this.trusted = new ArrayList<>();
this.settings.setAlias("");
- this.settings.setPosition(PlotHomePosition.DEFAULT);
this.delete = false;
this.settings.flags = new HashSet();
this.world = world;
@@ -152,7 +150,7 @@ import java.util.UUID;
*/
@Deprecated
@SuppressWarnings("unused")
- public Plot(final PlotId id, final UUID owner, final Biome plotBiome, final ArrayList helpers, final ArrayList trusted, final ArrayList denied, final String alias, final PlotHomePosition position, final Set flags, final String world, final boolean[] merged) {
+ public Plot(final PlotId id, final UUID owner, final Biome plotBiome, final ArrayList helpers, final ArrayList trusted, final ArrayList denied, final String alias, final BlockLoc position, final Set flags, final String world, final boolean[] merged) {
this.id = id;
this.settings = new PlotSettings(this);
this.owner = owner;
@@ -181,7 +179,7 @@ import java.util.UUID;
* @param denied
* @param merged
*/
- public Plot(final PlotId id, final UUID owner, final ArrayList helpers, final ArrayList trusted, final ArrayList denied, final String alias, final PlotHomePosition position, final Set flags, final String world, final boolean[] merged) {
+ public Plot(final PlotId id, final UUID owner, final ArrayList helpers, final ArrayList trusted, final ArrayList denied, final String alias, final BlockLoc position, final Set flags, final String world, final boolean[] merged) {
this.id = id;
this.settings = new PlotSettings(this);
this.owner = owner;
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java
index 136ed31aa..dfaf52212 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java
@@ -26,6 +26,7 @@ import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.util.PlotHelper;
import com.sun.istack.internal.NotNull;
+import org.bukkit.Location;
import org.bukkit.block.Biome;
import java.util.ArrayList;
@@ -63,7 +64,7 @@ import java.util.Set;
/**
* Home Position
*/
- private PlotHomePosition position;
+ private BlockLoc position;
/**
* Constructor
@@ -112,11 +113,14 @@ import java.util.Set;
return PlotHelper.getPlotBottomLoc(this.plot.getWorld(), this.plot.getId()).add(1, 0, 1).getBlock().getBiome();
}
- public PlotHomePosition getPosition() {
+ public BlockLoc getPosition() {
+ if (this.position == null) {
+ return new BlockLoc(0, 0, 0);
+ }
return this.position;
}
- public void setPosition(final PlotHomePosition position) {
+ public void setPosition(BlockLoc position) {
this.position = position;
}
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java
index 8569d0408..991e76fd9 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java
@@ -53,18 +53,6 @@ import java.util.*;
return getCurrentPlot(player) != null;
}
- /**
- * @param plot plot
- *
- * @return
- */
- public static boolean hasExpired(final Plot plot) {
- final OfflinePlayer player = UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner);
- final long lp = player.getLastPlayed();
- final long cu = System.currentTimeMillis();
- return (lp - cu) > 30l;
- }
-
public static ArrayList getPlotSelectionIds(@SuppressWarnings("unused") final World world, final PlotId pos1, final PlotId pos2) {
final ArrayList myplots = new ArrayList<>();
for (int x = pos1.x; x <= pos2.x; x++) {
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java
index 4217850a8..32aefce28 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java
@@ -280,7 +280,7 @@ import java.util.UUID;
return "unknown";
}
final OfflinePlayer plr = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
- if (plr == null) {
+ if (!plr.hasPlayedBefore()) {
return "unknown";
}
return plr.getName();
@@ -889,22 +889,19 @@ import java.util.UUID;
* @return Home Location
*/
public static Location getPlotHome(final World w, final PlotId plotid) {
-
- if (getPlot(w, plotid).settings.getPosition() == PlotHomePosition.DEFAULT) {
-
- final Location bot = getPlotBottomLoc(w, plotid);
-
- final int x = bot.getBlockX();
- final int z = bot.getBlockZ() - 2;
- final int y = getHeighestBlock(w, x, z);
- return new Location(w, x, y, z);
- } else {
- final Location bot = getPlotBottomLoc(w, plotid), top = getPlotTopLoc(w, plotid);
+ Plot plot = getPlot(w, plotid);
+ BlockLoc home = plot.settings.getPosition();
+ final Location bot = getPlotBottomLoc(w, plotid);
+ if (home == null) {
+ final Location top = getPlotTopLoc(w, plotid);
final int x = top.getBlockX() - bot.getBlockX();
final int z = top.getBlockZ() - bot.getBlockZ();
final int y = getHeighestBlock(w, x, z);
return new Location(w, bot.getBlockX() + (x / 2), y, bot.getBlockZ() + (z / 2));
}
+ else {
+ return bot.add(home.x, home.y, home.z);
+ }
}
/**
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/OfflineUUIDWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/OfflineUUIDWrapper.java
index 9851af247..80a2ab52a 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/OfflineUUIDWrapper.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/OfflineUUIDWrapper.java
@@ -32,15 +32,17 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
name = null;
}
if (name != null) {
- return Bukkit.getOfflinePlayer(name);
- } else {
- for (final OfflinePlayer player : Bukkit.getOfflinePlayers()) {
- if (getUUID(player).equals(uuid)) {
- return player;
- }
+ OfflinePlayer op = Bukkit.getOfflinePlayer(name);
+ if (op.hasPlayedBefore()) {
+ return op;
}
}
- return Bukkit.getOfflinePlayer(uuid.toString());
+ for (final OfflinePlayer player : Bukkit.getOfflinePlayers()) {
+ if (getUUID(player).equals(uuid)) {
+ return player;
+ }
+ }
+ return null;
}
@Override
diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHomePosition.java b/PlotSquared/src/main/java/com/intellectualcrafters/unused/PlotHomePosition.java
similarity index 98%
rename from PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHomePosition.java
rename to PlotSquared/src/main/java/com/intellectualcrafters/unused/PlotHomePosition.java
index 921324cc0..e14f786f9 100644
--- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHomePosition.java
+++ b/PlotSquared/src/main/java/com/intellectualcrafters/unused/PlotHomePosition.java
@@ -19,7 +19,7 @@
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
-package com.intellectualcrafters.plot.object;
+package com.intellectualcrafters.unused;
/**
* @author Citymonstret