mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Port BreakFlag
This commit is contained in:
parent
bf889fc07c
commit
3bccedd95f
@ -13,6 +13,7 @@ import com.github.intellectualsites.plotsquared.plot.flags.implementations.Anima
|
||||
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.BlockIgnitionFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BreakFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DenyTeleportFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DisablePhysicsFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
|
||||
@ -1127,10 +1128,9 @@ import java.util.regex.Pattern;
|
||||
return;
|
||||
}
|
||||
if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||
Optional<Set<BlockType>> destroy = plot.getFlag(Flags.BREAK);
|
||||
List<BlockType> destroy = plot.getFlag(BreakFlag.class);
|
||||
Block block = event.getBlock();
|
||||
if (destroy.isPresent() && destroy.get()
|
||||
.contains(BukkitAdapter.asBlockType(block.getType()))) {
|
||||
if (destroy.contains(BukkitAdapter.asBlockType(block.getType()))) {
|
||||
return;
|
||||
}
|
||||
if (Permissions
|
||||
@ -1400,10 +1400,9 @@ import java.util.regex.Pattern;
|
||||
}
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||
Optional<Set<BlockType>> destroy = plot.getFlag(Flags.BREAK);
|
||||
List<BlockType> destroy = plot.getFlag(BreakFlag.class);
|
||||
Block block = event.getBlock();
|
||||
if (destroy.isPresent() && destroy.get()
|
||||
.contains(BukkitAdapter.asBlockType(block.getType())) || Permissions
|
||||
if (destroy.contains(BukkitAdapter.asBlockType(block.getType())) || Permissions
|
||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
||||
return;
|
||||
}
|
||||
|
@ -577,6 +577,7 @@ public enum Captions implements Caption {
|
||||
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_IGNITION("Set to `true` to allow blocks to ignite within the plot.", "Flags"),
|
||||
FLAG_DESCRIPTION_BREAK("Define a list of materials players should be able to break even when they aren't added to the plot.", "Flags"),
|
||||
FLAG_DESCRIPTION_DEVICE_INTERACT("Set to `true` to allow devices to be interacted with in the plot.", "Flags"),
|
||||
FLAG_DESCRIPTION_DISABLE_PHYSICS("Set to `true` to disable block physics in the plot.", "Flags"),
|
||||
FLAG_DESCRIPTION_DROP_PROTECTION("Set to `true` to prevent dropped items from being picked up by non-members of the plot.", "Flags"),
|
||||
|
@ -6,6 +6,7 @@ import com.github.intellectualsites.plotsquared.plot.flags.implementations.Anima
|
||||
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.BlockIgnitionFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BreakFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DenyExitFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DenyTeleportFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DescriptionFlag;
|
||||
@ -158,6 +159,10 @@ public final class GlobalFlagContainer extends FlagContainer {
|
||||
// Double flags
|
||||
this.addFlag(PriceFlag.PRICE_NOT_BUYABLE);
|
||||
|
||||
// Block type list flags
|
||||
this.addFlag(BreakFlag.BREAK_NONE);
|
||||
|
||||
|
||||
// Misc
|
||||
this.addFlag(GamemodeFlag.GAMEMODE_FLAG_DEFAULT);
|
||||
this.addFlag(GuestGamemodeFlag.GUEST_GAMEMODE_FLAG_DEFAULT);
|
||||
|
@ -0,0 +1,21 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.flags.implementations;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.types.BlockTypeListFlag;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class BreakFlag extends BlockTypeListFlag<BreakFlag> {
|
||||
public static final BreakFlag BREAK_NONE = new BreakFlag(Collections.emptyList());
|
||||
|
||||
protected BreakFlag(List<BlockType> blockTypeList) {
|
||||
super(blockTypeList, Captions.FLAG_DESCRIPTION_BREAK);
|
||||
}
|
||||
|
||||
@Override protected BreakFlag flagOf(@NotNull List<BlockType> value) {
|
||||
return new BreakFlag(value);
|
||||
}
|
||||
}
|
@ -11,13 +11,13 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockTypeListFlag extends ListFlag<BlockType, BlockTypeListFlag> {
|
||||
public abstract class BlockTypeListFlag<F extends ListFlag<BlockType, F>> extends ListFlag<BlockType, F> {
|
||||
|
||||
public BlockTypeListFlag(List<BlockType> blockTypeList, Caption description) {
|
||||
protected BlockTypeListFlag(List<BlockType> blockTypeList, Caption description) {
|
||||
super(blockTypeList, Captions.FLAG_CATEGORY_BLOCK_LIST, description);
|
||||
}
|
||||
|
||||
@Override public BlockTypeListFlag parse(@NotNull String input) throws FlagParseException {
|
||||
@Override public F parse(@NotNull String input) throws FlagParseException {
|
||||
final List<BlockType> parsedBlocks = new ArrayList<>();
|
||||
final String[] split = input.split(",(?![^\\(\\[]*[\\]\\)])");
|
||||
if (split.length == 0) {
|
||||
@ -38,8 +38,4 @@ public class BlockTypeListFlag extends ListFlag<BlockType, BlockTypeListFlag> {
|
||||
return "air,grass_block";
|
||||
}
|
||||
|
||||
@Override protected BlockTypeListFlag flagOf(@NotNull List<BlockType> value) {
|
||||
return new BlockTypeListFlag(value, getFlagDescription()); // copy the description
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user