diff --git a/Bukkit/build.gradle.kts b/Bukkit/build.gradle.kts index f00a912bd0..c8500b73ba 100644 --- a/Bukkit/build.gradle.kts +++ b/Bukkit/build.gradle.kts @@ -109,7 +109,7 @@ tasks { withType { val isRelease = if (rootProject.version.toString().endsWith("-SNAPSHOT")) "TODO" else rootProject.version.toString() val opt = options as StandardJavadocDocletOptions - opt.links("https://jd.papermc.io/paper/1.20.4/") + opt.links("https://jd.papermc.io/paper/1.21.1/") // opt.links("https://docs.enginehub.org/javadoc/com.sk89q.worldedit/worldedit-bukkit/" + libs.worldeditBukkit.get().versionConstraint.toString()) opt.links("https://intellectualsites.github.io/plotsquared-javadocs/core/") // opt.links("https://jd.advntr.dev/api/" + libs.adventureApi.get().versionConstraint.toString()) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java index d60bbe3879..b0263af8de 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java @@ -33,6 +33,7 @@ import com.plotsquared.bukkit.listener.BlockEventListener117; import com.plotsquared.bukkit.listener.ChunkListener; import com.plotsquared.bukkit.listener.EntityEventListener; +import com.plotsquared.bukkit.listener.ProjectileEventListener1211; import com.plotsquared.bukkit.listener.EntitySpawnListener; import com.plotsquared.bukkit.listener.HighFreqBlockEventListener; import com.plotsquared.bukkit.listener.PaperListener; @@ -364,6 +365,9 @@ public void onEnable() { if (Settings.Enabled_Components.EVENTS) { getServer().getPluginManager().registerEvents(injector().getInstance(PlayerEventListener.class), this); + if ((serverVersion()[1] == 21 && serverVersion()[2] >= 1) || serverVersion()[1] > 21) { + getServer().getPluginManager().registerEvents(injector().getInstance(ProjectileEventListener1211.class), this); + } if ((serverVersion()[1] == 20 && serverVersion()[2] >= 1) || serverVersion()[1] > 20) { getServer().getPluginManager().registerEvents(injector().getInstance(PlayerEventListener1201.class), this); } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ProjectileEventListener1211.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ProjectileEventListener1211.java new file mode 100644 index 0000000000..2a1553b95a --- /dev/null +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ProjectileEventListener1211.java @@ -0,0 +1,87 @@ +/* + * 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.bukkit.listener; + +import com.plotsquared.bukkit.util.BukkitUtil; +import com.plotsquared.core.location.Location; +import com.plotsquared.core.player.PlotPlayer; +import com.plotsquared.core.plot.Plot; +import com.plotsquared.core.plot.PlotArea; +import com.plotsquared.core.plot.flag.implementations.WindChargeFlag; +import com.plotsquared.core.util.PlotFlagUtil; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.projectiles.ProjectileSource; + +/** + * For events since 1.21.1 + * @since TODO + */ +public class ProjectileEventListener1211 implements Listener { + + @EventHandler(priority = EventPriority.HIGH) + public void onWindCharge(ProjectileHitEvent event) { + + Projectile entity = event.getEntity(); + if ((entity.getType() != EntityType.WIND_CHARGE) && (entity.getType() != EntityType.BREEZE_WIND_CHARGE)) { + return; + } + + ProjectileSource shooter = entity.getShooter(); + if (!(shooter instanceof Player)) { + return; + } + Location location = BukkitUtil.adapt(entity.getLocation()); + PlotArea area = location.getPlotArea(); + if (area == null) { + return; + } + PlotPlayer pp = BukkitUtil.adapt((Player) shooter); + Plot plot = location.getOwnedPlot(); + + if (plot == null) { + if (PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, WindChargeFlag.class, false)) { + entity.remove(); + event.setCancelled(true); + } + return; + } + + if (!plot.hasOwner()) { + entity.remove(); + event.setCancelled(true); + return; + } + + if (!plot.isAdded(pp.getUUID())) { + if (!plot.getFlag(WindChargeFlag.class)) { + plot.debug("Could not update blocks by wind charge because wind-charge = false"); + entity.remove(); + event.setCancelled(true); + } + } + + } + +} diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/GlobalFlagContainer.java b/Core/src/main/java/com/plotsquared/core/plot/flag/GlobalFlagContainer.java index 0780493ab3..34917f647e 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/flag/GlobalFlagContainer.java +++ b/Core/src/main/java/com/plotsquared/core/plot/flag/GlobalFlagContainer.java @@ -93,6 +93,7 @@ import com.plotsquared.core.plot.flag.implementations.PriceFlag; import com.plotsquared.core.plot.flag.implementations.ProjectileChangeBlockFlag; import com.plotsquared.core.plot.flag.implementations.ProjectilesFlag; +import com.plotsquared.core.plot.flag.implementations.WindChargeFlag; import com.plotsquared.core.plot.flag.implementations.WeavingDeathPlace; import com.plotsquared.core.plot.flag.implementations.PveFlag; import com.plotsquared.core.plot.flag.implementations.PvpFlag; @@ -210,6 +211,7 @@ private GlobalFlagContainer() { this.addFlag(VillagerInteractFlag.VILLAGER_INTERACT_FALSE); this.addFlag(VineGrowFlag.VINE_GROW_TRUE); this.addFlag(ProjectilesFlag.PROJECTILES_FALSE); + this.addFlag(WindChargeFlag.WIND_CHARGE_FALSE); this.addFlag(WeavingDeathPlace.WEAVING_DEATH_PLACE_FALSE); // Double flags diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/WindChargeFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/WindChargeFlag.java new file mode 100644 index 0000000000..4f3f2cfb21 --- /dev/null +++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/WindChargeFlag.java @@ -0,0 +1,39 @@ +/* + * 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.plot.flag.implementations; + +import com.plotsquared.core.configuration.caption.TranslatableCaption; +import com.plotsquared.core.plot.flag.types.BooleanFlag; +import org.checkerframework.checker.nullness.qual.NonNull; + +public class WindChargeFlag extends BooleanFlag { + + public static final WindChargeFlag WIND_CHARGE_TRUE = new WindChargeFlag(true); + public static final WindChargeFlag WIND_CHARGE_FALSE = new WindChargeFlag(false); + + private WindChargeFlag(boolean value) { + super(value, TranslatableCaption.of("flags.flag_description_windcharge")); + } + + @Override + protected WindChargeFlag flagOf(@NonNull Boolean value) { + return value ? WIND_CHARGE_TRUE : WIND_CHARGE_FALSE; + } + +} diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json index ead61d08fe..615d3eaad5 100644 --- a/Core/src/main/resources/lang/messages_en.json +++ b/Core/src/main/resources/lang/messages_en.json @@ -635,6 +635,7 @@ "flags.flag_description_projectiles": "Prevents guests from shooting projectiles on the plot when set to false.", "flags.flag_description_weaving_death_place": "Set to `false` to prevent spawning of cobwebs by the Weaving status effect on the death of an entity.", "flags.flag_description_beacon_effect": "Enables beacon effects on the plot.", + "flags.flag_description_windcharge": "Enables Wind-Charge interactions on the plot.", "flags.flag_error_boolean": "Flag value must be a boolean (true | false).", "flags.flag_error_enum": "Must be one of: ", "flags.flag_error_integer": "Flag value must be a whole positive number.", diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a0b4e3c97a..342ad17c18 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] # Platform expectations -paper = "1.20.4-R0.1-SNAPSHOT" +paper = "1.21.1-R0.1-SNAPSHOT" guice = "7.0.0" spotbugs = "4.9.8" checkerqual = "3.53.0"