From a8b472984597a1e81d86e8495d8c2b8f9d8bdb76 Mon Sep 17 00:00:00 2001 From: sauilitired Date: Wed, 14 Nov 2018 23:51:56 +0100 Subject: [PATCH] Rename DBFunc#everyone to DBFunc#EVERYONE, and create two string constants :cat: --- .../plotme/ClassicPlotMeConnector.java | 6 ++--- .../database/plotme/PlotMeConnector_017.java | 6 ++--- .../bukkit/listeners/PlayerEvents.java | 20 +++++++------- .../plotsquared/plot/PlotSquared.java | 4 +-- .../plotsquared/plot/commands/Add.java | 4 +-- .../plotsquared/plot/commands/DebugExec.java | 16 ++++++------ .../plotsquared/plot/commands/Deny.java | 6 ++--- .../plotsquared/plot/commands/Info.java | 4 +-- .../plotsquared/plot/commands/Kick.java | 2 +- .../plot/commands/MainCommand.java | 16 ++++++------ .../plotsquared/plot/commands/Remove.java | 2 +- .../plotsquared/plot/commands/Trust.java | 4 +-- .../plotsquared/plot/database/AbstractDB.java | 2 +- .../plotsquared/plot/database/DBFunc.java | 4 ++- .../plot/listener/PlotListener.java | 10 +++---- .../plot/object/ConsolePlayer.java | 6 ++--- .../plotsquared/plot/object/Plot.java | 12 ++++----- .../plotsquared/plot/object/PlotArea.java | 4 +-- .../plotsquared/plot/object/PlotCluster.java | 6 ++--- .../plotsquared/plot/object/PlotPlayer.java | 6 ++++- .../plotsquared/plot/util/MainUtil.java | 4 +-- .../plot/util/expiry/ExpireManager.java | 4 +-- .../nukkit/listeners/PlayerEvents.java | 26 +++++++++---------- .../sponge/listener/MainListener.java | 10 +++---- 24 files changed, 95 insertions(+), 89 deletions(-) diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/database/plotme/ClassicPlotMeConnector.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/database/plotme/ClassicPlotMeConnector.java index 8c8daaa57..929360555 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/database/plotme/ClassicPlotMeConnector.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/database/plotme/ClassicPlotMeConnector.java @@ -100,7 +100,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector { UUID owner = UUIDHandler.getUUID(name, null); if (owner == null) { if ("*".equals(name)) { - owner = DBFunc.everyone; + owner = DBFunc.EVERYONE; } else { if (checkUUID || checkUUID2) { byte[] bytes = resultSet.getBytes(column); @@ -165,7 +165,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector { UUID denied = UUIDHandler.getUUID(name, null); if (denied == null) { if ("*".equals(name)) { - denied = DBFunc.everyone; + denied = DBFunc.EVERYONE; } else if (DBFunc.hasColumn(resultSet, "playerid")) { byte[] bytes = resultSet.getBytes("playerid"); if (bytes != null) { @@ -200,7 +200,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector { UUID helper = UUIDHandler.getUUID(name, null); if (helper == null) { if ("*".equals(name)) { - helper = DBFunc.everyone; + helper = DBFunc.EVERYONE; } else if (DBFunc.hasColumn(resultSet, "playerid")) { byte[] bytes = resultSet.getBytes("playerid"); if (bytes != null) { diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/database/plotme/PlotMeConnector_017.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/database/plotme/PlotMeConnector_017.java index 2df00092a..0aa5afcd5 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/database/plotme/PlotMeConnector_017.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/database/plotme/PlotMeConnector_017.java @@ -102,7 +102,7 @@ public class PlotMeConnector_017 extends APlotMeConnector { UUID owner = UUIDHandler.getUUID(name, null); if (owner == null) { if (name.equals("*")) { - owner = DBFunc.everyone; + owner = DBFunc.EVERYONE; } else { if (checkUUID) { byte[] bytes = resultSet.getBytes("ownerid"); @@ -148,7 +148,7 @@ public class PlotMeConnector_017 extends APlotMeConnector { continue; } String player = resultSet.getString("player"); - UUID denied = player.equals("*") ? DBFunc.everyone : UUID.fromString(player); + UUID denied = player.equals("*") ? DBFunc.EVERYONE : UUID.fromString(player); plot.getDenied().add(denied); } @@ -166,7 +166,7 @@ public class PlotMeConnector_017 extends APlotMeConnector { continue; } String player = resultSet.getString("player"); - UUID allowed = player.equals("*") ? DBFunc.everyone : UUID.fromString(player); + UUID allowed = player.equals("*") ? DBFunc.EVERYONE : UUID.fromString(player); plot.getTrusted().add(allowed); } resultSet.close(); diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java index fc3787a1f..741ad75f1 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java @@ -678,8 +678,8 @@ public class PlayerEvents extends PlotListener implements Listener { public void onTeleport(PlayerTeleportEvent event) { if (event.getTo() == null || event.getFrom() == null || !event.getFrom().getWorld() .equals(event.getTo().getWorld())) { - BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("location"); - BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("lastplot"); + BukkitUtil.getPlayer(event.getPlayer()).deleteMeta(PlotPlayer.META_LOCATION); + BukkitUtil.getPlayer(event.getPlayer()).deleteMeta(PlotPlayer.META_LAST_PLOT); org.bukkit.Location to = event.getTo(); if (to != null) { Player player = event.getPlayer(); @@ -796,14 +796,14 @@ public class PlayerEvents extends PlotListener implements Listener { TaskManager.TELEPORT_QUEUE.remove(pp.getName()); // Set last location Location loc = BukkitUtil.getLocation(to); - pp.setMeta("location", loc); + pp.setMeta(PlotPlayer.META_LOCATION, loc); PlotArea area = loc.getPlotArea(); if (area == null) { - pp.deleteMeta("lastplot"); + pp.deleteMeta(PlotPlayer.META_LAST_PLOT); return; } Plot now = area.getPlot(loc); - Plot lastPlot = pp.getMeta("lastplot"); + Plot lastPlot = pp.getMeta(PlotPlayer.META_LAST_PLOT); if (now == null) { if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport) { MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED); @@ -857,14 +857,14 @@ public class PlayerEvents extends PlotListener implements Listener { TaskManager.TELEPORT_QUEUE.remove(pp.getName()); // Set last location Location loc = BukkitUtil.getLocation(to); - pp.setMeta("location", loc); + pp.setMeta(PlotPlayer.META_LOCATION, loc); PlotArea area = loc.getPlotArea(); if (area == null) { - pp.deleteMeta("lastplot"); + pp.deleteMeta(PlotPlayer.META_LAST_PLOT); return; } Plot now = area.getPlot(loc); - Plot lastPlot = pp.getMeta("lastplot"); + Plot lastPlot = pp.getMeta(PlotPlayer.META_LAST_PLOT); if (now == null) { if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport) { MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED); @@ -1094,8 +1094,8 @@ public class PlayerEvents extends PlotListener implements Listener { Player player = event.getPlayer(); PlotPlayer pp = BukkitUtil.getPlayer(player); // Delete last location - pp.deleteMeta("location"); - Plot plot = (Plot) pp.deleteMeta("lastplot"); + pp.deleteMeta(PlotPlayer.META_LOCATION); + Plot plot = (Plot) pp.deleteMeta(PlotPlayer.META_LAST_PLOT); if (plot != null) { plotExit(pp, plot); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java index 8b48ab190..ac0c30784 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java @@ -160,7 +160,7 @@ import java.util.zip.ZipInputStream; startUuidCatching(); } else { // Start these separately - UUIDHandler.add(new StringWrapper("*"), DBFunc.everyone); + UUIDHandler.add(new StringWrapper("*"), DBFunc.EVERYONE); startExpiryTasks(); startPlotMeConversion(); } @@ -326,7 +326,7 @@ import java.util.zip.ZipInputStream; debug("Starting UUID caching"); UUIDHandler.startCaching(new Runnable() { @Override public void run() { - UUIDHandler.add(new StringWrapper("*"), DBFunc.everyone); + UUIDHandler.add(new StringWrapper("*"), DBFunc.EVERYONE); foreachPlotRaw(new RunnableVal() { @Override public void run(Plot plot) { if (plot.hasOwner() && plot.temp != -1) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java index 9cb4870ab..8d9df2774 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java @@ -37,7 +37,7 @@ public class Add extends Command { int size = plot.getTrusted().size() + plot.getMembers().size(); while (iter.hasNext()) { UUID uuid = iter.next(); - if (uuid == DBFunc.everyone && !( + if (uuid == DBFunc.EVERYONE && !( Permissions.hasPermission(player, C.PERMISSION_TRUST_EVERYONE) || Permissions .hasPermission(player, C.PERMISSION_ADMIN_COMMAND_TRUST))) { MainUtil.sendMessage(player, C.INVALID_PLAYER, MainUtil.getName(uuid)); @@ -63,7 +63,7 @@ public class Add extends Command { @Override // Success public void run() { for (UUID uuid : uuids) { - if (uuid != DBFunc.everyone) { + if (uuid != DBFunc.EVERYONE) { if (!plot.removeTrusted(uuid)) { if (plot.getDenied().contains(uuid)) { plot.removeDenied(uuid); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugExec.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugExec.java index 822c13123..ca5ba76d3 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugExec.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugExec.java @@ -349,22 +349,22 @@ import java.util.*; Command cmd = MainCommand.getInstance().getCommand(args[3]); String[] params = Arrays.copyOfRange(args, 4, args.length); if ("true".equals(args[1])) { - Location loc = player.getMeta("location"); - Plot plot = player.getMeta("lastplot"); + Location loc = player.getMeta(PlotPlayer.META_LOCATION); + Plot plot = player.getMeta(PlotPlayer.META_LAST_PLOT); for (Plot current : PlotSquared.get().getBasePlots()) { - player.setMeta("location", current.getBottomAbs()); - player.setMeta("lastplot", current); + player.setMeta(PlotPlayer.META_LOCATION, current.getBottomAbs()); + player.setMeta(PlotPlayer.META_LAST_PLOT, current); cmd.execute(player, params, null, null); } if (loc == null) { - player.deleteMeta("location"); + player.deleteMeta(PlotPlayer.META_LOCATION); } else { - player.setMeta("location", loc); + player.setMeta(PlotPlayer.META_LOCATION, loc); } if (plot == null) { - player.deleteMeta("lastplot"); + player.deleteMeta(PlotPlayer.META_LAST_PLOT); } else { - player.setMeta("lastplot", plot); + player.setMeta(PlotPlayer.META_LAST_PLOT, plot); } player.sendMessage("&c> " + (System.currentTimeMillis() - start)); return true; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Deny.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Deny.java index 1fe41541c..723a47cfb 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Deny.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Deny.java @@ -46,7 +46,7 @@ public class Deny extends SubCommand { Iterator iter = uuids.iterator(); while (iter.hasNext()) { UUID uuid = iter.next(); - if (uuid == DBFunc.everyone && !( + if (uuid == DBFunc.EVERYONE && !( Permissions.hasPermission(player, C.PERMISSION_DENY_EVERYONE) || Permissions .hasPermission(player, C.PERMISSION_ADMIN_COMMAND_DENY))) { MainUtil.sendMessage(player, C.INVALID_PLAYER, MainUtil.getName(uuid)); @@ -61,13 +61,13 @@ public class Deny extends SubCommand { MainUtil.sendMessage(player, C.ALREADY_ADDED, MainUtil.getName(uuid)); return false; } - if (uuid != DBFunc.everyone) { + if (uuid != DBFunc.EVERYONE) { plot.removeMember(uuid); plot.removeTrusted(uuid); } plot.addDenied(uuid); EventUtil.manager.callDenied(player, plot, uuid, true); - if (!uuid.equals(DBFunc.everyone)) { + if (!uuid.equals(DBFunc.EVERYONE)) { handleKick(UUIDHandler.getPlayer(uuid), plot); } else { for (PlotPlayer plotPlayer : plot.getPlayersInPlot()) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Info.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Info.java index 4850917f0..c8971c71c 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Info.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Info.java @@ -92,8 +92,8 @@ public class Info extends SubCommand { } boolean hasOwner = plot.hasOwner(); // Wildcard player {added} - boolean containsEveryone = plot.getTrusted().contains(DBFunc.everyone); - boolean trustedEveryone = plot.getMembers().contains(DBFunc.everyone); + boolean containsEveryone = plot.getTrusted().contains(DBFunc.EVERYONE); + boolean trustedEveryone = plot.getMembers().contains(DBFunc.EVERYONE); // Unclaimed? if (!hasOwner && !containsEveryone && !trustedEveryone) { MainUtil diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Kick.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Kick.java index 63d42bd29..f35423781 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Kick.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Kick.java @@ -43,7 +43,7 @@ public class Kick extends SubCommand { } Set players = new HashSet<>(); for (UUID uuid : uuids) { - if (uuid == DBFunc.everyone) { + if (uuid == DBFunc.EVERYONE) { for (PlotPlayer pp : plot.getPlayersInPlot()) { if (pp == player || Permissions .hasPermission(pp, C.PERMISSION_ADMIN_ENTRY_DENIED)) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/MainCommand.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/MainCommand.java index 053eec4d7..d297219c8 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/MainCommand.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/MainCommand.java @@ -206,12 +206,12 @@ import java.util.Arrays; Location newLoc = newPlot.getCenter(); if (player.canTeleport(newLoc)) { // Save meta - loc = player.getMeta("location"); - plot = player.getMeta("lastplot"); + loc = player.getMeta(PlotPlayer.META_LOCATION); + plot = player.getMeta(PlotPlayer.META_LAST_PLOT); tp = true; // Set loc - player.setMeta("location", newLoc); - player.setMeta("lastplot", newPlot); + player.setMeta(PlotPlayer.META_LOCATION, newLoc); + player.setMeta(PlotPlayer.META_LAST_PLOT, newPlot); } else { C.BORDER.send(player); } @@ -269,14 +269,14 @@ import java.util.Arrays; // Reset command scope // if (tp && !(player instanceof ConsolePlayer)) { if (loc == null) { - player.deleteMeta("location"); + player.deleteMeta(PlotPlayer.META_LOCATION); } else { - player.setMeta("location", loc); + player.setMeta(PlotPlayer.META_LOCATION, loc); } if (plot == null) { - player.deleteMeta("lastplot"); + player.deleteMeta(PlotPlayer.META_LAST_PLOT); } else { - player.setMeta("lastplot", plot); + player.setMeta(PlotPlayer.META_LAST_PLOT, plot); } } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Remove.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Remove.java index 1ff5ee764..666192e58 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Remove.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Remove.java @@ -65,7 +65,7 @@ public class Remove extends SubCommand { Set uuids = MainUtil.getUUIDsFromString(args[0]); if (!uuids.isEmpty()) { for (UUID uuid : uuids) { - if (uuid == DBFunc.everyone) { + if (uuid == DBFunc.EVERYONE) { if (plot.removeTrusted(uuid)) { EventUtil.manager.callTrusted(player, plot, uuid, false); count++; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trust.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trust.java index 3858d597b..493b48e2a 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trust.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trust.java @@ -38,7 +38,7 @@ public class Trust extends Command { int size = plot.getTrusted().size() + plot.getMembers().size(); while (iter.hasNext()) { UUID uuid = iter.next(); - if (uuid == DBFunc.everyone && !( + if (uuid == DBFunc.EVERYONE && !( Permissions.hasPermission(player, C.PERMISSION_TRUST_EVERYONE) || Permissions .hasPermission(player, C.PERMISSION_ADMIN_COMMAND_TRUST))) { MainUtil.sendMessage(player, C.INVALID_PLAYER, MainUtil.getName(uuid)); @@ -64,7 +64,7 @@ public class Trust extends Command { @Override // Success public void run() { for (UUID uuid : uuids) { - if (uuid != DBFunc.everyone) { + if (uuid != DBFunc.EVERYONE) { if (!plot.removeMember(uuid)) { if (plot.getDenied().contains(uuid)) { plot.removeDenied(uuid); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDB.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDB.java index 4b74ebd9c..a26d4d02e 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDB.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDB.java @@ -9,7 +9,7 @@ import java.util.*; public interface AbstractDB { /** - * The UUID that will count as everyone. + * The UUID that will count as EVERYONE. */ UUID everyone = UUID.fromString("1-1-3-3-7"); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/DBFunc.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/DBFunc.java index 2e3ca140c..5050c699f 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/DBFunc.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/DBFunc.java @@ -17,7 +17,9 @@ public class DBFunc { /** * The "global" uuid. */ - public static final UUID everyone = UUID.fromString("1-1-3-3-7"); + // TODO: Use this instead. public static final UUID EVERYONE = UUID.fromString("4aa2aaa4-c06b-485c-bc58-186aa1780d9b"); + public static final UUID EVERYONE = UUID.fromString("1-1-3-3-7"); + /** * Abstract Database Manager */ diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/PlotListener.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/PlotListener.java index 6d1eb2ba4..5eca8d910 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/PlotListener.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/PlotListener.java @@ -21,14 +21,14 @@ public class PlotListener { .hasPermission(player, "plots.admin.entry.denied")) { return false; } - Plot last = player.getMeta("lastplot"); + Plot last = player.getMeta(PlotPlayer.META_LAST_PLOT); if ((last != null) && !last.getId().equals(plot.getId())) { plotExit(player, last); } if (ExpireManager.IMP != null) { ExpireManager.IMP.handleEntry(player, plot); } - player.setMeta("lastplot", plot); + player.setMeta(PlotPlayer.META_LAST_PLOT, plot); EventUtil.manager.callEntry(player, plot); if (plot.hasOwner()) { Map, Object> flags = FlagManager.getPlotFlags(plot); @@ -160,7 +160,7 @@ public class PlotListener { .isEmpty()) { TaskManager.runTaskLaterAsync(new Runnable() { @Override public void run() { - Plot lastPlot = player.getMeta("lastplot"); + Plot lastPlot = player.getMeta(PlotPlayer.META_LAST_PLOT); if ((lastPlot != null) && plot.getId().equals(lastPlot.getId())) { Map replacements = new HashMap<>(); replacements.put("%x%", String.valueOf(lastPlot.getId().x)); @@ -185,7 +185,7 @@ public class PlotListener { } public static boolean plotExit(final PlotPlayer player, Plot plot) { - Object previous = player.deleteMeta("lastplot"); + Object previous = player.deleteMeta(PlotPlayer.META_LAST_PLOT); EventUtil.manager.callLeave(player, plot); if (plot.hasOwner()) { PlotArea pw = plot.getArea(); @@ -194,7 +194,7 @@ public class PlotListener { } if (Flags.DENY_EXIT.isTrue(plot)) { if (previous != null) { - player.setMeta("lastplot", previous); + player.setMeta(PlotPlayer.META_LAST_PLOT, previous); } return false; } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/ConsolePlayer.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/ConsolePlayer.java index 9ff8072f5..340c0952b 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/ConsolePlayer.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/ConsolePlayer.java @@ -46,7 +46,7 @@ public class ConsolePlayer extends PlotPlayer { } @Override public UUID getUUID() { - return DBFunc.everyone; + return DBFunc.EVERYONE; } @Override public long getLastPlayed() { @@ -66,8 +66,8 @@ public class ConsolePlayer extends PlotPlayer { } @Override public void teleport(Location location) { - setMeta("lastplot", location.getPlot()); - setMeta("location", location); + setMeta(PlotPlayer.META_LAST_PLOT, location.getPlot()); + setMeta(PlotPlayer.META_LOCATION, location); } @Override public boolean isOnline() { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java index d072df622..99af90eb7 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java @@ -384,10 +384,10 @@ public class Plot { if (getMembers().contains(uuid)) { return isOnline(); } - if (getTrusted().contains(uuid) || getTrusted().contains(DBFunc.everyone)) { + if (getTrusted().contains(uuid) || getTrusted().contains(DBFunc.EVERYONE)) { return true; } - if (getMembers().contains(DBFunc.everyone)) { + if (getMembers().contains(DBFunc.EVERYONE)) { return isOnline(); } return false; @@ -400,7 +400,7 @@ public class Plot { * @return boolean false if the player is allowed to enter */ public boolean isDenied(UUID uuid) { - return this.denied != null && (this.denied.contains(DBFunc.everyone) && !this.isAdded(uuid) + return this.denied != null && (this.denied.contains(DBFunc.EVERYONE) && !this.isAdded(uuid) || !this.isAdded(uuid) && this.denied.contains(uuid)); } @@ -1737,7 +1737,7 @@ public class Plot { * @param uuid */ public boolean removeDenied(UUID uuid) { - if (uuid == DBFunc.everyone && !denied.contains(uuid)) { + if (uuid == DBFunc.EVERYONE && !denied.contains(uuid)) { boolean result = false; for (UUID other : new HashSet<>(getDenied())) { result = rmvDenied(other) || result; @@ -1765,7 +1765,7 @@ public class Plot { * @param uuid */ public boolean removeTrusted(UUID uuid) { - if (uuid == DBFunc.everyone && !trusted.contains(uuid)) { + if (uuid == DBFunc.EVERYONE && !trusted.contains(uuid)) { boolean result = false; for (UUID other : new HashSet<>(getTrusted())) { result = rmvTrusted(other) || result; @@ -1796,7 +1796,7 @@ public class Plot { if (this.members == null) { return false; } - if (uuid == DBFunc.everyone && !members.contains(uuid)) { + if (uuid == DBFunc.EVERYONE && !members.contains(uuid)) { boolean result = false; for (UUID other : new HashSet<>(this.members)) { result = rmvMember(other) || result; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java index d898a027d..224dd0a1c 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java @@ -691,7 +691,7 @@ public abstract class PlotArea { public boolean addPlot(Plot plot) { for (PlotPlayer pp : plot.getPlayersInPlot()) { - pp.setMeta("lastplot", plot); + pp.setMeta(PlotPlayer.META_LAST_PLOT, plot); } return this.plots.put(plot.getId(), plot) == null; } @@ -730,7 +730,7 @@ public abstract class PlotArea { public boolean addPlotIfAbsent(Plot plot) { if (this.plots.putIfAbsent(plot.getId(), plot) == null) { for (PlotPlayer pp : plot.getPlayersInPlot()) { - pp.setMeta("lastplot", plot); + pp.setMeta(PlotPlayer.META_LAST_PLOT, plot); } return true; } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotCluster.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotCluster.java index 12566b1b6..a1134cbce 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotCluster.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotCluster.java @@ -69,13 +69,13 @@ public class PlotCluster { public boolean isAdded(UUID uuid) { return this.owner.equals(uuid) || this.invited.contains(uuid) || this.invited - .contains(DBFunc.everyone) || this.helpers.contains(uuid) || this.helpers - .contains(DBFunc.everyone); + .contains(DBFunc.EVERYONE) || this.helpers.contains(uuid) || this.helpers + .contains(DBFunc.EVERYONE); } public boolean hasHelperRights(UUID uuid) { return this.owner.equals(uuid) || this.helpers.contains(uuid) || this.helpers - .contains(DBFunc.everyone); + .contains(DBFunc.EVERYONE); } public String getName() { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java index a6f17f2e0..51d5f7885 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java @@ -22,6 +22,10 @@ import java.util.concurrent.atomic.AtomicInteger; * The abstract class supporting {@code BukkitPlayer} and {@code SpongePlayer}. */ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer { + + public static final String META_LAST_PLOT = "lastplot"; + public static final String META_LOCATION = "location"; + private Map metaMap = new HashMap<>(); /** @@ -119,7 +123,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer { * @return the plot the player is standing on or null if standing on a road or not in a {@link PlotArea} */ public Plot getCurrentPlot() { - Plot value = getMeta("lastplot"); + Plot value = getMeta(PlotPlayer.META_LAST_PLOT); if (value == null && !Settings.Enabled_Components.EVENTS) { return getLocation().getPlot(); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java index c71f0e03a..eaa9629d3 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java @@ -329,7 +329,7 @@ public class MainUtil { if (owner == null) { return C.NONE.s(); } - if (owner.equals(DBFunc.everyone)) { + if (owner.equals(DBFunc.EVERYONE)) { return C.EVERYONE.s(); } String name = UUIDHandler.getName(owner); @@ -686,7 +686,7 @@ public class MainUtil { return Collections.emptySet(); } if ("*".equals(name)) { - result.add(DBFunc.everyone); + result.add(DBFunc.EVERYONE); continue; } if (name.length() > 16) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/expiry/ExpireManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/expiry/ExpireManager.java index e62727158..b15877936 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/expiry/ExpireManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/expiry/ExpireManager.java @@ -429,7 +429,7 @@ public class ExpireManager { } public long getAccountAge(Plot plot) { - if (!plot.hasOwner() || Objects.equals(DBFunc.everyone, plot.owner) + if (!plot.hasOwner() || Objects.equals(DBFunc.EVERYONE, plot.owner) || UUIDHandler.getPlayer(plot.owner) != null || plot.getRunning() > 0) { return Long.MAX_VALUE; } @@ -442,7 +442,7 @@ public class ExpireManager { } public long getAge(Plot plot) { - if (!plot.hasOwner() || Objects.equals(DBFunc.everyone, plot.owner) + if (!plot.hasOwner() || Objects.equals(DBFunc.EVERYONE, plot.owner) || UUIDHandler.getPlayer(plot.owner) != null || plot.getRunning() > 0) { return 0; } diff --git a/Nukkit/src/main/java/com/github/intellectualsites/plotsquared/nukkit/listeners/PlayerEvents.java b/Nukkit/src/main/java/com/github/intellectualsites/plotsquared/nukkit/listeners/PlayerEvents.java index 6d1e0d912..6e63c4916 100644 --- a/Nukkit/src/main/java/com/github/intellectualsites/plotsquared/nukkit/listeners/PlayerEvents.java +++ b/Nukkit/src/main/java/com/github/intellectualsites/plotsquared/nukkit/listeners/PlayerEvents.java @@ -372,8 +372,8 @@ public class PlayerEvents extends PlotListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onTeleport(PlayerTeleportEvent event) { if (event.getTo() == null || event.getFrom() == null) { - NukkitUtil.getPlayer(event.getPlayer()).deleteMeta("location"); - NukkitUtil.getPlayer(event.getPlayer()).deleteMeta("lastplot"); + NukkitUtil.getPlayer(event.getPlayer()).deleteMeta(PlotPlayer.META_LOCATION); + NukkitUtil.getPlayer(event.getPlayer()).deleteMeta(PlotPlayer.META_LAST_PLOT); return; } cn.nukkit.level.Location from = event.getFrom(); @@ -386,14 +386,14 @@ public class PlayerEvents extends PlotListener implements Listener { TaskManager.TELEPORT_QUEUE.remove(pp.getName()); // Set last location Location loc = NukkitUtil.getLocation(to); - pp.setMeta("location", loc); + pp.setMeta(PlotPlayer.META_LOCATION, loc); PlotArea area = loc.getPlotArea(); if (area == null) { - pp.deleteMeta("lastplot"); + pp.deleteMeta(PlotPlayer.META_LAST_PLOT); return; } Plot now = area.getPlot(loc); - Plot lastPlot = pp.getMeta("lastplot"); + Plot lastPlot = pp.getMeta(PlotPlayer.META_LAST_PLOT); if (now == null) { if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport) { MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED); @@ -447,11 +447,11 @@ public class PlayerEvents extends PlotListener implements Listener { pp.setMeta("location", loc); PlotArea area = loc.getPlotArea(); if (area == null) { - pp.deleteMeta("lastplot"); + pp.deleteMeta(PlotPlayer.META_LAST_PLOT); return; } Plot now = area.getPlot(loc); - Plot lastPlot = pp.getMeta("lastplot"); + Plot lastPlot = pp.getMeta(PlotPlayer.META_LAST_PLOT); if (now == null) { if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport) { MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED); @@ -505,14 +505,14 @@ public class PlayerEvents extends PlotListener implements Listener { TaskManager.TELEPORT_QUEUE.remove(pp.getName()); // Set last location Location loc = NukkitUtil.getLocation(to); - pp.setMeta("location", loc); + pp.setMeta(PlotPlayer.META_LOCATION, loc); PlotArea area = loc.getPlotArea(); if (area == null) { - pp.deleteMeta("lastplot"); + pp.deleteMeta(PlotPlayer.META_LAST_PLOT); return; } Plot now = area.getPlot(loc); - Plot lastPlot = pp.getMeta("lastplot"); + Plot lastPlot = pp.getMeta(PlotPlayer.META_LAST_PLOT); if (now == null) { if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport) { MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED); @@ -563,14 +563,14 @@ public class PlayerEvents extends PlotListener implements Listener { TaskManager.TELEPORT_QUEUE.remove(pp.getName()); // Set last location Location loc = NukkitUtil.getLocation(to); - pp.setMeta("location", loc); + pp.setMeta(PlotPlayer.META_LOCATION, loc); PlotArea area = loc.getPlotArea(); if (area == null) { - pp.deleteMeta("lastplot"); + pp.deleteMeta(PlotPlayer.META_LAST_PLOT); return; } Plot now = area.getPlot(loc); - Plot lastPlot = pp.getMeta("lastplot"); + Plot lastPlot = pp.getMeta(PlotPlayer.META_LAST_PLOT); if (now == null) { if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport) { MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED); diff --git a/Sponge/src/main/java/com/github/intellectualsites/plotsquared/sponge/listener/MainListener.java b/Sponge/src/main/java/com/github/intellectualsites/plotsquared/sponge/listener/MainListener.java index 822001959..01dcfcd16 100644 --- a/Sponge/src/main/java/com/github/intellectualsites/plotsquared/sponge/listener/MainListener.java +++ b/Sponge/src/main/java/com/github/intellectualsites/plotsquared/sponge/listener/MainListener.java @@ -668,11 +668,11 @@ import java.util.function.Predicate; pp.setMeta("location", loc); PlotArea area = loc.getPlotArea(); if (area == null) { - pp.deleteMeta("lastplot"); + pp.deleteMeta(PlotPlayer.META_LAST_PLOT); return; } Plot now = area.getPlotAbs(loc); - Plot lastPlot = pp.getMeta("lastplot"); + Plot lastPlot = pp.getMeta(PlotPlayer.META_LAST_PLOT); if (now == null) { if (lastPlot != null && !PlotListener.plotExit(pp, lastPlot)) { MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED); @@ -715,14 +715,14 @@ import java.util.function.Predicate; TaskManager.TELEPORT_QUEUE.remove(pp.getName()); // Set last location Location loc = SpongeUtil.getLocation(to); - pp.setMeta("location", loc); + pp.setMeta(PlotPlayer.META_LOCATION, loc); PlotArea area = loc.getPlotArea(); if (area == null) { - pp.deleteMeta("lastplot"); + pp.deleteMeta(PlotPlayer.META_LAST_PLOT); return; } Plot now = area.getPlotAbs(loc); - Plot lastPlot = pp.getMeta("lastplot"); + Plot lastPlot = pp.getMeta(PlotPlayer.META_LAST_PLOT); if (now == null) { if (lastPlot != null && !PlotListener.plotExit(pp, lastPlot)) { MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);