From ffbec24290d4fd13a5b746ece75d824ca41947de Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 24 Jan 2023 22:35:15 +0100 Subject: [PATCH 1/5] Update dependency com.intellectualsites.bom:bom-1.18.x to v1.23 (#3948) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 3ef77914f..19635d1e8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -74,7 +74,7 @@ subprojects { } dependencies { - implementation(platform("com.intellectualsites.bom:bom-1.18.x:1.22")) + implementation(platform("com.intellectualsites.bom:bom-1.18.x:1.23")) } dependencies { From 0d359ade0c3a78b78f2dd368350c6f9c66056f57 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 28 Jan 2023 19:21:35 +0100 Subject: [PATCH 2/5] Update dependency com.diffplug.spotless to v6.14.0 (#3950) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- 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 3fb14d96b..79d494352 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -21,7 +21,7 @@ http4j = "1.3" # Gradle plugins shadow = "7.1.2" grgit = "4.1.1" -spotless = "6.13.0" +spotless = "6.14.0" nexus = "1.1.0" [libraries] From d7c2ab1d169df9b062ab0db2192d9a14bc14efc4 Mon Sep 17 00:00:00 2001 From: Traks <58818927+traksag@users.noreply.github.com> Date: Tue, 31 Jan 2023 11:22:13 +0100 Subject: [PATCH 3/5] Make farmland keep its moisture (#3952) Handle MoistureChangeEvent for farm land --- .../bukkit/listener/BlockEventListener.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java index 343acce06..fe58c41b7 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java @@ -98,6 +98,7 @@ import org.bukkit.event.block.BlockSpreadEvent; import org.bukkit.event.block.CauldronLevelChangeEvent; import org.bukkit.event.block.EntityBlockFormEvent; import org.bukkit.event.block.LeavesDecayEvent; +import org.bukkit.event.block.MoistureChangeEvent; import org.bukkit.event.block.SpongeAbsorbEvent; import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.projectiles.BlockProjectileSource; @@ -703,6 +704,28 @@ public class BlockEventListener implements Listener { } } + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onMoistureChange(MoistureChangeEvent event) { + Block block = event.getBlock(); + Location location = BukkitUtil.adapt(block.getLocation()); + PlotArea area = location.getPlotArea(); + if (area == null) { + return; + } + Plot plot = area.getOwnedPlot(location); + if (plot == null) { + event.setCancelled(true); + return; + } + Material blockType = block.getType(); + if (blockType == Material.FARMLAND) { + if (!plot.getFlag(SoilDryFlag.class)) { + plot.debug("Soil could not dry because soil-dry = false"); + event.setCancelled(true); + } + } + } + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onChange(BlockFromToEvent event) { Block fromBlock = event.getBlock(); From 84567bcb009e8a8b50e3f27fbf58e75d21bc299c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 6 Feb 2023 12:48:30 +0100 Subject: [PATCH 4/5] Update dependency com.diffplug.spotless to v6.14.1 (#3957) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- 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 79d494352..fc02d8785 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -21,7 +21,7 @@ http4j = "1.3" # Gradle plugins shadow = "7.1.2" grgit = "4.1.1" -spotless = "6.14.0" +spotless = "6.14.1" nexus = "1.1.0" [libraries] From 5cce86d9247c9b72bf0d58676fdfce140d4f6605 Mon Sep 17 00:00:00 2001 From: ByteExceptionM Date: Thu, 9 Feb 2023 20:51:59 +0100 Subject: [PATCH 5/5] feat: Add event firing on remove road entity (#3955) * feat: Add event firing on remove road entity Signed-off-by: ByteExceptionM * chore: Add some more entity vars Signed-off-by: ByteExceptionM * chore: Rename method Signed-off-by: ByteExceptionM * chore: Code cleanup Signed-off-by: ByteExceptionM * chore: Code reformat Signed-off-by: ByteExceptionM * chore: Change iterator removal Signed-off-by: ByteExceptionM * Comply with checkstyle --------- Signed-off-by: ByteExceptionM Co-authored-by: Alexander Brandes --- .../plotsquared/bukkit/BukkitPlatform.java | 31 +++++---- .../plotsquared/core/events/EntityEvent.java | 63 +++++++++++++++++++ .../core/events/RemoveRoadEntityEvent.java | 50 +++++++++++++++ .../core/util/EventDispatcher.java | 8 +++ 4 files changed, 141 insertions(+), 11 deletions(-) create mode 100644 Core/src/main/java/com/plotsquared/core/events/EntityEvent.java create mode 100644 Core/src/main/java/com/plotsquared/core/events/RemoveRoadEntityEvent.java diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java index 8055bd5cb..c82de570e 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java @@ -71,6 +71,8 @@ import com.plotsquared.core.configuration.Storage; import com.plotsquared.core.configuration.caption.ChatFormatter; import com.plotsquared.core.configuration.file.YamlConfiguration; import com.plotsquared.core.database.DBFunc; +import com.plotsquared.core.events.RemoveRoadEntityEvent; +import com.plotsquared.core.events.Result; import com.plotsquared.core.generator.GeneratorWrapper; import com.plotsquared.core.generator.IndependentPlotGenerator; import com.plotsquared.core.generator.SingleWorldGenerator; @@ -109,6 +111,7 @@ import com.plotsquared.core.uuid.CacheUUIDService; import com.plotsquared.core.uuid.UUIDPipeline; import com.plotsquared.core.uuid.offline.OfflineModeUUIDService; import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.bukkit.BukkitAdapter; import io.papermc.lib.PaperLib; import net.kyori.adventure.audience.Audience; import net.kyori.adventure.text.Component; @@ -810,8 +813,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl if (entity.hasMetadata("ps-tmp-teleport")) { continue; } - iterator.remove(); - entity.remove(); + this.removeRoadEntity(entity, iterator); } continue; } @@ -824,8 +826,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl if (entity.hasMetadata("ps-tmp-teleport")) { continue; } - iterator.remove(); - entity.remove(); + this.removeRoadEntity(entity, iterator); } } continue; @@ -835,7 +836,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl case "DROPPED_ITEM": if (Settings.Enabled_Components.KILL_ROAD_ITEMS && plotArea.getOwnedPlotAbs(BukkitUtil.adapt(entity.getLocation())) == null) { - entity.remove(); + this.removeRoadEntity(entity, iterator); } // dropped item continue; @@ -866,8 +867,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl if (entity.hasMetadata("ps-tmp-teleport")) { continue; } - iterator.remove(); - entity.remove(); + this.removeRoadEntity(entity, iterator); } } } @@ -972,8 +972,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl if (entity.hasMetadata("ps-tmp-teleport")) { continue; } - iterator.remove(); - entity.remove(); + this.removeRoadEntity(entity, iterator); } } } else { @@ -984,8 +983,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl if (entity.hasMetadata("ps-tmp-teleport")) { continue; } - iterator.remove(); - entity.remove(); + this.removeRoadEntity(entity, iterator); } } } @@ -999,6 +997,17 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl }), TaskTime.seconds(1L)); } + private void removeRoadEntity(Entity entity, Iterator entityIterator) { + RemoveRoadEntityEvent event = eventDispatcher.callRemoveRoadEntity(BukkitAdapter.adapt(entity)); + + if (event.getEventResult() == Result.DENY) { + return; + } + + entityIterator.remove(); + entity.remove(); + } + @Override public @Nullable final ChunkGenerator getDefaultWorldGenerator( diff --git a/Core/src/main/java/com/plotsquared/core/events/EntityEvent.java b/Core/src/main/java/com/plotsquared/core/events/EntityEvent.java new file mode 100644 index 000000000..5642342b6 --- /dev/null +++ b/Core/src/main/java/com/plotsquared/core/events/EntityEvent.java @@ -0,0 +1,63 @@ +/* + * PlotSquared, a land and world management plugin for Minecraft. + * Copyright (C) IntellectualSites + * Copyright (C) IntellectualSites team and contributors + * + * 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.core.events; + +import com.sk89q.worldedit.entity.Entity; +import org.checkerframework.checker.nullness.qual.NonNull; + +/** + * @since TODO + */ +public abstract class EntityEvent { + + private final Entity entity; + + private String name; + + /** + * @since TODO + */ + public EntityEvent(Entity entity) { + this.entity = entity; + } + + /** + * Obtain the entity involved in the event + * + * @return Entity + * @since TODO + */ + public Entity getEntity() { + return this.entity; + } + + /** + * Obtain the event's class name + * + * @return the event class name + * @since TODO + */ + @NonNull public String getEventName() { + if (this.name == null) { + this.name = this.getClass().getSimpleName(); + } + return this.name; + } + +} diff --git a/Core/src/main/java/com/plotsquared/core/events/RemoveRoadEntityEvent.java b/Core/src/main/java/com/plotsquared/core/events/RemoveRoadEntityEvent.java new file mode 100644 index 000000000..aa7155cc7 --- /dev/null +++ b/Core/src/main/java/com/plotsquared/core/events/RemoveRoadEntityEvent.java @@ -0,0 +1,50 @@ +/* + * PlotSquared, a land and world management plugin for Minecraft. + * Copyright (C) IntellectualSites + * Copyright (C) IntellectualSites team and contributors + * + * 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.core.events; + +import com.sk89q.worldedit.entity.Entity; + +/** + * @since TODO + */ +public class RemoveRoadEntityEvent extends EntityEvent implements CancellablePlotEvent { + + private Result eventResult; + + /** + * RemoveRoadEntityEvent: Called when an entity on road is removed. + * + * @param entity The entity to remove + * @since TODO + */ + public RemoveRoadEntityEvent(Entity entity) { + super(entity); + } + + @Override + public Result getEventResult() { + return this.eventResult; + } + + @Override + public void setEventResult(Result eventResult) { + this.eventResult = eventResult; + } + +} diff --git a/Core/src/main/java/com/plotsquared/core/util/EventDispatcher.java b/Core/src/main/java/com/plotsquared/core/util/EventDispatcher.java index 9318cccd0..f935c50f7 100644 --- a/Core/src/main/java/com/plotsquared/core/util/EventDispatcher.java +++ b/Core/src/main/java/com/plotsquared/core/util/EventDispatcher.java @@ -45,6 +45,7 @@ import com.plotsquared.core.events.PlotFlagRemoveEvent; import com.plotsquared.core.events.PlotMergeEvent; import com.plotsquared.core.events.PlotRateEvent; import com.plotsquared.core.events.PlotUnlinkEvent; +import com.plotsquared.core.events.RemoveRoadEntityEvent; import com.plotsquared.core.events.TeleportCause; import com.plotsquared.core.events.post.PostPlayerAutoPlotEvent; import com.plotsquared.core.events.post.PostPlotChangeOwnerEvent; @@ -71,6 +72,7 @@ import com.plotsquared.core.plot.flag.types.BlockTypeWrapper; import com.plotsquared.core.plot.world.SinglePlotArea; import com.plotsquared.core.util.task.TaskManager; import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; @@ -296,6 +298,12 @@ public class EventDispatcher { return event; } + public RemoveRoadEntityEvent callRemoveRoadEntity(Entity entity) { + RemoveRoadEntityEvent event = new RemoveRoadEntityEvent(entity); + eventBus.post(event); + return event; + } + public void doJoinTask(final PlotPlayer player) { if (player == null) { return; //possible future warning message to figure out where we are retrieving null