Skip to content

Commit

Permalink
Merge pull request #5548 from TownyAdvanced/separate_unclaimed_zone_i…
Browse files Browse the repository at this point in the history
…gnore_ids_from_wilds_plots

Separate UnclaimedZoneIgnoreIDs from Wilds plots.
  • Loading branch information
Warriorrrr authored Dec 19, 2021
2 parents f06d14a + d868586 commit 9732f4e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/com/palmergames/bukkit/config/ConfigNodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ public enum ConfigNodes {
"# Can players interact with switch blocks listed in the above protection.switch_ids in the wilderness without restriction?"),
UNCLAIMED_ZONE_IGNORE(
"unclaimed.unclaimed_zone_ignore",
"SAPLING,GOLD_ORE,IRON_ORE,COAL_ORE,LOG,LEAVES,LAPIS_ORE,LONG_GRASS,YELLOW_FLOWER,RED_ROSE,BROWN_MUSHROOM,RED_MUSHROOM,TORCH,DIAMOND_ORE,LADDER,RAILS,REDSTONE_ORE,GLOWING_REDSTONE_ORE,CACTUS,CLAY,SUGAR_CANE_BLOCK,PUMPKIN,GLOWSTONE,LOG_2,VINE,NETHER_WARTS,COCOA",
"GOLD_ORE,IRON_ORE,COAL_ORE,COPPER_ORE,REDSTONE_ORE,EMERALD_ORE,LAPIS_ORE,DIAMOND_ORE,DEEPSLATE_COAL_ORE,DEEPSLATE_IRON_ORE,DEEPSLATE_COPPER_ORE,DEEPSLATE_GOLD_ORE,DEEPSLATE_EMERALD_ORE,DEEPSLATE_REDSTONE_ORE,DEEPSLATE_LAPIS_ORE,DEEPSLATE_DIAMOND_ORE,NETHER_GOLD_ORE,NETHER_QUARTZ_ORE,ANCIENT_DEBRIS,OAK_LOG,SPRUCE_LOG,BIRCH_LOG,JUNGLE_LOG,ACACIA_LOG,DARK_OAK_LOG,CRIMSON_STEM,WARPED_STEM,ACACIA_LEAVES,OAK_LEAVES,DARK_OAK_LEAVES,JUNGLE_LEAVES,BIRCH_LEAVES,SPRUCE_LEAVES,CRIMSON_HYPHAE,WARPED_HYPHAE,ACACIA_SAPLING,BAMBOO_SAPLING,BIRCH_SAPLING,DARK_OAK_SAPLING,JUNGLE_SAPLING,OAK_SAPLING,SPRUCE_SAPLING,TALL_GRASS,BROWN_MUSHROOM,RED_MUSHROOM,CACTUS,ALLIUM,AZURE_BLUET,BLUE_ORCHID,CORNFLOWER,DANDELION,LILAC,LILY_OF_THE_VALLEY,ORANGE_TULIP,OXEYE_DAISY,PEONY,PINK_TULIP,POPPY,RED_TULIP,ROSE_BUSH,SUNFLOWER,WHITE_TULIP,WITHER_ROSE,CRIMSON_FUNGUS,LARGE_FERN,TORCH,LADDER,CLAY,PUMPKIN,GLOWSTONE,VINE,NETHER_WART_BLOCK,COCOA",
"",
"# A list of blocks that will bypass the above settings and do not require the towny.wild.* permission node.",
"# These blocks are also used in determining which blocks can be interacted with in Towny Wilds plots in towns."),
Expand Down
6 changes: 5 additions & 1 deletion src/com/palmergames/bukkit/towny/TownySettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ private static void setTownBlockTypes() {
type.put("mapKey", "W");
type.put("itemUseIds", "");
type.put("switchIds", "");
type.put("allowedBlocks", "");
type.put("allowedBlocks", getDefaultWildsblocks());
types.add(new LinkedHashMap<>(type));
type.clear();

Expand Down Expand Up @@ -842,6 +842,10 @@ private static void setTownBlockTypes() {
public static String getDefaultFarmblocks() {
return "BAMBOO,BAMBOO_SAPLING,JUNGLE_LOG,JUNGLE_SAPLING,JUNGLE_LEAVES,OAK_LOG,OAK_SAPLING,OAK_LEAVES,BIRCH_LOG,BIRCH_SAPLING,BIRCH_LEAVES,ACACIA_LOG,ACACIA_SAPLING,ACACIA_LEAVES,DARK_OAK_LOG,DARK_OAK_SAPLING,DARK_OAK_LEAVES,SPRUCE_LOG,SPRUCE_SAPLING,SPRUCE_LEAVES,BEETROOTS,COCOA,CHORUS_PLANT,CHORUS_FLOWER,SWEET_BERRY_BUSH,KELP,SEAGRASS,TALL_SEAGRASS,GRASS,TALL_GRASS,FERN,LARGE_FERN,CARROTS,WHEAT,POTATOES,PUMPKIN,PUMPKIN_STEM,ATTACHED_PUMPKIN_STEM,NETHER_WART,COCOA,VINE,MELON,MELON_STEM,ATTACHED_MELON_STEM,SUGAR_CANE,CACTUS,ALLIUM,AZURE_BLUET,BLUE_ORCHID,CORNFLOWER,DANDELION,LILAC,LILY_OF_THE_VALLEY,ORANGE_TULIP,OXEYE_DAISY,PEONY,PINK_TULIP,POPPY,RED_TULIP,ROSE_BUSH,SUNFLOWER,WHITE_TULIP,WITHER_ROSE,CRIMSON_FUNGUS,CRIMSON_STEM,CRIMSON_HYPHAE,CRIMSON_ROOTS,MUSHROOM_STEM,NETHER_WART_BLOCK,BROWN_MUSHROOM,BROWN_MUSHROOM_BLOCK,RED_MUSHROOM,RED_MUSHROOM_BLOCK,SHROOMLIGHT,WARPED_FUNGUS,WARPED_HYPHAE,WARPED_ROOTS,WARPED_STEM,WARPED_WART_BLOCK,WEEPING_VINES_PLANT,WEEPING_VINES,NETHER_SPROUTS,SHEARS";
}

public static String getDefaultWildsblocks() {
return "GOLD_ORE,IRON_ORE,COAL_ORE,COPPER_ORE,REDSTONE_ORE,EMERALD_ORE,LAPIS_ORE,DIAMOND_ORE,DEEPSLATE_COAL_ORE,DEEPSLATE_IRON_ORE,DEEPSLATE_COPPER_ORE,DEEPSLATE_GOLD_ORE,DEEPSLATE_EMERALD_ORE,DEEPSLATE_REDSTONE_ORE,DEEPSLATE_LAPIS_ORE,DEEPSLATE_DIAMOND_ORE,NETHER_GOLD_ORE,NETHER_QUARTZ_ORE,ANCIENT_DEBRIS,OAK_LOG,SPRUCE_LOG,BIRCH_LOG,JUNGLE_LOG,ACACIA_LOG,DARK_OAK_LOG,CRIMSON_STEM,WARPED_STEM,ACACIA_LEAVES,OAK_LEAVES,DARK_OAK_LEAVES,JUNGLE_LEAVES,BIRCH_LEAVES,SPRUCE_LEAVES,CRIMSON_HYPHAE,WARPED_HYPHAE,ACACIA_SAPLING,BAMBOO_SAPLING,BIRCH_SAPLING,DARK_OAK_SAPLING,JUNGLE_SAPLING,OAK_SAPLING,SPRUCE_SAPLING,TALL_GRASS,BROWN_MUSHROOM,RED_MUSHROOM,CACTUS,ALLIUM,AZURE_BLUET,BLUE_ORCHID,CORNFLOWER,DANDELION,LILAC,LILY_OF_THE_VALLEY,ORANGE_TULIP,OXEYE_DAISY,PEONY,PINK_TULIP,POPPY,RED_TULIP,ROSE_BUSH,SUNFLOWER,WHITE_TULIP,WITHER_ROSE,CRIMSON_FUNGUS,LARGE_FERN,TORCH,LADDER,CLAY,PUMPKIN,GLOWSTONE,VINE,NETHER_WART_BLOCK,COCOA";
}

public static String getKingPrefix(Resident resident) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.palmergames.bukkit.config.CommentedConfiguration;
import com.palmergames.bukkit.config.ConfigNodes;
import com.palmergames.bukkit.towny.Towny;
import com.palmergames.bukkit.towny.TownyMessaging;
import com.palmergames.bukkit.towny.TownySettings;
import com.palmergames.bukkit.towny.event.TownBlockTypeRegisterEvent;
import com.palmergames.bukkit.towny.exceptions.TownyException;
Expand Down Expand Up @@ -111,9 +112,9 @@ private static void applyConfigSettings(Map<String, TownBlockType> newData) {
double tax = parseDouble(type.get("tax").toString());
String mapKey = String.valueOf(type.get("mapKey"));

Set<Material> itemUseIds = loadMaterialList(String.valueOf(type.get("itemUseIds")), name);
Set<Material> switchIds = loadMaterialList(String.valueOf(type.get("switchIds")), name);
Set<Material> allowedBlocks = loadMaterialList(String.valueOf(type.get("allowedBlocks")), name);
Set<Material> itemUseIds = loadMaterialList("itemUseIds", String.valueOf(type.get("itemUseIds")), name);
Set<Material> switchIds = loadMaterialList("switchIds", String.valueOf(type.get("switchIds")), name);
Set<Material> allowedBlocks = loadMaterialList("allowedBlocks", String.valueOf(type.get("allowedBlocks")), name);

TownBlockType townBlockType = newData.get(name.toLowerCase());
TownBlockData data;
Expand All @@ -140,14 +141,14 @@ private static void applyConfigSettings(Map<String, TownBlockType> newData) {
}
}

private static Set<Material> loadMaterialList(String materialList, String typeName) {
private static Set<Material> loadMaterialList(String listName, String materialList, String typeName) {
if (!materialList.isEmpty()) {
Set<Material> set = new LinkedHashSet<>();
for (String materialName : materialList.split(",")) {
Material material = Material.matchMaterial(materialName);

if (material == null)
Towny.getPlugin().getLogger().warning(String.format("Could not find a material named '%s' while loading the item use list for the %s type.", materialName, typeName));
TownyMessaging.sendDebugMsg(String.format("Could not find a material named '%s' while loading the " + listName + " list for the %s type.", materialName, typeName));
else
set.add(material);
}
Expand Down
4 changes: 0 additions & 4 deletions src/com/palmergames/bukkit/towny/utils/PlayerCacheUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import com.palmergames.bukkit.towny.object.Resident;
import com.palmergames.bukkit.towny.object.Town;
import com.palmergames.bukkit.towny.object.TownBlock;
import com.palmergames.bukkit.towny.object.TownBlockType;
import com.palmergames.bukkit.towny.object.TownyPermission;
import com.palmergames.bukkit.towny.object.TownyPermission.ActionType;
import com.palmergames.bukkit.towny.object.Translatable;
Expand Down Expand Up @@ -580,9 +579,6 @@ private static boolean getPermission(Player player, TownBlockStatus status, Worl
* @return True if this material is allowed in this townblock.
*/
private static boolean isAllowedMaterial(TownBlock townBlock, Material material, ActionType action) {
if (townBlock.getType() == TownBlockType.WILDS)
return TownyUniverse.getInstance().getPermissionSource().unclaimedZoneAction(townBlock.getWorld(), material, action);

if ((action == ActionType.BUILD || action == ActionType.DESTROY) && !townBlock.getData().getAllowedBlocks().isEmpty())
return townBlock.getData().getAllowedBlocks().contains(material);

Expand Down

0 comments on commit 9732f4e

Please sign in to comment.