diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java index 012fee6ff..079d04fe3 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java @@ -44,6 +44,7 @@ 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.DoneFlag; +import com.plotsquared.core.plot.flag.implementations.ProjectilesFlag; import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.util.Permissions; import net.kyori.adventure.text.minimessage.Template; @@ -352,13 +353,15 @@ public class PaperListener implements Listener { event.setCancelled(true); } } else if (!plot.isAdded(pp.getUUID())) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) { - pp.sendMessage( - TranslatableCaption.of("permission.no_permission_event"), - Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) - ); - entity.remove(); - event.setCancelled(true); + if (!plot.getFlag(ProjectilesFlag.class)) { + if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) { + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) + ); + entity.remove(); + event.setCancelled(true); + } } } } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ProjectileEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ProjectileEventListener.java index 8754c4520..a09cf6943 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ProjectileEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ProjectileEventListener.java @@ -35,6 +35,7 @@ import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotHandler; +import com.plotsquared.core.plot.flag.implementations.ProjectilesFlag; import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.util.Permissions; import net.kyori.adventure.text.minimessage.Template; @@ -128,13 +129,15 @@ public class ProjectileEventListener implements Listener { event.setCancelled(true); } } else if (!plot.isAdded(pp.getUUID())) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) { - pp.sendMessage( - TranslatableCaption.of("permission.no_permission_event"), - Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) - ); - entity.remove(); - event.setCancelled(true); + if (!plot.getFlag(ProjectilesFlag.class)) { + if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) { + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) + ); + entity.remove(); + event.setCancelled(true); + } } } } @@ -162,7 +165,7 @@ public class ProjectileEventListener implements Listener { return; } if (plot.isAdded(pp.getUUID()) || Permissions - .hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) { + .hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER) || plot.getFlag(ProjectilesFlag.class)) { return; } entity.remove(); 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 3b7c572d7..052086464 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.PlayerInteractFlag; import com.plotsquared.core.plot.flag.implementations.PlotTitleFlag; import com.plotsquared.core.plot.flag.implementations.PreventCreativeCopyFlag; import com.plotsquared.core.plot.flag.implementations.PriceFlag; +import com.plotsquared.core.plot.flag.implementations.ProjectilesFlag; import com.plotsquared.core.plot.flag.implementations.PveFlag; import com.plotsquared.core.plot.flag.implementations.PvpFlag; import com.plotsquared.core.plot.flag.implementations.RedstoneFlag; @@ -198,6 +199,7 @@ public final class GlobalFlagContainer extends FlagContainer { this.addFlag(VehicleUseFlag.VEHICLE_USE_FALSE); this.addFlag(VillagerInteractFlag.VILLAGER_INTERACT_FALSE); this.addFlag(VineGrowFlag.VINE_GROW_TRUE); + this.addFlag(ProjectilesFlag.PROJECTILES_FALSE); // Double flags this.addFlag(PriceFlag.PRICE_NOT_BUYABLE); diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/ProjectilesFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/ProjectilesFlag.java new file mode 100644 index 000000000..a8953b084 --- /dev/null +++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/ProjectilesFlag.java @@ -0,0 +1,46 @@ +/* + * _____ _ _ _____ _ + * | __ \| | | | / ____| | | + * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| | + * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` | + * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| | + * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_| + * | | + * |_| + * PlotSquared plot management system for Minecraft + * Copyright (C) 2014 - 2022 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.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 ProjectilesFlag extends BooleanFlag { + + public static final ProjectilesFlag PROJECTILES_TRUE = new ProjectilesFlag(true); + public static final ProjectilesFlag PROJECTILES_FALSE = new ProjectilesFlag(false); + + private ProjectilesFlag(boolean value){ + super(value, TranslatableCaption.of("flags.flag_description_projectiles")); + } + + @Override + protected ProjectilesFlag flagOf(@NonNull final Boolean value) { + return value ? PROJECTILES_TRUE : PROJECTILES_FALSE; + } + +} diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json index 50b3639df..bc189c8c9 100644 --- a/Core/src/main/resources/lang/messages_en.json +++ b/Core/src/main/resources/lang/messages_en.json @@ -613,6 +613,7 @@ "flags.flag_description_lectern_read_book": "Prevent players taking books from lecterns.", "flags.flag_description_prevent_creative_copy": "Prevents people from copying item NBT data in the plot unless they're added as members.", "flags.flag_description_leaf_decay": "Set to `false` to prevent leaves from decaying.", + "flags.flag_description_projectiles": "Prevents guests from shooting projectiles on the plot when set to false.", "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/build.gradle.kts b/build.gradle.kts index c21177f5f..2e6b65b31 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -18,7 +18,7 @@ plugins { idea } -version = "6.6.4-SNAPSHOT" +version = "6.7.1-SNAPSHOT" allprojects { group = "com.plotsquared" @@ -140,7 +140,7 @@ allprojects { } developer { id.set("NotMyFault") - name.set("NotMyFault") + name.set("Alexander Brandes") organization.set("IntellectualSites") email.set("contact@notmyfault.dev") } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 537d3fb41..e62f8bcde 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -6,7 +6,7 @@ guava = "31.0.1-jre" # Version set by Minecraft # Platform expectations paper = "1.18.1-R0.1-SNAPSHOT" -checker-qual = "3.21.4" +checker-qual = "3.22.0" guice = "5.1.0" spotbugs = "4.6.0" snakeyaml = "1.30" # Version set by Bukkit