diff --git a/src/main/java/com/cjburkey/claimchunk/Utils.java b/src/main/java/com/cjburkey/claimchunk/Utils.java index 5e34b46..ddf5f34 100644 --- a/src/main/java/com/cjburkey/claimchunk/Utils.java +++ b/src/main/java/com/cjburkey/claimchunk/Utils.java @@ -1,19 +1,16 @@ package com.cjburkey.claimchunk; import com.cjburkey.claimchunk.placeholder.ClaimChunkPlaceholders; - import lombok.Getter; - import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.TextComponent; - import org.bukkit.ChatColor; +import org.bukkit.Material; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; - import java.util.AbstractMap; import java.util.HashMap; import java.util.Map; @@ -196,9 +193,20 @@ public static Map getAllFalsePermissionsMap() { return permissionsMap; } + // Should prevent the old enum values from mucking everything up :) + public static @Nullable Material materialFromString(String input) { + // First, try to match based on the new enum values + Material matchedEnum = Material.matchMaterial(input); + if (matchedEnum != null) { + return matchedEnum; + } + + // Otherwise, try the legacy as a fallback + return Material.matchMaterial(input, true); + } + // -- JAVA UTIL -- // - // TODO: TEST???? public static HashMap deepCloneMap(HashMap map, Function cloneFunc) { return map.entrySet().stream() .map( diff --git a/src/main/java/com/cjburkey/claimchunk/config/ClaimChunkWorldProfile.java b/src/main/java/com/cjburkey/claimchunk/config/ClaimChunkWorldProfile.java index 3194199..62f75fa 100644 --- a/src/main/java/com/cjburkey/claimchunk/config/ClaimChunkWorldProfile.java +++ b/src/main/java/com/cjburkey/claimchunk/config/ClaimChunkWorldProfile.java @@ -572,7 +572,7 @@ public void fromCCConfig(@NotNull CCConfig config) { config.getStrList("_.preventAdjacent").stream() .map( blockType -> { - Material material = Material.getMaterial(blockType); + Material material = Utils.materialFromString(blockType); if (material == null) { Utils.warn( "Material type \"%s\" not found when loading from" diff --git a/src/main/java/com/cjburkey/claimchunk/flags/PermFlag.java b/src/main/java/com/cjburkey/claimchunk/flags/PermFlag.java new file mode 100644 index 0000000..077dff1 --- /dev/null +++ b/src/main/java/com/cjburkey/claimchunk/flags/PermFlag.java @@ -0,0 +1,7 @@ +package com.cjburkey.claimchunk.flags; + +public class PermFlag { + + // TODO: INCLUDE BLOCK/ENTITY PROTECTIONS + +} diff --git a/src/main/java/com/cjburkey/claimchunk/flags/PermFlags.java b/src/main/java/com/cjburkey/claimchunk/flags/PermFlags.java new file mode 100644 index 0000000..3c2da85 --- /dev/null +++ b/src/main/java/com/cjburkey/claimchunk/flags/PermFlags.java @@ -0,0 +1,14 @@ +package com.cjburkey.claimchunk.flags; + +import java.io.File; +import java.util.HashMap; + +public class PermFlags { + + private final File flagsFile; + private final HashMap flagMap = new HashMap<>(); + + public PermFlags(File flagsFile) { + this.flagsFile = flagsFile; + } +} diff --git a/src/main/resources/defaultFlags.yml b/src/main/resources/defaultFlags.yml new file mode 100644 index 0000000..fd4f10c --- /dev/null +++ b/src/main/resources/defaultFlags.yml @@ -0,0 +1,58 @@ +# List of flags that players can customize within their claims. + +permissionFlags: + breakBlocks: + # Blocks + - for: BLOCKS # BLOCKS or ENTITIES + type: BREAK # For blocks, can be BREAK, PLACE, INTERACT, or EXPLODE + # If no `include` or `exclude` (cannot be used together, btw) + # is present, the default is to include all blocks/entities. + # If `include` is present, only the provided entities/entity + # classes will be included. + # The opposite is true of `exclude`, which includes all + # default blocks/items and excludes the provided ones. + placeBlocks: + - for: BLOCKS + type: PLACE + interactBlocks: + - for: BLOCKS + type: INTERACT + exclude: ['@REDSTONE', '@DOORS', '@BLOCK_CONTAINERS'] # Handle these separately + redstone: + - for: BLOCKS + type: INTERACT + include: ['@REDSTONE'] + doors: + - for: BLOCKS + type: INTERACT + include: ['@DOORS'] + + # Entities + damageEntities: + - for: ENTITIES + type: DAMAGE + interactEntities: + - for: ENTITIES + type: INTERACT + exclude: ['@VEHICLES'] + vehicles: + - for: ENTITIES + type: INTERACT + include: ['@VEHICLES'] + + # Can also handle both types with one flag + containers: + - for: BLOCKS + type: INTERACT + include: ['@BLOCK_CONTAINERS'] + - for: ENTITIES + type: INTERACT + include: ['@VEHICLE_CONTAINERS'] + + # Explosions + explodeHurt: + - for: ENTITIES + type: EXPLODE + explodeDamage: + - for: BLOCKS + type: EXPLODE