From 3a3a06631d45f108e8fe5d1d4e71439537121b6f Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Wed, 25 Mar 2020 21:14:58 +0100 Subject: [PATCH] Add coral-dry flag --- .../bukkit/listeners/PlayerEvents.java | 19 ++++++++++++++++++ .../plotsquared/plot/config/Captions.java | 1 + .../plot/flags/GlobalFlagContainer.java | 2 ++ .../flags/implementations/CoralDryFlag.java | 20 +++++++++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/CoralDryFlag.java diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java index 93738cda0..c3f04a5e2 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java @@ -1414,6 +1414,25 @@ public class PlayerEvents extends PlotListener implements Listener { event.setCancelled(true); } break; + case TUBE_CORAL_BLOCK: + case BRAIN_CORAL_BLOCK: + case BUBBLE_CORAL_BLOCK: + case FIRE_CORAL_BLOCK: + case DEAD_HORN_CORAL_BLOCK: + case TUBE_CORAL: + case BRAIN_CORAL: + case BUBBLE_CORAL: + case FIRE_CORAL: + case HORN_CORAL: + case TUBE_CORAL_FAN: + case BRAIN_CORAL_FAN: + case BUBBLE_CORAL_FAN: + case FIRE_CORAL_FAN: + case HORN_CORAL_FAN: + if (!plot.getFlag(CoralDryFlag.class)) { + event.setCancelled(true); + } + break; } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java index 7ba027a29..9e7fa737b 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java @@ -627,6 +627,7 @@ public enum Captions implements Caption { FLAG_DESCRIPTION_SNOW_FORM("Set to `true` to allow snow to form within the plot.", "Flags"), FLAG_DESCRIPTION_SNOW_MELT("Set to `true` to allow snow to melt within the plot.", "Flags"), FLAG_DESCRIPTION_SOIL_DRY("Set to `true` to allow soil to dry within the plot.", "Flags"), + FLAG_DESCRIPTION_CORAL_DRY("Set to `true` to allow coral blocks to dry within the plot.", "Flags"), FLAG_DESCRIPTION_TAMED_ATTACK("Set to `true` to allow guests to attack tamed animals in the plot.", "Flags"), FLAG_DESCRIPTION_TAMED_INTERACT("Set to `true` to allow guests to interact with tamed animals in the plot.", "Flags"), FLAG_DESCRIPTION_TIME("Set the time in the plot to a fixed value.", "Flags"), diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/GlobalFlagContainer.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/GlobalFlagContainer.java index e9d04ca45..5a9223a61 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/GlobalFlagContainer.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/GlobalFlagContainer.java @@ -60,6 +60,7 @@ import com.github.intellectualsites.plotsquared.plot.flags.implementations.Serve import com.github.intellectualsites.plotsquared.plot.flags.implementations.SnowFormFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.SnowMeltFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.SoilDryFlag; +import com.github.intellectualsites.plotsquared.plot.flags.implementations.CoralDryFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.TamedAttackFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.TamedInteractFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.TimeFlag; @@ -134,6 +135,7 @@ public final class GlobalFlagContainer extends FlagContainer { this.addFlag(SnowFormFlag.SNOW_FORM_FALSE); this.addFlag(SnowMeltFlag.SNOW_MELT_TRUE); this.addFlag(SoilDryFlag.SOIL_DRY_FALSE); + this.addFlag(CoralDryFlag.CORAL_DRY_FALSE); this.addFlag(TamedAttackFlag.TAMED_ATTACK_FALSE); this.addFlag(TamedInteractFlag.TAMED_INTERACT_FALSE); this.addFlag(VehicleBreakFlag.VEHICLE_BREAK_FALSE); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/CoralDryFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/CoralDryFlag.java new file mode 100644 index 000000000..a17a2db35 --- /dev/null +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/CoralDryFlag.java @@ -0,0 +1,20 @@ +package com.github.intellectualsites.plotsquared.plot.flags.implementations; + +import com.github.intellectualsites.plotsquared.plot.config.Captions; +import com.github.intellectualsites.plotsquared.plot.flags.types.BooleanFlag; +import org.jetbrains.annotations.NotNull; + +public class CoralDryFlag extends BooleanFlag { + + public static final CoralDryFlag CORAL_DRY_TRUE = new CoralDryFlag(true); + public static final CoralDryFlag CORAL_DRY_FALSE = new CoralDryFlag(false); + + private CoralDryFlag(boolean value) { + super(value, Captions.FLAG_DESCRIPTION_CORAL_DRY); + } + + @Override protected CoralDryFlag flagOf(@NotNull Boolean value) { + return value ? CORAL_DRY_TRUE : CORAL_DRY_FALSE; + } + +} \ No newline at end of file