From babad3ab6de755de20a9e11376837442b5879a16 Mon Sep 17 00:00:00 2001 From: Hannes Greule Date: Fri, 4 Sep 2020 14:49:02 +0200 Subject: [PATCH 01/11] Don't validate plot aliases with offline players (Fixes PS-126) --- Core/src/main/java/com/plotsquared/core/command/Alias.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Core/src/main/java/com/plotsquared/core/command/Alias.java b/Core/src/main/java/com/plotsquared/core/command/Alias.java index 59c0da49c..71a82c91f 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Alias.java +++ b/Core/src/main/java/com/plotsquared/core/command/Alias.java @@ -27,6 +27,7 @@ package com.plotsquared.core.command; import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.Captions; +import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.location.Location; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; @@ -151,6 +152,12 @@ public class Alias extends SubCommand { MainUtil.sendMessage(player, Captions.ALIAS_IS_TAKEN); return; } + if (Settings.UUID.OFFLINE) { + plot.setAlias(alias); + MainUtil.sendMessage(player, + Captions.ALIAS_SET_TO.getTranslated().replaceAll("%alias%", alias)); + return; + } PlotSquared.get().getImpromptuUUIDPipeline().getSingle(alias, ((uuid, throwable) -> { if (throwable instanceof TimeoutException) { MainUtil.sendMessage(player, Captions.FETCHING_PLAYERS_TIMEOUT); From 37010d92ee9869a43978a2e06515f5f3668a4571 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Sat, 5 Sep 2020 13:42:11 +0200 Subject: [PATCH 02/11] Create CODEOWNERS --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 000000000..f0809ab2a --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +@IntellectualSites/plotsquared-team From f6d1e2b3b8d7bf1145a035a21692a16a14673f88 Mon Sep 17 00:00:00 2001 From: Hannes Greule Date: Sat, 5 Sep 2020 13:24:18 +0200 Subject: [PATCH 03/11] Check TileState manually on 1.13.2, fixes PS-122 --- .../com/plotsquared/bukkit/BukkitMain.java | 8 ++- .../bukkit/listener/PaperListener113.java | 58 +++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener113.java diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java index 34cbcc5b3..4f149d126 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -25,6 +25,7 @@ */ package com.plotsquared.bukkit; +import com.plotsquared.bukkit.chat.Reflection; import com.plotsquared.bukkit.generator.BukkitHybridUtils; import com.plotsquared.bukkit.generator.BukkitPlotGenerator; import com.plotsquared.bukkit.listener.BlockEventListener; @@ -32,6 +33,7 @@ import com.plotsquared.bukkit.listener.ChunkListener; import com.plotsquared.bukkit.listener.EntityEventListener; import com.plotsquared.bukkit.listener.EntitySpawnListener; import com.plotsquared.bukkit.listener.PaperListener; +import com.plotsquared.bukkit.listener.PaperListener113; import com.plotsquared.bukkit.listener.PlayerEventListener; import com.plotsquared.bukkit.listener.ProjectileEventListener; import com.plotsquared.bukkit.listener.ServerListener; @@ -904,7 +906,11 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain< getServer().getPluginManager().registerEvents(new ProjectileEventListener(), this); getServer().getPluginManager().registerEvents(new EntitySpawnListener(), this); if (PaperLib.isPaper() && Settings.Paper_Components.PAPER_LISTENERS) { - getServer().getPluginManager().registerEvents(new PaperListener(), this); + if (Reflection.getVersion().startsWith("v1_13")) { + getServer().getPluginManager().registerEvents(new PaperListener113(), this); + } else { + getServer().getPluginManager().registerEvents(new PaperListener(), this); + } } PlotListener.startRunnable(); } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener113.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener113.java new file mode 100644 index 000000000..d098182bf --- /dev/null +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener113.java @@ -0,0 +1,58 @@ +package com.plotsquared.bukkit.listener; + +import com.plotsquared.bukkit.util.BukkitUtil; +import com.plotsquared.core.configuration.Captions; +import com.plotsquared.core.configuration.Settings; +import com.plotsquared.core.location.Location; +import com.plotsquared.core.player.PlotPlayer; +import com.plotsquared.core.plot.PlotArea; +import org.bukkit.block.Banner; +import org.bukkit.block.Beacon; +import org.bukkit.block.Bed; +import org.bukkit.block.BlockState; +import org.bukkit.block.CommandBlock; +import org.bukkit.block.Comparator; +import org.bukkit.block.Conduit; +import org.bukkit.block.Container; +import org.bukkit.block.CreatureSpawner; +import org.bukkit.block.DaylightDetector; +import org.bukkit.block.EnchantingTable; +import org.bukkit.block.EndGateway; +import org.bukkit.block.EnderChest; +import org.bukkit.block.Jukebox; +import org.bukkit.block.Sign; +import org.bukkit.block.Skull; +import org.bukkit.block.Structure; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.BlockPlaceEvent; + +public class PaperListener113 extends PaperListener { + + @EventHandler + public void onBlockPlace(BlockPlaceEvent event) { + if (!Settings.Paper_Components.TILE_ENTITY_CHECK || !Settings.Enabled_Components.CHUNK_PROCESSOR) { + return; + } + BlockState state = event.getBlock().getState(false); + if (!(state instanceof Banner || state instanceof Beacon || state instanceof Bed + || state instanceof CommandBlock || state instanceof Comparator || state instanceof Conduit + || state instanceof Container || state instanceof CreatureSpawner || state instanceof DaylightDetector + || state instanceof EnchantingTable || state instanceof EnderChest || state instanceof EndGateway + || state instanceof Jukebox || state instanceof Sign || state instanceof Skull + || state instanceof Structure)) { + return; + } + final Location location = BukkitUtil.getLocation(event.getBlock().getLocation()); + final PlotArea plotArea = location.getPlotArea(); + if (plotArea == null) { + return; + } + final int tileEntityCount = event.getBlock().getChunk().getTileEntities(false).length; + if (tileEntityCount >= Settings.Chunk_Processor.MAX_TILES) { + final PlotPlayer plotPlayer = BukkitUtil.getPlayer(event.getPlayer()); + Captions.TILE_ENTITY_CAP_REACHED.send(plotPlayer, Settings.Chunk_Processor.MAX_TILES); + event.setCancelled(true); + event.setBuild(false); + } + } +} From 5c48e4ad19088b940d06d9f540a2f59b566bd574 Mon Sep 17 00:00:00 2001 From: Hannes Greule Date: Sat, 5 Sep 2020 13:28:04 +0200 Subject: [PATCH 04/11] Add missing license header --- .../bukkit/listener/PaperListener113.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener113.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener113.java index d098182bf..fc5fca677 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener113.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener113.java @@ -1,3 +1,28 @@ +/* + * _____ _ _ _____ _ + * | __ \| | | | / ____| | | + * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| | + * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` | + * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| | + * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_| + * | | + * |_| + * PlotSquared plot management system for Minecraft + * Copyright (C) 2020 IntellectualSites + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package com.plotsquared.bukkit.listener; import com.plotsquared.bukkit.util.BukkitUtil; From 0aeca40137d85d66e6ad0b67a4a42b324cce0b0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Sat, 5 Sep 2020 18:48:58 +0200 Subject: [PATCH 05/11] Take player visibility into account when sending notify-enter and notify-leave messages. Fixes PS-103. --- .../com/plotsquared/bukkit/player/BukkitPlayer.java | 8 ++++++++ .../com/plotsquared/core/listener/PlotListener.java | 8 ++++---- .../com/plotsquared/core/player/ConsolePlayer.java | 4 ++++ .../java/com/plotsquared/core/player/PlotPlayer.java | 10 ++++++++++ 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java index 643039600..1d4a0284e 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java @@ -32,6 +32,7 @@ import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.events.TeleportCause; import com.plotsquared.core.location.Location; +import com.plotsquared.core.player.ConsolePlayer; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.PlotWeather; import com.plotsquared.core.util.EconHandler; @@ -354,6 +355,13 @@ public class BukkitPlayer extends PlotPlayer { return this.player.isBanned(); } + @Override public boolean canSee(final PlotPlayer other) { + if (other instanceof ConsolePlayer) { + return true; + } else { + return this.player.canSee(((BukkitPlayer) other).getPlatformPlayer()); + } + } public PlayerTeleportEvent.TeleportCause getTeleportCause(@NotNull final TeleportCause cause) { switch (cause) { diff --git a/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java b/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java index 361a71b28..bd99fe197 100644 --- a/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java +++ b/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java @@ -160,8 +160,8 @@ public class PlotListener { if (plot.getFlag(NotifyEnterFlag.class)) { if (!Permissions.hasPermission(player, "plots.flag.notify-enter.bypass")) { for (UUID uuid : plot.getOwners()) { - final PlotPlayer owner = PlotSquared.imp().getPlayerManager().getPlayerIfExists(uuid); - if (owner != null && !owner.getUUID().equals(player.getUUID())) { + final PlotPlayer owner = PlotSquared.imp().getPlayerManager().getPlayerIfExists(uuid); + if (owner != null && !owner.getUUID().equals(player.getUUID()) && owner.canSee(player)) { MainUtil.sendMessage(owner, Captions.NOTIFY_ENTER.getTranslated() .replace("%player", player.getName()) .replace("%plot", plot.getId().toString())); @@ -336,8 +336,8 @@ public class PlotListener { if (plot.getFlag(NotifyLeaveFlag.class)) { if (!Permissions.hasPermission(player, "plots.flag.notify-enter.bypass")) { for (UUID uuid : plot.getOwners()) { - final PlotPlayer owner = PlotSquared.imp().getPlayerManager().getPlayerIfExists(uuid); - if ((owner != null) && !owner.getUUID().equals(player.getUUID())) { + final PlotPlayer owner = PlotSquared.imp().getPlayerManager().getPlayerIfExists(uuid); + if ((owner != null) && !owner.getUUID().equals(player.getUUID()) && owner.canSee(player)) { MainUtil.sendMessage(owner, Captions.NOTIFY_LEAVE.getTranslated() .replace("%player", player.getName()) .replace("%plot", plot.getId().toString())); diff --git a/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java b/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java index 9a97800e7..10a27c0fd 100644 --- a/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java +++ b/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java @@ -174,4 +174,8 @@ public class ConsolePlayer extends PlotPlayer { return false; } + @Override public boolean canSee(final PlotPlayer other) { + return true; + } + } 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 b11a33ba6..95fba9a60 100644 --- a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java +++ b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java @@ -727,6 +727,16 @@ public abstract class PlotPlayer

