mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 15:16:45 +01:00
Port integer flags
This commit is contained in:
parent
867948097d
commit
aa64d7b135
@ -547,6 +547,7 @@ public enum Captions implements Caption {
|
|||||||
FLAG_CATEGORY_MIXED("Mixed Value Flags", "Flags"),
|
FLAG_CATEGORY_MIXED("Mixed Value Flags", "Flags"),
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
//<editor-fold desc="Flag descriptions">
|
//<editor-fold desc="Flag descriptions">
|
||||||
|
FLAG_DESCRIPTION_ENTITY_CAP("Set to an integer value to limit the amount of entities on the plot.", "Flags"),
|
||||||
FLAG_DESCRIPTION_EXPLOSION("Set to 'true' to enable explosions in the plot, and 'false' to disable them.", "Flags"),
|
FLAG_DESCRIPTION_EXPLOSION("Set to 'true' to enable explosions in the plot, and 'false' to disable them.", "Flags"),
|
||||||
FLAG_DESCRIPTION_MUSIC("Set to a music disk ID (item name) to play the music disc inside of the plot.", "Flags"),
|
FLAG_DESCRIPTION_MUSIC("Set to a music disk ID (item name) to play the music disc inside of the plot.", "Flags"),
|
||||||
FLAG_DESCRIPTION_FLIGHT("Set to 'true' to enable flight within the plot when in survival or adventure mode.", "Flags"),
|
FLAG_DESCRIPTION_FLIGHT("Set to 'true' to enable flight within the plot when in survival or adventure mode.", "Flags"),
|
||||||
@ -557,6 +558,7 @@ public enum Captions implements Caption {
|
|||||||
FLAG_DESCRIPTION_FAREWELL("Message sent to players when leaving the plot. Supports '&' color codes.", "Flags"),
|
FLAG_DESCRIPTION_FAREWELL("Message sent to players when leaving the plot. Supports '&' color codes.", "Flags"),
|
||||||
FLAG_DESCRIPTION_WEATHER("Specifies the weather conditions inside of the plot.", "Flags"),
|
FLAG_DESCRIPTION_WEATHER("Specifies the weather conditions inside of the plot.", "Flags"),
|
||||||
FLAG_DESCRIPTION_ANIMAL_ATTACK("Set to `true` to allow animals to be attacked in the plot.", "Flags"),
|
FLAG_DESCRIPTION_ANIMAL_ATTACK("Set to `true` to allow animals to be attacked in the plot.", "Flags"),
|
||||||
|
FLAG_DESCRIPTION_ANIMAL_CAP("Set to an integer value to limit the amount of animals on the plot.", "Flags"),
|
||||||
FLAG_DESCRIPTION_ANIMAL_INTERACT("Set to `true` to allow animals to be interacted with in the plot.", "Flags"),
|
FLAG_DESCRIPTION_ANIMAL_INTERACT("Set to `true` to allow animals to be interacted with in the plot.", "Flags"),
|
||||||
FLAG_DESCRIPTION_BLOCK_BURN("Set to `true` to allow blocks to burn within the plot.", "Flags"),
|
FLAG_DESCRIPTION_BLOCK_BURN("Set to `true` to allow blocks to burn within the plot.", "Flags"),
|
||||||
FLAG_DESCRIPTION_BLOCK_IGNITION("Set to `true` to allow blocks to ignite within the plot.", "Flags"),
|
FLAG_DESCRIPTION_BLOCK_IGNITION("Set to `true` to allow blocks to ignite within the plot.", "Flags"),
|
||||||
@ -569,6 +571,7 @@ public enum Captions implements Caption {
|
|||||||
FLAG_DESCRIPTION_HANGING_PLACE("Set to `true` to allow guests to hang objects in the plot.", "Flags"),
|
FLAG_DESCRIPTION_HANGING_PLACE("Set to `true` to allow guests to hang objects in the plot.", "Flags"),
|
||||||
FLAG_DESCRIPTION_HIDE_INFO("Set to `true` to hide plot information.", "Flags"),
|
FLAG_DESCRIPTION_HIDE_INFO("Set to `true` to hide plot information.", "Flags"),
|
||||||
FLAG_DESCRIPTION_HOSTILE_ATTACK("Set to `true` to enable players to attack hostile mobs in the plot.", "Flags"),
|
FLAG_DESCRIPTION_HOSTILE_ATTACK("Set to `true` to enable players to attack hostile mobs in the plot.", "Flags"),
|
||||||
|
FLAG_DESCRIPTION_HOSTILE_CAP("Set to an integer value to limit the amount of hostile entities on the plot.", "Flags"),
|
||||||
FLAG_DESCRIPTION_HOSTILE_INTERACT("Set to `true` to allow players to interact with hostile mobs in the plot.", "Flags"),
|
FLAG_DESCRIPTION_HOSTILE_INTERACT("Set to `true` to allow players to interact with hostile mobs in the plot.", "Flags"),
|
||||||
FLAG_DESCRIPTION_ICE_FORM("Set to `true` to allow ice to form in the plot.", "Flags"),
|
FLAG_DESCRIPTION_ICE_FORM("Set to `true` to allow ice to form in the plot.", "Flags"),
|
||||||
FLAG_DESCRIPTION_ICE_MELT("Set to `true` to allow ice to melt in the plot.", "Flags"),
|
FLAG_DESCRIPTION_ICE_MELT("Set to `true` to allow ice to melt in the plot.", "Flags"),
|
||||||
@ -578,9 +581,11 @@ public enum Captions implements Caption {
|
|||||||
FLAG_DESCRIPTION_KELP_GROW("Set to `true` to allow kelp to grow in the plot.", "Flags"),
|
FLAG_DESCRIPTION_KELP_GROW("Set to `true` to allow kelp to grow in the plot.", "Flags"),
|
||||||
FLAG_DESCRIPTION_LIQUID_FLOW("Set to `false` to disable liquids from flowing within the plot.", "Flags"),
|
FLAG_DESCRIPTION_LIQUID_FLOW("Set to `false` to disable liquids from flowing within the plot.", "Flags"),
|
||||||
FLAG_DESCRIPTION_MISC_BREAK("Set to `true` to allow guests to break miscellaneous items.", "Flags"),
|
FLAG_DESCRIPTION_MISC_BREAK("Set to `true` to allow guests to break miscellaneous items.", "Flags"),
|
||||||
|
FLAG_DESCRIPTION_MISC_CAP("Set to an integer value to limit the amount of miscellaneous entities on the plot.", "Flags"),
|
||||||
FLAG_DESCRIPTION_MISC_INTERACT("Set to `true` to allow guests to interact with miscellaneous items.", "Flags"),
|
FLAG_DESCRIPTION_MISC_INTERACT("Set to `true` to allow guests to interact with miscellaneous items.", "Flags"),
|
||||||
FLAG_DESCRIPTION_MISC_PLACE("Set to `true` to allow guests to place miscellaneous items.", "Flags"),
|
FLAG_DESCRIPTION_MISC_PLACE("Set to `true` to allow guests to place miscellaneous items.", "Flags"),
|
||||||
FLAG_DESCRIPTION_MOB_BREAK("Set to `true` to allow mobs to break blocks within the plot.", "Flags"),
|
FLAG_DESCRIPTION_MOB_BREAK("Set to `true` to allow mobs to break blocks within the plot.", "Flags"),
|
||||||
|
FLAG_DESCRIPTION_MOB_CAP("Set to an integer value to limit the amount of mobs on the plot.", "Flags"),
|
||||||
FLAG_DESCRIPTION_MOB_PLACE("Set to `true` to allow mobs to place blocks within the plot.", "Flags"),
|
FLAG_DESCRIPTION_MOB_PLACE("Set to `true` to allow mobs to place blocks within the plot.", "Flags"),
|
||||||
FLAG_DESCRIPTION_MYCEL_GROW("Set to `true` to allow mycelium to grow in the plot.", "Flags"),
|
FLAG_DESCRIPTION_MYCEL_GROW("Set to `true` to allow mycelium to grow in the plot.", "Flags"),
|
||||||
FLAG_DESCRIPTION_NOTIFY_ENTER("Set to `true` to notify the plot owners when someone enters the plot.", "Flags"),
|
FLAG_DESCRIPTION_NOTIFY_ENTER("Set to `true` to notify the plot owners when someone enters the plot.", "Flags"),
|
||||||
@ -598,6 +603,7 @@ public enum Captions implements Caption {
|
|||||||
FLAG_DESCRIPTION_TAMED_INTERACT("Set to `true` to allow guests to interact with 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_TITLES("Set to `false` to disable plot titles.", "Flags"),
|
FLAG_DESCRIPTION_TITLES("Set to `false` to disable plot titles.", "Flags"),
|
||||||
FLAG_DESCRIPTION_VEHICLE_BREAK("Set to `true` to allow guests to break vehicles in the plot.", "Flags"),
|
FLAG_DESCRIPTION_VEHICLE_BREAK("Set to `true` to allow guests to break vehicles in the plot.", "Flags"),
|
||||||
|
FLAG_DESCRIPTION_VEHICLE_CAP("Set to an integer value to limit the amount of vehicles on the plot.", "Flags"),
|
||||||
FLAG_DESCRIPTION_VEHICLE_PLACE("Set to `true` to allow guests to place vehicles in the plot.", "Flags"),
|
FLAG_DESCRIPTION_VEHICLE_PLACE("Set to `true` to allow guests to place vehicles in the plot.", "Flags"),
|
||||||
FLAG_DESCRIPTION_VEHICLE_USE("Set to `true` to allow guests to use vehicles in the plot.", "Flags"),
|
FLAG_DESCRIPTION_VEHICLE_USE("Set to `true` to allow guests to use vehicles in the plot.", "Flags"),
|
||||||
FLAG_DESCRIPTION_VILLAGER_INTERACT("Set to `true` to allow guests to interact with villagers in the plot.", "Flags"),
|
FLAG_DESCRIPTION_VILLAGER_INTERACT("Set to `true` to allow guests to interact with villagers in the plot.", "Flags"),
|
||||||
|
@ -25,12 +25,6 @@ public final class Flags {
|
|||||||
public static final BlockStateListFlag USE = new BlockStateListFlag("use");
|
public static final BlockStateListFlag USE = new BlockStateListFlag("use");
|
||||||
public static final BlockStateListFlag BREAK = new BlockStateListFlag("break");
|
public static final BlockStateListFlag BREAK = new BlockStateListFlag("break");
|
||||||
public static final BlockStateListFlag PLACE = new BlockStateListFlag("place");
|
public static final BlockStateListFlag PLACE = new BlockStateListFlag("place");
|
||||||
public static final IntegerFlag MISC_CAP = new IntegerFlag("misc-cap");
|
|
||||||
public static final IntegerFlag ENTITY_CAP = new IntegerFlag("entity-cap");
|
|
||||||
public static final IntegerFlag MOB_CAP = new IntegerFlag("mob-cap");
|
|
||||||
public static final IntegerFlag ANIMAL_CAP = new IntegerFlag("animal-cap");
|
|
||||||
public static final IntegerFlag HOSTILE_CAP = new IntegerFlag("hostile-cap");
|
|
||||||
public static final IntegerFlag VEHICLE_CAP = new IntegerFlag("vehicle-cap");
|
|
||||||
public static final Flag<?> KEEP = new Flag(Captions.FLAG_CATEGORY_MIXED, "keep") {
|
public static final Flag<?> KEEP = new Flag(Captions.FLAG_CATEGORY_MIXED, "keep") {
|
||||||
@Override public String valueToString(Object value) {
|
@Override public String valueToString(Object value) {
|
||||||
return value.toString();
|
return value.toString();
|
||||||
|
@ -2,6 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.flags;
|
|||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnalysisFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnalysisFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnimalAttackFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnimalAttackFlag;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnimalCapFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnimalInteractFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnimalInteractFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BlockBurnFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BlockBurnFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BlockIgnitionFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BlockIgnitionFlag;
|
||||||
@ -11,6 +12,7 @@ import com.github.intellectualsites.plotsquared.plot.flags.implementations.Devic
|
|||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DisablePhysicsFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DisablePhysicsFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DropProtectionFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DropProtectionFlag;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.EntityCapFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.ExplosionFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.ExplosionFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.FarewellFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.FarewellFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.FlightFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.FlightFlag;
|
||||||
@ -21,6 +23,7 @@ import com.github.intellectualsites.plotsquared.plot.flags.implementations.Hangi
|
|||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HangingPlaceFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HangingPlaceFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HideInfoFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HideInfoFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HostileAttackFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HostileAttackFlag;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HostileCapFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HostileInteractFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.HostileInteractFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.IceFormFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.IceFormFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.IceMeltFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.IceMeltFlag;
|
||||||
@ -30,7 +33,9 @@ import com.github.intellectualsites.plotsquared.plot.flags.implementations.ItemD
|
|||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.KelpGrowFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.KelpGrowFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.LiquidFlowFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.LiquidFlowFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MiscBreakFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MiscBreakFlag;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MiscCapFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MobBreakFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MobBreakFlag;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MobCapFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MobPlaceFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MobPlaceFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MusicFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MusicFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MycelGrowFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MycelGrowFlag;
|
||||||
@ -51,6 +56,7 @@ import com.github.intellectualsites.plotsquared.plot.flags.implementations.Tamed
|
|||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.TitlesFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.TitlesFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.UntrustedVisitFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.UntrustedVisitFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehicleBreakFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehicleBreakFlag;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehicleCapFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehicleUseFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehicleUseFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VillagerInteractFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VillagerInteractFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VineGrowFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VineGrowFlag;
|
||||||
@ -74,6 +80,7 @@ public final class GlobalFlagContainer extends FlagContainer {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Register all default flags here
|
// Register all default flags here
|
||||||
|
// Boolean flags
|
||||||
this.addFlag(ExplosionFlag.EXPLOSION_FALSE);
|
this.addFlag(ExplosionFlag.EXPLOSION_FALSE);
|
||||||
this.addFlag(MusicFlag.MUSIC_FLAG_NONE);
|
this.addFlag(MusicFlag.MUSIC_FLAG_NONE);
|
||||||
this.addFlag(FlightFlag.FLIGHT_FLAG_FALSE);
|
this.addFlag(FlightFlag.FLIGHT_FLAG_FALSE);
|
||||||
@ -127,6 +134,14 @@ public final class GlobalFlagContainer extends FlagContainer {
|
|||||||
this.addFlag(InstabreakFlag.INSTABREAK_FALSE);
|
this.addFlag(InstabreakFlag.INSTABREAK_FALSE);
|
||||||
this.addFlag(InvincibleFlag.INVINCIBLE_FALSE);
|
this.addFlag(InvincibleFlag.INVINCIBLE_FALSE);
|
||||||
|
|
||||||
|
//Integer flags
|
||||||
|
this.addFlag(AnimalCapFlag.ANIMAL_CAP_UNLIMITED);
|
||||||
|
this.addFlag(EntityCapFlag.ENTITY_CAP_UNLIMITED);
|
||||||
|
this.addFlag(HostileCapFlag.HOSTILE_CAP_UNLIMITED);
|
||||||
|
this.addFlag(MiscCapFlag.MISC_CAP_UNLIMITED);
|
||||||
|
this.addFlag(MobCapFlag.MOB_CAP_UNLIMITED);
|
||||||
|
this.addFlag(VehicleCapFlag.VEHICLE_CAP_UNLIMITED);
|
||||||
|
|
||||||
// Internal flags
|
// Internal flags
|
||||||
this.addFlag(new AnalysisFlag(Collections.emptyList()));
|
this.addFlag(new AnalysisFlag(Collections.emptyList()));
|
||||||
this.addFlag(new DoneFlag(""));
|
this.addFlag(new DoneFlag(""));
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.flags.implementations;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.types.NonNegativeIntegerFlag;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class AnimalCapFlag extends NonNegativeIntegerFlag<AnimalCapFlag> {
|
||||||
|
public static final AnimalCapFlag ANIMAL_CAP_UNLIMITED = new AnimalCapFlag(Integer.MAX_VALUE);
|
||||||
|
|
||||||
|
protected AnimalCapFlag(int value) {
|
||||||
|
super(value, Captions.FLAG_DESCRIPTION_ANIMAL_CAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override protected AnimalCapFlag flagOf(@NotNull Integer value) {
|
||||||
|
return new AnimalCapFlag(value);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.flags.implementations;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.types.NonNegativeIntegerFlag;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class EntityCapFlag extends NonNegativeIntegerFlag<EntityCapFlag> {
|
||||||
|
public static final EntityCapFlag ENTITY_CAP_UNLIMITED = new EntityCapFlag(Integer.MAX_VALUE);
|
||||||
|
|
||||||
|
protected EntityCapFlag(int value) {
|
||||||
|
super(value, Captions.FLAG_DESCRIPTION_ENTITY_CAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override protected EntityCapFlag flagOf(@NotNull Integer value) {
|
||||||
|
return new EntityCapFlag(value);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.flags.implementations;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.types.NonNegativeIntegerFlag;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class HostileCapFlag extends NonNegativeIntegerFlag<HostileCapFlag> {
|
||||||
|
public static final HostileCapFlag HOSTILE_CAP_UNLIMITED = new HostileCapFlag(Integer.MAX_VALUE);
|
||||||
|
|
||||||
|
protected HostileCapFlag(int value) {
|
||||||
|
super(value, Captions.FLAG_DESCRIPTION_HOSTILE_CAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override protected HostileCapFlag flagOf(@NotNull Integer value) {
|
||||||
|
return new HostileCapFlag(value);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.flags.implementations;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.types.NonNegativeIntegerFlag;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class MiscCapFlag extends NonNegativeIntegerFlag<MiscCapFlag> {
|
||||||
|
public static final MiscCapFlag MISC_CAP_UNLIMITED = new MiscCapFlag(Integer.MAX_VALUE);
|
||||||
|
|
||||||
|
protected MiscCapFlag(int value) {
|
||||||
|
super(value, Captions.FLAG_DESCRIPTION_MISC_CAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override protected MiscCapFlag flagOf(@NotNull Integer value) {
|
||||||
|
return new MiscCapFlag(value);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.flags.implementations;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.types.NonNegativeIntegerFlag;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class MobCapFlag extends NonNegativeIntegerFlag<MobCapFlag> {
|
||||||
|
public static final MobCapFlag MOB_CAP_UNLIMITED = new MobCapFlag(Integer.MAX_VALUE);
|
||||||
|
|
||||||
|
protected MobCapFlag(int value) {
|
||||||
|
super(value, Captions.FLAG_DESCRIPTION_MOB_CAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override protected MobCapFlag flagOf(@NotNull Integer value) {
|
||||||
|
return new MobCapFlag(value);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.flags.implementations;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.types.NonNegativeIntegerFlag;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class VehicleCapFlag extends NonNegativeIntegerFlag<VehicleCapFlag> {
|
||||||
|
public static final VehicleCapFlag VEHICLE_CAP_UNLIMITED = new VehicleCapFlag(Integer.MAX_VALUE);
|
||||||
|
|
||||||
|
protected VehicleCapFlag(int value) {
|
||||||
|
super(value, Captions.FLAG_DESCRIPTION_VEHICLE_CAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override protected VehicleCapFlag flagOf(@NotNull Integer value) {
|
||||||
|
return new VehicleCapFlag(value);
|
||||||
|
}
|
||||||
|
}
|
@ -7,21 +7,34 @@ import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public abstract class IntegerFlag<F extends PlotFlag<Integer, F>> extends PlotFlag<Integer, F> {
|
public abstract class IntegerFlag<F extends PlotFlag<Integer, F>> extends PlotFlag<Integer, F> {
|
||||||
|
private final int minimum;
|
||||||
|
private final int maximum;
|
||||||
|
|
||||||
protected IntegerFlag(final int value, @NotNull Caption flagDescription) {
|
protected IntegerFlag(final int value, int minimum, int maximum, @NotNull Caption flagDescription) {
|
||||||
super(value, Captions.FLAG_CATEGORY_INTEGERS, flagDescription);
|
super(value, Captions.FLAG_CATEGORY_INTEGERS, flagDescription);
|
||||||
|
if (maximum < minimum) {
|
||||||
|
throw new IllegalArgumentException("Maximum may not be less than minimum:" + maximum + " < " + minimum);
|
||||||
|
}
|
||||||
|
this.minimum = minimum;
|
||||||
|
this.maximum = maximum;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IntegerFlag(@NotNull Caption flagDescription) {
|
protected IntegerFlag(@NotNull Caption flagDescription) {
|
||||||
this(0, flagDescription);
|
this(0, Integer.MIN_VALUE, Integer.MAX_VALUE, flagDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public F parse(@NotNull String input) throws FlagParseException {
|
@Override public F parse(@NotNull String input) throws FlagParseException {
|
||||||
|
int parsed;
|
||||||
try {
|
try {
|
||||||
return flagOf(Integer.parseInt(input));
|
parsed = Integer.parseInt(input);
|
||||||
} catch (final Throwable throwable) {
|
} catch (final Throwable throwable) {
|
||||||
throw new FlagParseException(this, input, Captions.FLAG_ERROR_INTEGER);
|
throw new FlagParseException(this, input, Captions.FLAG_ERROR_INTEGER);
|
||||||
}
|
}
|
||||||
|
if (parsed < minimum || parsed > maximum) {
|
||||||
|
throw new FlagParseException(this, input, Captions.NOT_VALID_NUMBER); // TODO format Caption, provide valid range
|
||||||
|
}
|
||||||
|
return flagOf(parsed);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public F merge(@NotNull Integer newValue) {
|
@Override public F merge(@NotNull Integer newValue) {
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.flags.types;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.config.Caption;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public abstract class NonNegativeIntegerFlag<F extends IntegerFlag<F>> extends IntegerFlag<F> {
|
||||||
|
|
||||||
|
protected NonNegativeIntegerFlag(int value, @NotNull Caption flagDescription) {
|
||||||
|
super(value, 0, Integer.MAX_VALUE, flagDescription);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NonNegativeIntegerFlag(int value, int maximum, @NotNull Caption flagDescription) {
|
||||||
|
super(value, 0, maximum, flagDescription);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user