mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 15:16:45 +01:00
Plot home position + another attempt to fix minor UUID issue.
This commit is contained in:
parent
d833935a30
commit
f70b7c3f93
@ -6,7 +6,7 @@
|
|||||||
<groupId>com.intellectualcrafters</groupId>
|
<groupId>com.intellectualcrafters</groupId>
|
||||||
|
|
||||||
<artifactId>PlotSquared</artifactId>
|
<artifactId>PlotSquared</artifactId>
|
||||||
<version>2.5.6</version>
|
<version>2.5.7</version>
|
||||||
<name>PlotSquared</name>
|
<name>PlotSquared</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<build>
|
<build>
|
||||||
|
@ -180,7 +180,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
String owner = "none";
|
String owner = "none";
|
||||||
if (plot.owner != null) {
|
if (plot.owner != null) {
|
||||||
owner = UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner).getName();
|
owner = UUIDHandler.getName(plot.owner);
|
||||||
}
|
}
|
||||||
if (owner == null) {
|
if (owner == null) {
|
||||||
owner = plot.owner.toString();
|
owner = plot.owner.toString();
|
||||||
|
@ -30,17 +30,20 @@ import com.intellectualcrafters.plot.flag.AbstractFlag;
|
|||||||
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.listeners.PlotListener;
|
import com.intellectualcrafters.plot.listeners.PlotListener;
|
||||||
|
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
import com.intellectualcrafters.plot.object.PlotHomePosition;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||||
import com.intellectualcrafters.plot.util.StringComparison;
|
import com.intellectualcrafters.plot.util.StringComparison;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -174,24 +177,25 @@ public class Set extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("home")) {
|
if (args[0].equalsIgnoreCase("home")) {
|
||||||
if (args.length < 2) {
|
if (args.length > 1) {
|
||||||
PlayerFunctions.sendMessage(plr, C.MISSING_POSITION);
|
if (args[1].equalsIgnoreCase("none")) {
|
||||||
return false;
|
plot.settings.setPosition(null);
|
||||||
}
|
DBFunc.setPosition(plr.getWorld().getName(), plot, "");
|
||||||
PlotHomePosition position = null;
|
|
||||||
for (final PlotHomePosition p : PlotHomePosition.values()) {
|
|
||||||
if (p.isMatching(args[1])) {
|
|
||||||
position = p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
return PlayerFunctions.sendMessage(plr, C.HOME_ARGUMENT);
|
||||||
|
}
|
||||||
|
//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")) {
|
if (args[0].equalsIgnoreCase("alias")) {
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
|
@ -147,8 +147,9 @@ public enum C {
|
|||||||
/*
|
/*
|
||||||
* Position
|
* Position
|
||||||
*/
|
*/
|
||||||
MISSING_POSITION("&cYou need to specify a position. Possible values: &6default&c, &6center"),
|
MISSING_POSITION("&cYou need to specify a position. Possible values: &6none"),
|
||||||
POSITION_SET("&cPlot home position set"),
|
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"),
|
INVALID_POSITION("&cThat is not a valid position value"),
|
||||||
/*
|
/*
|
||||||
* Time
|
* Time
|
||||||
|
@ -24,9 +24,9 @@ package com.intellectualcrafters.plot.database;
|
|||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
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.object.BlockLoc;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotComment;
|
import com.intellectualcrafters.plot.object.PlotComment;
|
||||||
import com.intellectualcrafters.plot.object.PlotHomePosition;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
@ -540,7 +540,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
user = UUID.fromString(o);
|
user = UUID.fromString(o);
|
||||||
uuids.put(o, user);
|
uuids.put(o, user);
|
||||||
}
|
}
|
||||||
p = new Plot(plot_id, user, new ArrayList<UUID>(), new ArrayList<UUID>(), new ArrayList<UUID>(), "", PlotHomePosition.DEFAULT, null, worldname, new boolean[]{false, false, false, false});
|
p = new Plot(plot_id, user, new ArrayList<UUID>(), new ArrayList<UUID>(), new ArrayList<UUID>(), "", null, null, worldname, new boolean[]{false, false, false, false});
|
||||||
plots.put(id, p);
|
plots.put(id, p);
|
||||||
}
|
}
|
||||||
// stmt.close();
|
// stmt.close();
|
||||||
@ -632,15 +632,20 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final String pos = r.getString("position");
|
final String pos = r.getString("position");
|
||||||
if (pos != null) {
|
|
||||||
for (final PlotHomePosition plotHomePosition : PlotHomePosition.values()) {
|
switch (pos.toLowerCase()) {
|
||||||
if (plotHomePosition.isMatching(pos)) {
|
case "":
|
||||||
if (plotHomePosition != PlotHomePosition.DEFAULT) {
|
case "default":
|
||||||
plot.settings.setPosition(plotHomePosition);
|
case "0,0,0":
|
||||||
}
|
case "center":
|
||||||
break;
|
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");
|
final Integer m = r.getInt("merged");
|
||||||
if (m != null) {
|
if (m != null) {
|
||||||
@ -886,7 +891,6 @@ public class SQLManager implements AbstractDB {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setPosition(final String world, final Plot plot, final String position) {
|
public void setPosition(final String world, final Plot plot, final String position) {
|
||||||
plot.settings.setPosition(PlotHomePosition.valueOf(position));
|
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package com.intellectualcrafters.plot.object;
|
package com.intellectualcrafters.plot.object;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
|
||||||
public class BlockLoc {
|
public class BlockLoc {
|
||||||
public int x;
|
public int x;
|
||||||
|
@ -109,7 +109,6 @@ import java.util.UUID;
|
|||||||
this.denied = denied;
|
this.denied = denied;
|
||||||
this.trusted = new ArrayList<>();
|
this.trusted = new ArrayList<>();
|
||||||
this.settings.setAlias("");
|
this.settings.setAlias("");
|
||||||
this.settings.setPosition(PlotHomePosition.DEFAULT);
|
|
||||||
this.delete = false;
|
this.delete = false;
|
||||||
this.settings.flags = new HashSet<Flag>();
|
this.settings.flags = new HashSet<Flag>();
|
||||||
this.world = world;
|
this.world = world;
|
||||||
@ -132,7 +131,6 @@ import java.util.UUID;
|
|||||||
this.denied = denied;
|
this.denied = denied;
|
||||||
this.trusted = new ArrayList<>();
|
this.trusted = new ArrayList<>();
|
||||||
this.settings.setAlias("");
|
this.settings.setAlias("");
|
||||||
this.settings.setPosition(PlotHomePosition.DEFAULT);
|
|
||||||
this.delete = false;
|
this.delete = false;
|
||||||
this.settings.flags = new HashSet<Flag>();
|
this.settings.flags = new HashSet<Flag>();
|
||||||
this.world = world;
|
this.world = world;
|
||||||
@ -152,7 +150,7 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public Plot(final PlotId id, final UUID owner, final Biome plotBiome, final ArrayList<UUID> helpers, final ArrayList<UUID> trusted, final ArrayList<UUID> denied, final String alias, final PlotHomePosition position, final Set<Flag> flags, final String world, final boolean[] merged) {
|
public Plot(final PlotId id, final UUID owner, final Biome plotBiome, final ArrayList<UUID> helpers, final ArrayList<UUID> trusted, final ArrayList<UUID> denied, final String alias, final BlockLoc position, final Set<Flag> flags, final String world, final boolean[] merged) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.settings = new PlotSettings(this);
|
this.settings = new PlotSettings(this);
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
@ -181,7 +179,7 @@ import java.util.UUID;
|
|||||||
* @param denied
|
* @param denied
|
||||||
* @param merged
|
* @param merged
|
||||||
*/
|
*/
|
||||||
public Plot(final PlotId id, final UUID owner, final ArrayList<UUID> helpers, final ArrayList<UUID> trusted, final ArrayList<UUID> denied, final String alias, final PlotHomePosition position, final Set<Flag> flags, final String world, final boolean[] merged) {
|
public Plot(final PlotId id, final UUID owner, final ArrayList<UUID> helpers, final ArrayList<UUID> trusted, final ArrayList<UUID> denied, final String alias, final BlockLoc position, final Set<Flag> flags, final String world, final boolean[] merged) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.settings = new PlotSettings(this);
|
this.settings = new PlotSettings(this);
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
|
@ -26,6 +26,7 @@ import com.intellectualcrafters.plot.flag.FlagManager;
|
|||||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||||
import com.sun.istack.internal.NotNull;
|
import com.sun.istack.internal.NotNull;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -63,7 +64,7 @@ import java.util.Set;
|
|||||||
/**
|
/**
|
||||||
* Home Position
|
* Home Position
|
||||||
*/
|
*/
|
||||||
private PlotHomePosition position;
|
private BlockLoc position;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -112,11 +113,14 @@ import java.util.Set;
|
|||||||
return PlotHelper.getPlotBottomLoc(this.plot.getWorld(), this.plot.getId()).add(1, 0, 1).getBlock().getBiome();
|
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;
|
return this.position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPosition(final PlotHomePosition position) {
|
public void setPosition(BlockLoc position) {
|
||||||
this.position = position;
|
this.position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,18 +53,6 @@ import java.util.*;
|
|||||||
return getCurrentPlot(player) != null;
|
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<PlotId> getPlotSelectionIds(@SuppressWarnings("unused") final World world, final PlotId pos1, final PlotId pos2) {
|
public static ArrayList<PlotId> getPlotSelectionIds(@SuppressWarnings("unused") final World world, final PlotId pos1, final PlotId pos2) {
|
||||||
final ArrayList<PlotId> myplots = new ArrayList<>();
|
final ArrayList<PlotId> myplots = new ArrayList<>();
|
||||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||||
|
@ -280,7 +280,7 @@ import java.util.UUID;
|
|||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
final OfflinePlayer plr = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
|
final OfflinePlayer plr = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
|
||||||
if (plr == null) {
|
if (!plr.hasPlayedBefore()) {
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
return plr.getName();
|
return plr.getName();
|
||||||
@ -889,22 +889,19 @@ import java.util.UUID;
|
|||||||
* @return Home Location
|
* @return Home Location
|
||||||
*/
|
*/
|
||||||
public static Location getPlotHome(final World w, final PlotId plotid) {
|
public static Location getPlotHome(final World w, final PlotId plotid) {
|
||||||
|
Plot plot = getPlot(w, plotid);
|
||||||
if (getPlot(w, plotid).settings.getPosition() == PlotHomePosition.DEFAULT) {
|
BlockLoc home = plot.settings.getPosition();
|
||||||
|
|
||||||
final Location bot = getPlotBottomLoc(w, plotid);
|
final Location bot = getPlotBottomLoc(w, plotid);
|
||||||
|
if (home == null) {
|
||||||
final int x = bot.getBlockX();
|
final Location top = getPlotTopLoc(w, plotid);
|
||||||
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);
|
|
||||||
final int x = top.getBlockX() - bot.getBlockX();
|
final int x = top.getBlockX() - bot.getBlockX();
|
||||||
final int z = top.getBlockZ() - bot.getBlockZ();
|
final int z = top.getBlockZ() - bot.getBlockZ();
|
||||||
final int y = getHeighestBlock(w, x, z);
|
final int y = getHeighestBlock(w, x, z);
|
||||||
return new Location(w, bot.getBlockX() + (x / 2), y, bot.getBlockZ() + (z / 2));
|
return new Location(w, bot.getBlockX() + (x / 2), y, bot.getBlockZ() + (z / 2));
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return bot.add(home.x, home.y, home.z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,15 +32,17 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
|
|||||||
name = null;
|
name = null;
|
||||||
}
|
}
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
return Bukkit.getOfflinePlayer(name);
|
OfflinePlayer op = Bukkit.getOfflinePlayer(name);
|
||||||
} else {
|
if (op.hasPlayedBefore()) {
|
||||||
|
return op;
|
||||||
|
}
|
||||||
|
}
|
||||||
for (final OfflinePlayer player : Bukkit.getOfflinePlayers()) {
|
for (final OfflinePlayer player : Bukkit.getOfflinePlayers()) {
|
||||||
if (getUUID(player).equals(uuid)) {
|
if (getUUID(player).equals(uuid)) {
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return null;
|
||||||
return Bukkit.getOfflinePlayer(uuid.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.object;
|
package com.intellectualcrafters.unused;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Citymonstret
|
* @author Citymonstret
|
Loading…
Reference in New Issue
Block a user