implements CommandCaller, OfflinePlotPlayer } } + /** + * Check if the player is able to see the other player. + * This does not mean that the other player is in line of sight of the player, + * but rather that the player is permitted to see the other player. + * + * @param other Other player + * @return {@code true} if the player is able to see the other player, {@code false} if not + */ + public abstract boolean canSee(PlotPlayer other); + public boolean hasPersistentMeta(String key) { return this.metaMap.containsKey(key); } From f2355a76d68014306315dc31eb0fe731b091cec8 Mon Sep 17 00:00:00 2001 From: Hannes Greule Date: Sun, 6 Sep 2020 23:36:36 +0200 Subject: [PATCH 06/11] Add default namespace when wrapping block categories by their ids --- .../core/plot/flag/types/BlockTypeWrapper.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/types/BlockTypeWrapper.java b/Core/src/main/java/com/plotsquared/core/plot/flag/types/BlockTypeWrapper.java index 9af840d4c..d29140672 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/flag/types/BlockTypeWrapper.java +++ b/Core/src/main/java/com/plotsquared/core/plot/flag/types/BlockTypeWrapper.java @@ -46,6 +46,8 @@ public class BlockTypeWrapper { private static final Map blockTypes = new HashMap<>(); private static final Map blockCategories = new HashMap<>(); + private static final String minecraftNamespace = "minecraft"; + @Nullable @Getter private final BlockType blockType; @Nullable private final String blockCategoryId; @Nullable private BlockCategory blockCategory; @@ -78,7 +80,14 @@ public class BlockTypeWrapper { } public static BlockTypeWrapper get(final String blockCategoryId) { - return blockCategories.computeIfAbsent(blockCategoryId, BlockTypeWrapper::new); + // use minecraft as default namespace + String id; + if (blockCategoryId.indexOf(':') == -1) { + id = minecraftNamespace + ":" + blockCategoryId; + } else { + id = blockCategoryId; + } + return blockCategories.computeIfAbsent(id, BlockTypeWrapper::new); } @Override public String toString() { From 0c6113b0d1a04096ac3d406b4581baab4b8ad22e Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Wed, 9 Sep 2020 23:31:30 +0200 Subject: [PATCH 07/11] 5.13.4 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 615053d2c..5fc85e33f 100644 --- a/build.gradle +++ b/build.gradle @@ -30,7 +30,7 @@ ext { git = Grgit.open(dir: new File(rootDir.toString() + "/.git")) } -def ver = "5.13.3" +def ver = "5.13.4" def versuffix = "" ext { if (project.hasProperty("versionsuffix")) { From 5463f15633b56a8b33ec7f2aae3acc4c54475cba Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Fri, 11 Sep 2020 01:16:57 +0200 Subject: [PATCH 08/11] Add pigstep music disc --- Core/src/main/java/com/plotsquared/core/command/Music.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/src/main/java/com/plotsquared/core/command/Music.java b/Core/src/main/java/com/plotsquared/core/command/Music.java index 91b756a81..c113f6ae0 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Music.java +++ b/Core/src/main/java/com/plotsquared/core/command/Music.java @@ -53,7 +53,7 @@ public class Music extends SubCommand { private static final Collection DISCS = Arrays .asList("music_disc_13", "music_disc_cat", "music_disc_blocks", "music_disc_chirp", "music_disc_far", "music_disc_mall", "music_disc_mellohi", "music_disc_stal", - "music_disc_strad", "music_disc_ward", "music_disc_11", "music_disc_wait"); + "music_disc_strad", "music_disc_ward", "music_disc_11", "music_disc_wait", "music_disc_pigstep"); @Override public boolean onCommand(PlotPlayer player, String[] args) { Location location = player.getLocation(); From 648953ec1fa3df3c614aff37c228e4b29131934a Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Fri, 11 Sep 2020 12:27:23 +0200 Subject: [PATCH 09/11] 5.13.5 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 5fc85e33f..c55f5f6e8 100644 --- a/build.gradle +++ b/build.gradle @@ -30,7 +30,7 @@ ext { git = Grgit.open(dir: new File(rootDir.toString() + "/.git")) } -def ver = "5.13.4" +def ver = "5.13.5" def versuffix = "" ext { if (project.hasProperty("versionsuffix")) { From d843d1715dcf7ee25f90c0891f795a595bf8f890 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Fri, 11 Sep 2020 15:03:48 +0100 Subject: [PATCH 10/11] Allow /plot home [area|world] --- .../java/com/plotsquared/core/command/HomeCommand.java | 9 ++++++++- 1 file changed, 8 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 42c4ff1c5..fe25c585e 100644 --- a/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java @@ -107,6 +107,7 @@ public class HomeCommand extends Command { PlotQuery query = query(player); int page = 1; // page = index + 1 String identifier; + PlotArea plotArea; boolean basePlotOnly = true; switch (args.length) { case 1: @@ -129,12 +130,18 @@ public class HomeCommand extends Command { query.withPlot(fromId); break; } + // allow for plot home within a plot area + plotArea = PlotSquared.get().getPlotAreaByString(args[0]); + if (plotArea != null) { + query.inArea(plotArea); + break; + } // it wasn't a valid plot id, trying to find plot by alias query.withAlias(identifier); break; case 2: // we assume args[0] is a plot area and args[1] an identifier - PlotArea plotArea = PlotSquared.get().getPlotAreaByString(args[0]); + plotArea = PlotSquared.get().getPlotAreaByString(args[0]); identifier = args[1]; if (plotArea == null) { // invalid command, therefore no plots From 8547533210175f6c67263915a6ae352a2189f4cd Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Fri, 11 Sep 2020 15:04:09 +0100 Subject: [PATCH 11/11] update pom --- Bukkit/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bukkit/pom.xml b/Bukkit/pom.xml index ef3ad830a..5d2f060bc 100644 --- a/Bukkit/pom.xml +++ b/Bukkit/pom.xml @@ -21,7 +21,7 @@ com.plotsquared PlotSquared-Core - 5.13.3 + 5.13.5 compile