From 16e26b910c1577681f6498d03c69e24789580760 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 9 May 2022 13:53:59 +0200 Subject: [PATCH 01/10] build: Update dependency com.github.spotbugs:spotbugs-annotations to v4.7.0 (#3606) Co-authored-by: Renovate Bot --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e62f8bcde..d66b57d56 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,7 +8,7 @@ guava = "31.0.1-jre" # Version set by Minecraft paper = "1.18.1-R0.1-SNAPSHOT" checker-qual = "3.22.0" guice = "5.1.0" -spotbugs = "4.6.0" +spotbugs = "4.7.0" snakeyaml = "1.30" # Version set by Bukkit # Adventure & MiniMessage From 13d7357c8523487b40b4f1c1bbe4815f8a3d6a7c Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Tue, 10 May 2022 01:43:01 +0100 Subject: [PATCH 02/10] Niceties - Better ordering of augmented information printed to consol on startup - Override --- .../bukkit/generator/DelegatePlotGenerator.java | 3 ++- .../java/com/plotsquared/core/PlotSquared.java | 14 +++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/DelegatePlotGenerator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/DelegatePlotGenerator.java index 93d60997b..0ce6554d8 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/DelegatePlotGenerator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/DelegatePlotGenerator.java @@ -80,7 +80,8 @@ final class DelegatePlotGenerator extends IndependentPlotGenerator { result.setBiome(x, z, BukkitAdapter.adapt(biome)); } - //do not annotate with Override until we discontinue support for 1.4.4 + //do not annotate with Override until we discontinue support for 1.4.4 (we no longer support 1.4.4) + @Override public void setBiome(int x, int y, int z, @NonNull Biome biome) { result.setBiome(x, z, BukkitAdapter.adapt(biome)); diff --git a/Core/src/main/java/com/plotsquared/core/PlotSquared.java b/Core/src/main/java/com/plotsquared/core/PlotSquared.java index 872d1bd68..9c9bb09f3 100644 --- a/Core/src/main/java/com/plotsquared/core/PlotSquared.java +++ b/Core/src/main/java/com/plotsquared/core/PlotSquared.java @@ -889,8 +889,8 @@ public class PlotSquared { e.printStackTrace(); } LOGGER.info("| generator: {}>{}", baseGenerator, areaGen); - LOGGER.info("| plot world: {}", pa); - LOGGER.info("| manager: {}", pa); + LOGGER.info("| plot world: {}", pa.getClass().getCanonicalName()); + LOGGER.info("| manager: {}", pa.getPlotManager().getClass().getCanonicalName()); LOGGER.info("Note: Area created for cluster '{}' (invalid or old configuration?)", name); areaGen.getPlotGenerator().initialize(pa); areaGen.augment(pa); @@ -906,6 +906,13 @@ public class PlotSquared { throw new IllegalArgumentException("Invalid Generator: " + gen_string); } PlotArea pa = areaGen.getPlotGenerator().getNewPlotArea(world, null, null, null); + LOGGER.info("- generator: {}>{}", baseGenerator, areaGen); + LOGGER.info("- plot world: {}", pa.getClass().getCanonicalName()); + LOGGER.info("- plot area manager: {}", pa.getPlotManager().getClass().getCanonicalName()); + if (!this.worldConfiguration.contains(path)) { + this.worldConfiguration.createSection(path); + worldSection = this.worldConfiguration.getConfigurationSection(path); + } pa.saveConfiguration(worldSection); pa.loadDefaultConfiguration(worldSection); try { @@ -913,9 +920,6 @@ public class PlotSquared { } catch (IOException e) { e.printStackTrace(); } - LOGGER.info("- generator: {}>{}", baseGenerator, areaGen); - LOGGER.info("- plot world: {}", pa); - LOGGER.info("- plot area manager: {}", pa.getPlotManager()); areaGen.getPlotGenerator().initialize(pa); areaGen.augment(pa); addPlotArea(pa); From 7d6e515ba8c4f2048d64a407a24b53e9e592ce69 Mon Sep 17 00:00:00 2001 From: Bernhard Date: Tue, 10 May 2022 09:50:27 +0200 Subject: [PATCH 03/10] Improvements to /plot list command (#3585) * refactor: list command shows owner better added check for: - unknown owners (UUID not cached/invalid) - server plots - plots owner by everyone * fix: show correct color in list command if plot is owned by everyone * refactor: improved List command for server plots (cherry picked from commit fed700f0d8d20b0c53e7767b3b4bf04c40f9a9b5) * refactor: removed duplicate code * refactor: renamed placeholders to reflect their use Co-authored-by: Alexander Brandes --- .../com/plotsquared/core/command/ListCmd.java | 85 ++++++++++++------- Core/src/main/resources/lang/messages_en.json | 3 + 2 files changed, 58 insertions(+), 30 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/command/ListCmd.java b/Core/src/main/java/com/plotsquared/core/command/ListCmd.java index e6a2ae91d..8fe2fd46c 100644 --- a/Core/src/main/java/com/plotsquared/core/command/ListCmd.java +++ b/Core/src/main/java/com/plotsquared/core/command/ListCmd.java @@ -32,6 +32,7 @@ import com.plotsquared.core.configuration.caption.Caption; import com.plotsquared.core.configuration.caption.CaptionHolder; import com.plotsquared.core.configuration.caption.Templates; import com.plotsquared.core.configuration.caption.TranslatableCaption; +import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.permissions.Permission; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; @@ -39,6 +40,7 @@ import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.expiration.ExpireManager; import com.plotsquared.core.plot.flag.implementations.DoneFlag; import com.plotsquared.core.plot.flag.implementations.PriceFlag; +import com.plotsquared.core.plot.flag.implementations.ServerPlotFlag; import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.util.EconHandler; import com.plotsquared.core.util.MathMan; @@ -418,7 +420,7 @@ public class ListCmd extends SubCommand { Caption color; if (plot.getOwner() == null) { color = TranslatableCaption.of("info.plot_list_no_owner"); - } else if (plot.isOwner(player.getUUID())) { + } else if (plot.isOwner(player.getUUID()) || plot.getOwner().equals(DBFunc.EVERYONE)) { color = TranslatableCaption.of("info.plot_list_owned_by"); } else if (plot.isAdded(player.getUUID())) { color = TranslatableCaption.of("info.plot_list_added_to"); @@ -456,37 +458,60 @@ public class ListCmd extends SubCommand { String prefix = ""; String online = TranslatableCaption.of("info.plot_list_player_online").getComponent(player); String offline = TranslatableCaption.of("info.plot_list_player_offline").getComponent(player); + String unknown = TranslatableCaption.of("info.plot_list_player_unknown").getComponent(player); + String server = TranslatableCaption.of("info.plot_list_player_server").getComponent(player); + String everyone = TranslatableCaption.of("info.plot_list_player_everyone").getComponent(player); TextComponent.Builder builder = Component.text(); - try { - final List names = PlotSquared.get().getImpromptuUUIDPipeline().getNames(plot.getOwners()) - .get(Settings.UUID.BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS); - for (final UUIDMapping uuidMapping : names) { - PlotPlayer pp = PlotSquared.platform().playerManager().getPlayerIfExists(uuidMapping.getUuid()); - Template prefixTemplate = Template.of("prefix", prefix); - Template playerTemplate = Template.of("player", uuidMapping.getUsername()); - if (pp != null) { - builder.append(MINI_MESSAGE.parse(online, prefixTemplate, playerTemplate)); - } else { - builder.append(MINI_MESSAGE.parse(offline, prefixTemplate, playerTemplate)); - } - prefix = ", "; - } - } catch (InterruptedException | ExecutionException e) { - final StringBuilder playerBuilder = new StringBuilder(); - final Iterator uuidIterator = plot.getOwners().iterator(); - while (uuidIterator.hasNext()) { - final UUID uuid = uuidIterator.next(); - playerBuilder.append(uuid); - if (uuidIterator.hasNext()) { - playerBuilder.append(", "); - } - } - player.sendMessage( - TranslatableCaption.of("errors.invalid_player"), - Templates.of("value", playerBuilder.toString()) + if (plot.getFlag(ServerPlotFlag.class)) { + Template serverTemplate = Template.of( + "info.server", + TranslatableCaption.of("info.server").getComponent(player) ); - } catch (TimeoutException e) { - player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout")); + builder.append(MINI_MESSAGE.parse(server, serverTemplate)); + } else { + try { + final List names = PlotSquared.get().getImpromptuUUIDPipeline().getNames(plot.getOwners()) + .get(Settings.UUID.BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS); + for (final UUIDMapping uuidMapping : names) { + PlotPlayer pp = PlotSquared.platform().playerManager().getPlayerIfExists(uuidMapping.getUuid()); + Template prefixTemplate = Template.of("prefix", prefix); + Template playerTemplate = Template.of("player", uuidMapping.getUsername()); + if (pp != null) { + builder.append(MINI_MESSAGE.parse(online, prefixTemplate, playerTemplate)); + } else if (uuidMapping.getUsername().equalsIgnoreCase("unknown")) { + Template unknownTemplate = Template.of( + "info.unknown", + TranslatableCaption.of("info.unknown").getComponent(player) + ); + builder.append(MINI_MESSAGE.parse(unknown, unknownTemplate)); + } else if (uuidMapping.getUuid().equals(DBFunc.EVERYONE)) { + Template everyoneTemplate = Template.of( + "info.everyone", + TranslatableCaption.of("info.everyone").getComponent(player) + ); + builder.append(MINI_MESSAGE.parse(everyone, everyoneTemplate)); + } else { + builder.append(MINI_MESSAGE.parse(offline, prefixTemplate, playerTemplate)); + } + prefix = ", "; + } + } catch (InterruptedException | ExecutionException e) { + final StringBuilder playerBuilder = new StringBuilder(); + final Iterator uuidIterator = plot.getOwners().iterator(); + while (uuidIterator.hasNext()) { + final UUID uuid = uuidIterator.next(); + playerBuilder.append(uuid); + if (uuidIterator.hasNext()) { + playerBuilder.append(", "); + } + } + player.sendMessage( + TranslatableCaption.of("errors.invalid_player"), + Templates.of("value", playerBuilder.toString()) + ); + } catch (TimeoutException e) { + player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout")); + } } Template players = Template.of("players", builder.asComponent()); caption.set(TranslatableCaption.of("info.plot_list_item")); diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json index bc189c8c9..85c829d8c 100644 --- a/Core/src/main/resources/lang/messages_en.json +++ b/Core/src/main/resources/lang/messages_en.json @@ -381,6 +381,9 @@ "info.plot_list_default": "", "info.plot_list_player_online": "Online\">", "info.plot_list_player_offline": "Offline\">", + "info.plot_list_player_unknown": "The owner of this plot is unknown\">", + "info.plot_list_player_server": "The plot is owned by the server\">", + "info.plot_list_player_everyone": "The plot is owned by everyone\">", "info.area_info_format": "
\nName: \nType: \nTerrain: \nUsage: %\nClaimed: \nClusters: \nRegion: \nGenerator: \n