From 265c10ec1c4ad1d3be5f72c7a0cf5be138de8d8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Wed, 8 Jul 2020 13:40:55 +0200 Subject: [PATCH 01/21] Remove `commands.yml` --- .../com/plotsquared/core/PlotSquared.java | 19 ---------- .../com/plotsquared/core/command/Command.java | 35 ++++--------------- 2 files changed, 6 insertions(+), 48 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/PlotSquared.java b/Core/src/main/java/com/plotsquared/core/PlotSquared.java index 30d738afc..0ebcc7b1c 100644 --- a/Core/src/main/java/com/plotsquared/core/PlotSquared.java +++ b/Core/src/main/java/com/plotsquared/core/PlotSquared.java @@ -154,12 +154,10 @@ public class PlotSquared { public File styleFile; public File configFile; public File worldsFile; - public File commandsFile; public File translationFile; public YamlConfiguration style; public YamlConfiguration worlds; public YamlConfiguration storage; - public YamlConfiguration commands; // Temporary hold the plots/clusters before the worlds load public HashMap> clusters_tmp; public HashMap> plots_tmp; @@ -1796,23 +1794,6 @@ public class PlotSquared { } catch (IOException ignored) { PlotSquared.log("Failed to save storage.yml"); } - try { - this.commandsFile = new File(folder, "commands.yml"); - if (!this.commandsFile.exists() && !this.commandsFile.createNewFile()) { - PlotSquared.log( - "Could not the storage settings file, please create \"commands.yml\" manually."); - } - this.commands = YamlConfiguration.loadConfiguration(this.commandsFile); - } catch (IOException ignored) { - PlotSquared.log("Failed to save commands.yml"); - } - try { - this.style.save(this.styleFile); - this.commands.save(this.commandsFile); - } catch (IOException e) { - PlotSquared.log("Configuration file saving failed"); - e.printStackTrace(); - } return true; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Command.java b/Core/src/main/java/com/plotsquared/core/command/Command.java index 7238d4566..194fc48a4 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Command.java +++ b/Core/src/main/java/com/plotsquared/core/command/Command.java @@ -25,9 +25,7 @@ */ package com.plotsquared.core.command; -import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.Captions; -import com.plotsquared.core.configuration.file.YamlConfiguration; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.message.PlotMessage; import com.plotsquared.core.util.MainUtil; @@ -40,7 +38,6 @@ import com.plotsquared.core.util.task.RunnableVal3; import lombok.SneakyThrows; import org.jetbrains.annotations.NotNull; -import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; @@ -190,36 +187,16 @@ public abstract class Command { this.permission = declaration.permission(); this.required = declaration.requiredType(); this.category = declaration.category(); + List aliasOptions = new ArrayList<>(); aliasOptions.add(this.id); aliasOptions.addAll(Arrays.asList(declaration.aliases())); - HashMap options = new HashMap<>(); - options.put("aliases", aliasOptions); - options.put("description", declaration.description()); - options.put("usage", declaration.usage()); - options.put("confirmation", declaration.confirmation()); - boolean set = false; - YamlConfiguration commands = - PlotSquared.get() == null ? new YamlConfiguration() : PlotSquared.get().commands; - for (Map.Entry entry : options.entrySet()) { - String key = this.getFullId() + "." + entry.getKey(); - if (!commands.contains(key)) { - commands.set(key, entry.getValue()); - set = true; - } - } - if (set && PlotSquared.get() != null) { - try { - commands.save(PlotSquared.get().commandsFile); - } catch (IOException e) { - e.printStackTrace(); - } - } - this.aliases = commands.getStringList(this.getFullId() + ".aliases"); - this.description = commands.getString(this.getFullId() + ".description"); - this.usage = commands.getString(this.getFullId() + ".usage"); - this.confirmation = commands.getBoolean(this.getFullId() + ".confirmation"); + this.aliases = aliasOptions; + this.description = declaration.description(); + this.usage = declaration.usage(); + this.confirmation = declaration.confirmation(); + if (this.parent != null) { this.parent.register(this); } From f2191cb731af85efcc26998038cc888e717a62b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Wed, 8 Jul 2020 13:43:16 +0200 Subject: [PATCH 02/21] Save style.yml again --- Core/src/main/java/com/plotsquared/core/PlotSquared.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Core/src/main/java/com/plotsquared/core/PlotSquared.java b/Core/src/main/java/com/plotsquared/core/PlotSquared.java index 0ebcc7b1c..8df57ba4c 100644 --- a/Core/src/main/java/com/plotsquared/core/PlotSquared.java +++ b/Core/src/main/java/com/plotsquared/core/PlotSquared.java @@ -1779,6 +1779,7 @@ public class PlotSquared { } this.style = YamlConfiguration.loadConfiguration(this.styleFile); setupStyle(); + this.style.save(this.styleFile); } catch (IOException err) { err.printStackTrace(); PlotSquared.log("Failed to save style.yml"); From d267d1bb98f9981d236e764f44bad0183d57131d Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Wed, 8 Jul 2020 14:35:46 +0100 Subject: [PATCH 03/21] Start expiry tasks --- Core/src/main/java/com/plotsquared/core/PlotSquared.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Core/src/main/java/com/plotsquared/core/PlotSquared.java b/Core/src/main/java/com/plotsquared/core/PlotSquared.java index 8df57ba4c..e9048f726 100644 --- a/Core/src/main/java/com/plotsquared/core/PlotSquared.java +++ b/Core/src/main/java/com/plotsquared/core/PlotSquared.java @@ -259,6 +259,7 @@ public class PlotSquared { if (Settings.Enabled_Components.CHUNK_PROCESSOR) { this.IMP.registerChunkProcessor(); } + startExpiryTasks(); // Create Event utility class eventDispatcher = new EventDispatcher(); // create Hybrid utility class From 2936b806f3d48b2e1b1c9f6b78a33aeb3b163e73 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Wed, 8 Jul 2020 17:10:09 +0100 Subject: [PATCH 04/21] Allow players to interact on their own plot --- .../com/plotsquared/bukkit/listener/PlayerEvents.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java index 841470413..ed812d09f 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java @@ -1864,8 +1864,8 @@ public class PlayerEvents extends PlotListener implements Listener { Plot plot = location.getPlotAbs(); BukkitPlayer pp = BukkitUtil.getPlayer(e.getPlayer()); if (plot == null) { - if (!area.isRoadFlags() && !area.getRoadFlag(MiscInteractFlag.class) - && !Permissions.hasPermission(pp, "plots.admin.interact.road")) { + if (!area.isRoadFlags() && !area.getRoadFlag(MiscInteractFlag.class) && !Permissions + .hasPermission(pp, "plots.admin.interact.road")) { MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, "plots.admin.interact.road"); e.setCancelled(true); } @@ -2601,8 +2601,8 @@ public class PlayerEvents extends PlotListener implements Listener { Captions.PERMISSION_ADMIN_INTERACT_UNOWNED); event.setCancelled(true); } - } else if ((plot != null && !plot.isAdded(pp.getUUID())) || area - .isRoadFlags()) { + } else if ((plot != null && !plot.isAdded(pp.getUUID())) || (plot == null && area + .isRoadFlags())) { final Entity entity = event.getRightClicked(); final com.sk89q.worldedit.world.entity.EntityType entityType = BukkitAdapter.adapt(entity.getType()); From d652225f36063b661e215a5ad9fbdb34f4451edb Mon Sep 17 00:00:00 2001 From: Hannes Greule Date: Wed, 8 Jul 2020 19:33:58 +0200 Subject: [PATCH 05/21] Let players teleport to their merged plots --- .../java/com/plotsquared/core/command/HomeCommand.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java b/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java index b72276026..38942ad11 100644 --- a/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java @@ -84,7 +84,7 @@ public class HomeCommand extends Command { @NotNull private PlotQuery query(@NotNull final PlotPlayer player) { // everything plots need to have in common here - return PlotQuery.newQuery().ownedBy(player).whereBasePlot(); + return PlotQuery.newQuery().ownedBy(player); } @Override public CompletableFuture execute(PlotPlayer player, String[] args, @@ -107,6 +107,7 @@ public class HomeCommand extends Command { PlotQuery query = query(player); int page = 1; // page = index + 1 String identifier; + boolean basePlotOnly = true; switch (args.length) { case 1: identifier = args[0]; @@ -124,6 +125,7 @@ public class HomeCommand extends Command { Plot fromId = MainUtil.getPlotFromString(player, identifier, false); if (fromId != null && fromId.isOwner(player.getUUID())) { // it was a valid plot id + basePlotOnly = false; query.withPlot(fromId); break; } @@ -165,12 +167,16 @@ public class HomeCommand extends Command { break; } // as the query already filters by owner, this is fine + basePlotOnly = false; query.withPlot(plot); break; case 0: query.withSortingStrategy(SortingStrategy.SORT_BY_CREATION); break; } + if (basePlotOnly) { + query.whereBasePlot(); + } home(player, query, page, confirm, whenDone); return CompletableFuture.completedFuture(true); } From 1310f9470ed8ca53e5cb146b05b75049dd56de60 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Wed, 8 Jul 2020 19:34:08 +0100 Subject: [PATCH 06/21] 5.12.4 --- Bukkit/pom.xml | 2 +- build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Bukkit/pom.xml b/Bukkit/pom.xml index 13e2e6fcf..f70fa0eba 100644 --- a/Bukkit/pom.xml +++ b/Bukkit/pom.xml @@ -21,7 +21,7 @@ com.plotsquared PlotSquared-Core - 5.12.3 + 5.12.4 compile diff --git a/build.gradle b/build.gradle index a841bb030..fff3ba5eb 100644 --- a/build.gradle +++ b/build.gradle @@ -30,7 +30,7 @@ ext { git = Grgit.open(dir: new File(rootDir.toString() + "/.git")) } -def ver = "5.12.3" +def ver = "5.12.4" def versuffix = "" ext { if (project.hasProperty("versionsuffix")) { From 61de18190f084402a37fc67d8ca85c2ee86aec52 Mon Sep 17 00:00:00 2001 From: Traks Date: Thu, 9 Jul 2020 02:11:51 +0200 Subject: [PATCH 07/21] More dispense blocking on roads --- .../bukkit/listener/PlayerEvents.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java index ed812d09f..d81f24fa6 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java @@ -1618,6 +1618,35 @@ public class PlayerEvents extends PlotListener implements Listener { public void onBlockDispense(BlockDispenseEvent event) { Material type = event.getItem().getType(); switch (type) { + case SHULKER_BOX: + case WHITE_SHULKER_BOX: + case ORANGE_SHULKER_BOX: + case MAGENTA_SHULKER_BOX: + case LIGHT_BLUE_SHULKER_BOX: + case YELLOW_SHULKER_BOX: + case LIME_SHULKER_BOX: + case PINK_SHULKER_BOX: + case GRAY_SHULKER_BOX: + case LIGHT_GRAY_SHULKER_BOX: + case CYAN_SHULKER_BOX: + case PURPLE_SHULKER_BOX: + case BLUE_SHULKER_BOX: + case BROWN_SHULKER_BOX: + case GREEN_SHULKER_BOX: + case RED_SHULKER_BOX: + case BLACK_SHULKER_BOX: + case CARVED_PUMPKIN: + case WITHER_SKELETON_SKULL: + case FLINT_AND_STEEL: + case BONE_MEAL: + case SHEARS: + case GLASS_BOTTLE: + case GLOWSTONE: + case COD_BUCKET: + case PUFFERFISH_BUCKET: + case SALMON_BUCKET: + case TROPICAL_FISH_BUCKET: + case BUCKET: case WATER_BUCKET: case LAVA_BUCKET: { if (event.getBlock().getType() == Material.DROPPER) { From e05d81748229f71d4d6a0958cbf9487da482ca91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Thu, 9 Jul 2020 16:38:46 +0200 Subject: [PATCH 08/21] Fix plot owner placeholder. Fixes PS-62. --- .../bukkit/placeholder/Placeholders.java | 22 +++++---------- .../com/plotsquared/core/util/MainUtil.java | 27 ++++++++++++++++--- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/placeholder/Placeholders.java b/Bukkit/src/main/java/com/plotsquared/bukkit/placeholder/Placeholders.java index 5457dbe0f..c61b29f37 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/placeholder/Placeholders.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/placeholder/Placeholders.java @@ -26,17 +26,16 @@ package com.plotsquared.bukkit.placeholder; import com.plotsquared.core.PlotSquared; -import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.flag.GlobalFlagContainer; import com.plotsquared.core.plot.flag.PlotFlag; +import com.plotsquared.core.util.MainUtil; import me.clip.placeholderapi.PlaceholderAPIPlugin; import me.clip.placeholderapi.expansion.PlaceholderExpansion; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import java.util.Set; import java.util.UUID; public class Placeholders extends PlaceholderExpansion { @@ -117,23 +116,16 @@ public class Placeholders extends PlaceholderExpansion { return plot.getAlias(); } case "currentplot_owner": { - final Set o = plot.getOwners(); - if (o == null || o.isEmpty()) { - return ""; - } - final UUID uid = (UUID) o.toArray()[0]; - if (uid == null) { + final UUID plotOwner = plot.getOwnerAbs(); + if (plotOwner == null) { return ""; } - String name = PlotSquared.get().getImpromptuUUIDPipeline() - .getSingle(uid, Settings.UUID.BLOCKING_TIMEOUT); + try { + return MainUtil.getName(plotOwner, false); + } catch (final Exception ignored) {} - if (name != null) { - return name; - } - - name = Bukkit.getOfflinePlayer(uid).getName(); + final String name = Bukkit.getOfflinePlayer(plotOwner).getName(); return name != null ? name : "unknown"; } case "currentplot_members": { diff --git a/Core/src/main/java/com/plotsquared/core/util/MainUtil.java b/Core/src/main/java/com/plotsquared/core/util/MainUtil.java index 9e2a78853..9f79f3273 100644 --- a/Core/src/main/java/com/plotsquared/core/util/MainUtil.java +++ b/Core/src/main/java/com/plotsquared/core/util/MainUtil.java @@ -372,10 +372,21 @@ public class MainUtil { /** * Get the name from a UUID. * - * @param owner + * @param owner Owner UUID * @return The player's name, None, Everyone or Unknown */ - @NotNull public static String getName(UUID owner) { + @NotNull public static String getName(@Nullable UUID owner) { + return getName(owner, true); + } + + /** + * Get the name from a UUID. + * + * @param owner Owner UUID + * @param blocking Whether or not the operation can be blocking + * @return The player's name, None, Everyone or Unknown + */ + @NotNull public static String getName(@Nullable final UUID owner, final boolean blocking) { if (owner == null) { return Captions.NONE.getTranslated(); } @@ -385,7 +396,17 @@ public class MainUtil { if (owner.equals(DBFunc.SERVER)) { return Captions.SERVER.getTranslated(); } - String name = PlotSquared.get().getImpromptuUUIDPipeline().getSingle(owner, Settings.UUID.BLOCKING_TIMEOUT); + final String name; + if (blocking) { + name = PlotSquared.get().getImpromptuUUIDPipeline().getSingle(owner, Settings.UUID.BLOCKING_TIMEOUT); + } else { + final UUIDMapping uuidMapping = PlotSquared.get().getImpromptuUUIDPipeline().getImmediately(owner); + if (uuidMapping != null) { + name = uuidMapping.getUsername(); + } else { + name = null; + } + } if (name == null) { return Captions.UNKNOWN.getTranslated(); } From 6b07f38cff49aae77fdcab615eb43b6faff5fb46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Thu, 9 Jul 2020 16:45:25 +0200 Subject: [PATCH 09/21] Send teleportation cancellation message immediately on movement, rather than after the timer has finished. This fixes PS-33. --- .../com/plotsquared/bukkit/listener/PlayerEvents.java | 8 ++++++-- Core/src/main/java/com/plotsquared/core/plot/Plot.java | 4 +--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java index d81f24fa6..8cd72da47 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java @@ -822,7 +822,9 @@ public class PlayerEvents extends PlotListener implements Listener { Player player = event.getPlayer(); BukkitPlayer pp = BukkitUtil.getPlayer(player); // Cancel teleport - TaskManager.TELEPORT_QUEUE.remove(pp.getName()); + if (TaskManager.TELEPORT_QUEUE.remove(pp.getName())) { + MainUtil.sendMessage(pp, Captions.TELEPORT_FAILED); + } // Set last location Location location = BukkitUtil.getLocation(to); pp.setMeta(PlotPlayer.META_LOCATION, location); @@ -882,7 +884,9 @@ public class PlayerEvents extends PlotListener implements Listener { Player player = event.getPlayer(); BukkitPlayer pp = BukkitUtil.getPlayer(player); // Cancel teleport - TaskManager.TELEPORT_QUEUE.remove(pp.getName()); + if (TaskManager.TELEPORT_QUEUE.remove(pp.getName())) { + MainUtil.sendMessage(pp, Captions.TELEPORT_FAILED); + } // Set last location Location location = BukkitUtil.getLocation(to); pp.setMeta(PlotPlayer.META_LOCATION, location); diff --git a/Core/src/main/java/com/plotsquared/core/plot/Plot.java b/Core/src/main/java/com/plotsquared/core/plot/Plot.java index 46ce9f24c..2adca5334 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/Plot.java +++ b/Core/src/main/java/com/plotsquared/core/plot/Plot.java @@ -3010,11 +3010,9 @@ public class Plot { final String name = player.getName(); TaskManager.TELEPORT_QUEUE.add(name); TaskManager.runTaskLater(() -> { - if (!TaskManager.TELEPORT_QUEUE.contains(name)) { - MainUtil.sendMessage(player, Captions.TELEPORT_FAILED); + if (!TaskManager.TELEPORT_QUEUE.remove(name)) { return; } - TaskManager.TELEPORT_QUEUE.remove(name); if (player.isOnline()) { MainUtil.sendMessage(player, Captions.TELEPORTED_TO_PLOT); player.teleport(location, cause); From 699eb71e2a5bd4e99dbeba48a22a026698188895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Thu, 9 Jul 2020 19:46:17 +0200 Subject: [PATCH 10/21] Fix kill-road-mobs. Fixes PS-73 --- Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java | 1 - 1 file changed, 1 deletion(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java index 39a763d24..39b2a3c9d 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -833,7 +833,6 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain< case "HOGLIN": case "PIGLIN": case "ZOGLIN": - break; default: { if (Settings.Enabled_Components.KILL_ROAD_MOBS) { Location location = entity.getLocation(); From 89cb6450fb310c67f04e18562bfec98e39055acd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Thu, 9 Jul 2020 20:04:00 +0200 Subject: [PATCH 11/21] Fix issue where PlotPlayer#getLocation returns a mutable location --- .../java/com/plotsquared/core/location/Location.java | 11 +++++++++++ .../java/com/plotsquared/core/player/PlotPlayer.java | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Core/src/main/java/com/plotsquared/core/location/Location.java b/Core/src/main/java/com/plotsquared/core/location/Location.java index 0505137b1..fa9175892 100644 --- a/Core/src/main/java/com/plotsquared/core/location/Location.java +++ b/Core/src/main/java/com/plotsquared/core/location/Location.java @@ -34,6 +34,7 @@ import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import lombok.Getter; import lombok.Setter; +import org.jetbrains.annotations.NotNull; import org.khelekore.prtree.MBR; import org.khelekore.prtree.SimpleMBR; @@ -103,6 +104,16 @@ public class Location implements Cloneable, Comparable { } } + /** + * Return a copy of the location. This will pass {@link #equals(Object)} + * but will have a different identity. + * + * @return Copy of the location + */ + @NotNull public Location copy() { + return new Location(this.world, this.x, this.y, this.z, this.yaw, this.pitch); + } + public PlotArea getPlotArea() { return PlotSquared.get().getPlotAreaAbs(this); } diff --git a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java index 13efa6bfb..b11a33ba6 100644 --- a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java +++ b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java @@ -367,7 +367,7 @@ public abstract class PlotPlayer

implements CommandCaller, OfflinePlotPlayer @NotNull public Location getLocation() { Location location = getMeta("location"); if (location != null) { - return location; + return location.copy(); // Always return a copy of the location } return getLocationFull(); } From 4576cfd961667a7695ed2dd02f6baec07ebb8eb2 Mon Sep 17 00:00:00 2001 From: Traks Date: Thu, 9 Jul 2020 15:43:16 +0200 Subject: [PATCH 12/21] Improve piston interaction with plot border Fixes retracting pistons being able to modify plot borders. Prevents piston heads from sticking outside plots. --- .../bukkit/listener/PlayerEvents.java | 74 ++++++------------- 1 file changed, 21 insertions(+), 53 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java index 8cd72da47..3949e0245 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java @@ -230,7 +230,6 @@ public class PlayerEvents extends PlotListener implements Listener { public static final com.sk89q.worldedit.world.entity.EntityType FAKE_ENTITY_TYPE = new com.sk89q.worldedit.world.entity.EntityType("plotsquared:fake"); - private boolean pistonBlocks = true; private float lastRadius; // To prevent recursion private boolean tmpTeleport = true; @@ -1539,35 +1538,28 @@ public class PlayerEvents extends PlotListener implements Listener { return; } } + if (!plot.equals(area.getOwnedPlot(location.add( + relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())))) { + // This branch is only necessary to prevent pistons from extending + // if they are: on a plot edge, facing outside the plot, and not + // pushing any blocks + event.setCancelled(true); + } } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBlockPistonRetract(BlockPistonRetractEvent event) { Block block = event.getBlock(); Location location = BukkitUtil.getLocation(block.getLocation()); + BlockFace face = event.getDirection(); + Vector relative = new Vector(face.getModX(), face.getModY(), face.getModZ()); PlotArea area = location.getPlotArea(); if (area == null) { if (!PlotSquared.get().hasPlotArea(location.getWorld())) { return; } - if (this.pistonBlocks) { - try { - for (Block pulled : event.getBlocks()) { - location = BukkitUtil.getLocation(pulled.getLocation()); - if (location.isPlotArea()) { - event.setCancelled(true); - return; - } - } - } catch (Throwable ignored) { - this.pistonBlocks = false; - } - } - if (!this.pistonBlocks && !block.getType().toString().contains("PISTON")) { - BlockFace dir = event.getDirection(); - location = BukkitUtil.getLocation(block.getLocation() - .add(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2)); - if (location.isPlotArea()) { + for (Block block1 : event.getBlocks()) { + if (BukkitUtil.getLocation(block1.getLocation().add(relative)).isPlotArea()) { event.setCancelled(true); return; } @@ -1575,45 +1567,21 @@ public class PlayerEvents extends PlotListener implements Listener { return; } Plot plot = area.getOwnedPlot(location); - BlockFace dir = event.getDirection(); - // Location head = location.add(-dir.getModX(), -dir.getModY(), -dir.getModZ()); - // - // if (!Objects.equals(plot, area.getOwnedPlot(head))) { - // // FIXME: cancelling the event doesn't work here. See issue #1484 - // event.setCancelled(true); - // return; - // } - if (this.pistonBlocks) { - try { - for (Block pulled : event.getBlocks()) { - Location from = BukkitUtil.getLocation( - pulled.getLocation().add(dir.getModX(), dir.getModY(), dir.getModZ())); - Location to = BukkitUtil.getLocation(pulled.getLocation()); - if (!area.contains(to.getX(), to.getZ())) { - event.setCancelled(true); - return; - } - Plot fromPlot = area.getOwnedPlot(from); - Plot toPlot = area.getOwnedPlot(to); - if (!Objects.equals(fromPlot, toPlot)) { - event.setCancelled(true); - return; - } - } - } catch (Throwable ignored) { - this.pistonBlocks = false; - } + if (plot == null) { + event.setCancelled(true); + return; } - if (!this.pistonBlocks && !block.getType().toString().contains("PISTON")) { - location = BukkitUtil.getLocation( - block.getLocation().add(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2)); - if (!area.contains(location)) { + for (Block block1 : event.getBlocks()) { + Location bloc = BukkitUtil.getLocation(block1.getLocation()); + if (!area.contains(bloc.getX(), bloc.getZ()) || !area + .contains(bloc.getX() + relative.getBlockX(), bloc.getZ() + relative.getBlockZ())) { event.setCancelled(true); return; } - Plot newPlot = area.getOwnedPlot(location); - if (!Objects.equals(plot, newPlot)) { + if (!plot.equals(area.getOwnedPlot(bloc)) || !plot.equals(area.getOwnedPlot( + bloc.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())))) { event.setCancelled(true); + return; } } } From cfd389883b3ae8d2ec07b67112a1306204cf2f4b Mon Sep 17 00:00:00 2001 From: Traks Date: Thu, 9 Jul 2020 18:30:45 +0200 Subject: [PATCH 13/21] Improve piston interaction with area border --- .../plotsquared/bukkit/listener/PlayerEvents.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java index 3949e0245..28fc05d4a 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java @@ -1513,11 +1513,19 @@ public class PlayerEvents extends PlotListener implements Listener { return; } for (Block block1 : event.getBlocks()) { - if (BukkitUtil.getLocation(block1.getLocation().add(relative)).isPlotArea()) { + Location bloc = BukkitUtil.getLocation(block1.getLocation()); + if (bloc.isPlotArea() || bloc.add(relative.getBlockX(), + relative.getBlockY(), relative.getBlockZ()).isPlotArea()) { event.setCancelled(true); return; } } + if (location.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ()) + .isPlotArea()) { + // Prevent pistons from extending if they are: bordering a plot + // area, facing inside plot area, and not pushing any blocks + event.setCancelled(true); + } return; } Plot plot = area.getOwnedPlot(location); @@ -1559,7 +1567,9 @@ public class PlayerEvents extends PlotListener implements Listener { return; } for (Block block1 : event.getBlocks()) { - if (BukkitUtil.getLocation(block1.getLocation().add(relative)).isPlotArea()) { + Location bloc = BukkitUtil.getLocation(block1.getLocation()); + if (bloc.isPlotArea() || bloc.add(relative.getBlockX(), + relative.getBlockY(), relative.getBlockZ()).isPlotArea()) { event.setCancelled(true); return; } From 63c308971b530712636e9a0bb44979250fc85b80 Mon Sep 17 00:00:00 2001 From: Traks Date: Thu, 9 Jul 2020 18:31:44 +0200 Subject: [PATCH 14/21] Update location block vector on add and subtract --- Core/src/main/java/com/plotsquared/core/location/Location.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Core/src/main/java/com/plotsquared/core/location/Location.java b/Core/src/main/java/com/plotsquared/core/location/Location.java index fa9175892..08db98a19 100644 --- a/Core/src/main/java/com/plotsquared/core/location/Location.java +++ b/Core/src/main/java/com/plotsquared/core/location/Location.java @@ -190,6 +190,7 @@ public class Location implements Cloneable, Comparable { this.x += x; this.y += y; this.z += z; + this.blockVector3 = BlockVector3.at(this.x, this.y, this.z); return this; } @@ -231,6 +232,7 @@ public class Location implements Cloneable, Comparable { this.x -= x; this.y -= y; this.z -= z; + this.blockVector3 = BlockVector3.at(this.x, this.y, this.z); return this; } From b36c6427d1e32d0382d01326114b8d1e9bdf3f44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Thu, 9 Jul 2020 20:25:16 +0200 Subject: [PATCH 15/21] Split failed UUID batches into individual requests in order to identify the invalid UUIDs --- .../bukkit/uuid/SquirrelIdUUIDService.java | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SquirrelIdUUIDService.java b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SquirrelIdUUIDService.java index 4580519aa..8c8dfca83 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SquirrelIdUUIDService.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SquirrelIdUUIDService.java @@ -26,6 +26,8 @@ package com.plotsquared.bukkit.uuid; import com.google.common.util.concurrent.RateLimiter; +import com.plotsquared.core.PlotSquared; +import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.uuid.UUIDMapping; import com.plotsquared.core.uuid.UUIDService; import com.sk89q.squirrelid.Profile; @@ -35,6 +37,7 @@ import org.jetbrains.annotations.NotNull; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.UUID; @@ -65,8 +68,27 @@ public class SquirrelIdUUIDService implements UUIDService { final List results = new ArrayList<>(uuids.size()); this.rateLimiter.acquire(uuids.size()); try { - for (final Profile profile : this.profileService.findAllById(uuids)) { - results.add(new UUIDMapping(profile.getUniqueId(), profile.getName())); + try { + for (final Profile profile : this.profileService.findAllById(uuids)) { + results.add(new UUIDMapping(profile.getUniqueId(), profile.getName())); + } + } catch (final IllegalArgumentException illegalArgumentException) { + // + // This means that the UUID was invalid for whatever reason, we'll try to + // go through them one by one + // + if (uuids.size() >= 2) { + PlotSquared.debug(Captions.PREFIX + "(UUID) Found invalid UUID in batch. Will try each UUID individually."); + for (final UUID uuid : uuids) { + final List result = this.getNames(Collections.singletonList(uuid)); + if (result.isEmpty()) { + continue; + } + results.add(result.get(0)); + } + } else if (uuids.size() == 1) { + PlotSquared.debug(Captions.PREFIX + "(UUID) Found invalid UUID: " + uuids.get(0)); + } } } catch (IOException | InterruptedException e) { e.printStackTrace(); From fb050ac3da808273597d5ed1c5516d93e67afd18 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Thu, 9 Jul 2020 21:15:28 +0200 Subject: [PATCH 16/21] 5.12.5 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index fff3ba5eb..a0bae9c0c 100644 --- a/build.gradle +++ b/build.gradle @@ -30,7 +30,7 @@ ext { git = Grgit.open(dir: new File(rootDir.toString() + "/.git")) } -def ver = "5.12.4" +def ver = "5.12.5" def versuffix = "" ext { if (project.hasProperty("versionsuffix")) { From 96740fd2820234e7f5c875fe273d511ce9a7b14f Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 9 Jul 2020 21:52:51 +0100 Subject: [PATCH 17/21] Couple of fixes to road flag logic --- .../java/com/plotsquared/bukkit/listener/PlayerEvents.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java index ed812d09f..b088239ef 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java @@ -1878,8 +1878,7 @@ public class PlayerEvents extends PlotListener implements Listener { return; } } - if (!plot.hasOwner() && !area.isRoadFlags() && !area - .getRoadFlag(MiscInteractFlag.class)) { + if (!plot.hasOwner()) { if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) { MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, "plots.admin.interact.unowned"); @@ -3145,7 +3144,7 @@ public class PlayerEvents extends PlotListener implements Listener { } Plot plot = location.getOwnedPlot(); if (plot == null) { - if (area.isRoadFlags() && area.getRoadFlag(ItemDropFlag.class)) { + if (area.isRoadFlags() && !area.getRoadFlag(ItemDropFlag.class)) { event.setCancelled(true); } return; From 55139eb134996d559055aea9e271d89beb979ad7 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 9 Jul 2020 22:19:23 +0100 Subject: [PATCH 18/21] Do not respect paste on top for road schematics. --- .../main/java/com/plotsquared/core/generator/HybridUtils.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/generator/HybridUtils.java b/Core/src/main/java/com/plotsquared/core/generator/HybridUtils.java index 75ada359f..ec70811db 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/HybridUtils.java +++ b/Core/src/main/java/com/plotsquared/core/generator/HybridUtils.java @@ -622,9 +622,6 @@ public abstract class HybridUtils { if (condition) { BaseBlock[] blocks = plotWorld.G_SCH.get(MathMan.pair(absX, absZ)); int minY = plotWorld.SCHEM_Y; - if (!Settings.Schematics.PASTE_ON_TOP) { - minY = 1; - } int maxY = Math.max(extend, blocks.length); for (int y = 0; y < maxY; y++) { if (y > blocks.length - 1) { From 5b260ea8da4c6955bce501aa7ab23c9f42d73d73 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 9 Jul 2020 22:33:01 +0100 Subject: [PATCH 19/21] update bukkit pom --- Bukkit/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bukkit/pom.xml b/Bukkit/pom.xml index f70fa0eba..cde998b9a 100644 --- a/Bukkit/pom.xml +++ b/Bukkit/pom.xml @@ -21,7 +21,7 @@ com.plotsquared PlotSquared-Core - 5.12.4 + 5.12.5 compile From 2fb76e66364737ba5609fecd2c5e53b29bb36526 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 9 Jul 2020 22:39:06 +0100 Subject: [PATCH 20/21] Split road and plot paste-on-top settings --- .../plotsquared/core/configuration/Settings.java | 3 +++ .../plotsquared/core/generator/HybridGen.java | 3 ++- .../core/generator/HybridPlotManager.java | 16 +++++++++------- .../plotsquared/core/generator/HybridUtils.java | 14 +++++++------- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java index db22c46be..f575fba43 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java @@ -388,6 +388,9 @@ public class Settings extends Config { @Comment( "Whether schematic based generation should paste schematic on top of plots, or from Y=1") public static boolean PASTE_ON_TOP = true; + @Comment( + "Whether schematic based road generation should paste schematic on top of roads, or from Y=1") + public static boolean PASTE_ROAD_ON_TOP = true; } diff --git a/Core/src/main/java/com/plotsquared/core/generator/HybridGen.java b/Core/src/main/java/com/plotsquared/core/generator/HybridGen.java index e661e4c5f..a4f955682 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/HybridGen.java +++ b/Core/src/main/java/com/plotsquared/core/generator/HybridGen.java @@ -47,7 +47,8 @@ public class HybridGen extends IndependentPlotGenerator { private void placeSchem(HybridPlotWorld world, ScopedLocalBlockQueue result, short relativeX, short relativeZ, int x, int z, boolean isRoad) { int minY; // Math.min(world.PLOT_HEIGHT, world.ROAD_HEIGHT); - if (isRoad || Settings.Schematics.PASTE_ON_TOP) { + if ((isRoad && Settings.Schematics.PASTE_ROAD_ON_TOP) || (!isRoad + && Settings.Schematics.PASTE_ON_TOP)) { minY = world.SCHEM_Y; } else { minY = 1; diff --git a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotManager.java b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotManager.java index 67ad6eb8b..da4fa74b9 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotManager.java +++ b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotManager.java @@ -112,15 +112,17 @@ public class HybridPlotManager extends ClassicPlotManager { return true; } LocalBlockQueue queue = hybridPlotWorld.getQueue(false); - createSchemAbs(queue, pos1, pos2); + createSchemAbs(queue, pos1, pos2, true); queue.enqueue(); return true; } - private void createSchemAbs(LocalBlockQueue queue, Location pos1, Location pos2) { + private void createSchemAbs(LocalBlockQueue queue, Location pos1, Location pos2, + boolean isRoad) { int size = hybridPlotWorld.SIZE; int minY; - if (Settings.Schematics.PASTE_ON_TOP) { + if ((isRoad && Settings.Schematics.PASTE_ROAD_ON_TOP) || (!isRoad + && Settings.Schematics.PASTE_ON_TOP)) { minY = hybridPlotWorld.SCHEM_Y; } else { minY = 1; @@ -172,7 +174,7 @@ public class HybridPlotManager extends ClassicPlotManager { return true; } LocalBlockQueue queue = hybridPlotWorld.getQueue(false); - createSchemAbs(queue, pos1, pos2); + createSchemAbs(queue, pos1, pos2, true); queue.enqueue(); return true; } @@ -186,9 +188,9 @@ public class HybridPlotManager extends ClassicPlotManager { pos1.setY(0); pos2.setY(Math.min(getWorldHeight(), 255)); LocalBlockQueue queue = hybridPlotWorld.getQueue(false); - createSchemAbs(queue, pos1, pos2); + createSchemAbs(queue, pos1, pos2, true); if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) { - createSchemAbs(queue, pos1, pos2); + createSchemAbs(queue, pos1, pos2, true); } return queue.enqueue(); } @@ -267,7 +269,7 @@ public class HybridPlotManager extends ClassicPlotManager { if (!hybridPlotWorld.PLOT_SCHEMATIC) { return; } - createSchemAbs(queue, bottom, top); + createSchemAbs(queue, bottom, top, false); } /** diff --git a/Core/src/main/java/com/plotsquared/core/generator/HybridUtils.java b/Core/src/main/java/com/plotsquared/core/generator/HybridUtils.java index ec70811db..539e9e1cd 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/HybridUtils.java +++ b/Core/src/main/java/com/plotsquared/core/generator/HybridUtils.java @@ -83,6 +83,11 @@ public abstract class HybridUtils { public static PlotArea area; public static boolean UPDATE = false; + public static boolean regeneratePlotWalls(final PlotArea area) { + PlotManager plotManager = area.getPlotManager(); + return plotManager.regenerateAllPlotWalls(); + } + public void analyzeRegion(final String world, final CuboidRegion region, final RunnableVal whenDone) { // int diff, int variety, int vertices, int rotation, int height_sd @@ -501,7 +506,7 @@ public abstract class HybridUtils { PlotManager plotManager = plotworld.getPlotManager(); int sx = bot.getX() - plotworld.ROAD_WIDTH + 1; int sz = bot.getZ() + 1; - int sy = plotworld.ROAD_HEIGHT; + int sy = Settings.Schematics.PASTE_ROAD_ON_TOP ? plotworld.ROAD_HEIGHT : 1; int ex = bot.getX(); int ez = top.getZ(); int ey = get_ey(plotManager, queue, sx, ex, sz, ez, sy); @@ -621,7 +626,7 @@ public abstract class HybridUtils { } if (condition) { BaseBlock[] blocks = plotWorld.G_SCH.get(MathMan.pair(absX, absZ)); - int minY = plotWorld.SCHEM_Y; + int minY = Settings.Schematics.PASTE_ROAD_ON_TOP ? plotWorld.SCHEM_Y : 1; int maxY = Math.max(extend, blocks.length); for (int y = 0; y < maxY; y++) { if (y > blocks.length - 1) { @@ -656,9 +661,4 @@ public abstract class HybridUtils { } return false; } - - public static boolean regeneratePlotWalls(final PlotArea area) { - PlotManager plotManager = area.getPlotManager(); - return plotManager.regenerateAllPlotWalls(); - } } From e72ce9c90ed784be681c422eb593da41dbafe2c5 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Tue, 14 Jul 2020 12:44:11 +0200 Subject: [PATCH 21/21] Update gradle.yml --- .github/workflows/gradle.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 2447c5b87..1f19a8e80 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -3,14 +3,12 @@ name: Java CI on: push: branches: - - 'v4' - 'v5' - - 'legacy/1.8-1.12' + - 'v6' pull_request: branches: - - 'v4' - 'v5' - - 'legacy/1.8-1.12' + - 'v6' jobs: test: