mirror of
https://github.com/songoda/EpicBuckets.git
synced 2024-10-02 15:27:39 +02:00
BlockFace customization in config
This commit is contained in:
parent
58f4604ee0
commit
0c53dbf2a1
@ -1,17 +1,17 @@
|
|||||||
package com.songoda.epicbuckets.file;
|
package com.songoda.epicbuckets.file;
|
||||||
|
|
||||||
import com.songoda.epicbuckets.EpicBuckets;
|
import com.songoda.epicbuckets.EpicBuckets;
|
||||||
|
import com.songoda.epicbuckets.genbucket.GenbucketType;
|
||||||
import com.songoda.epicbuckets.util.InventoryHelper;
|
import com.songoda.epicbuckets.util.InventoryHelper;
|
||||||
import com.songoda.epicbuckets.util.Validator;
|
import com.songoda.epicbuckets.util.Validator;
|
||||||
import com.songoda.epicbuckets.util.XMaterial;
|
import com.songoda.epicbuckets.util.XMaterial;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
import java.util.stream.Collectors;
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ConfigManager {
|
public class ConfigManager {
|
||||||
|
|
||||||
@ -30,6 +30,10 @@ public class ConfigManager {
|
|||||||
|
|
||||||
private LinkedHashMap<String, Integer> genbucketGroups;
|
private LinkedHashMap<String, Integer> genbucketGroups;
|
||||||
|
|
||||||
|
private HashMap<GenbucketType, List<BlockFace>> genbucketValidFaces;
|
||||||
|
private HashMap<GenbucketType, BlockFace> genbucketDefaultFace;
|
||||||
|
private HashMap<GenbucketType, List<BlockFace>> genbucketLogicalFaces;
|
||||||
|
|
||||||
private boolean supportFactions;
|
private boolean supportFactions;
|
||||||
private boolean supportWorldGuard;
|
private boolean supportWorldGuard;
|
||||||
private boolean supportGriefPrevention;
|
private boolean supportGriefPrevention;
|
||||||
@ -77,6 +81,8 @@ public class ConfigManager {
|
|||||||
psuedoMaterials = new ArrayList<>();
|
psuedoMaterials = new ArrayList<>();
|
||||||
genbucketGroups = new LinkedHashMap<>();
|
genbucketGroups = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
loadValidFaces();
|
||||||
|
|
||||||
ignoredMaterials = InventoryHelper.convertMaterialList(epicBuckets.getConfig().getStringList("IGNORE-MATERIALS"), "IGNORE-MATERIALS");
|
ignoredMaterials = InventoryHelper.convertMaterialList(epicBuckets.getConfig().getStringList("IGNORE-MATERIALS"), "IGNORE-MATERIALS");
|
||||||
psuedoMaterials = InventoryHelper.convertMaterialList(epicBuckets.getConfig().getStringList("PSUEDO-MATERIALS"), "PSUEDO-MATERIALS");
|
psuedoMaterials = InventoryHelper.convertMaterialList(epicBuckets.getConfig().getStringList("PSUEDO-MATERIALS"), "PSUEDO-MATERIALS");
|
||||||
supportFactions = epicBuckets.getConfig().getBoolean("FACTIONS-SUPPORT");
|
supportFactions = epicBuckets.getConfig().getBoolean("FACTIONS-SUPPORT");
|
||||||
@ -98,6 +104,22 @@ public class ConfigManager {
|
|||||||
epicBuckets.getConfig().getConfigurationSection("CUSTOM-ACTIVE-GEN-PER-PLAY").getKeys(false).forEach(s -> genbucketGroups.put(epicBuckets.getConfig().getString("CUSTOM-ACTIVE-GEN-PER-PLAY." + s).split(":")[1], Integer.parseInt(epicBuckets.getConfig().getString("CUSTOM-ACTIVE-GEN-PER-PLAY." + s).split(":")[0])));
|
epicBuckets.getConfig().getConfigurationSection("CUSTOM-ACTIVE-GEN-PER-PLAY").getKeys(false).forEach(s -> genbucketGroups.put(epicBuckets.getConfig().getString("CUSTOM-ACTIVE-GEN-PER-PLAY." + s).split(":")[1], Integer.parseInt(epicBuckets.getConfig().getString("CUSTOM-ACTIVE-GEN-PER-PLAY." + s).split(":")[0])));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void loadValidFaces() {
|
||||||
|
genbucketValidFaces = new HashMap<>();
|
||||||
|
genbucketDefaultFace = new HashMap<>();
|
||||||
|
genbucketLogicalFaces = new HashMap<>();
|
||||||
|
|
||||||
|
epicBuckets.getConfig().getConfigurationSection("VALID-FACES").getKeys(false).forEach(s -> {
|
||||||
|
genbucketDefaultFace.put(GenbucketType.valueOf(s), BlockFace.valueOf(epicBuckets.getConfig().getString("VALID-FACES" + s + "DEFAULT")));
|
||||||
|
genbucketValidFaces.put(GenbucketType.valueOf(s), epicBuckets.getConfig().getStringList("VALID-FACES" + s + "WHITELIST").stream().map(s1 -> BlockFace.valueOf(s1)).collect(Collectors.toList()));
|
||||||
|
});
|
||||||
|
|
||||||
|
genbucketLogicalFaces.put(GenbucketType.HORIZONTAL, new ArrayList<>(Arrays.asList(BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH)));
|
||||||
|
genbucketLogicalFaces.put(GenbucketType.VERTICAL, new ArrayList<>(Arrays.asList(BlockFace.UP, BlockFace.DOWN)));
|
||||||
|
genbucketLogicalFaces.put(GenbucketType.INFUSED, new ArrayList<>(Arrays.asList(BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH)));
|
||||||
|
genbucketLogicalFaces.put(GenbucketType.PSUEDO, new ArrayList<>(Arrays.asList(BlockFace.UP, BlockFace.DOWN)));
|
||||||
|
}
|
||||||
|
|
||||||
private void setupFillItem() {
|
private void setupFillItem() {
|
||||||
boolean m = Validator.isMaterial(epicBuckets.getConfig().getString(getFillItemPath() + ".material"));
|
boolean m = Validator.isMaterial(epicBuckets.getConfig().getString(getFillItemPath() + ".material"));
|
||||||
|
|
||||||
@ -238,4 +260,16 @@ public class ConfigManager {
|
|||||||
public LinkedHashMap<String, Integer> getGenbucketGroups() {
|
public LinkedHashMap<String, Integer> getGenbucketGroups() {
|
||||||
return genbucketGroups;
|
return genbucketGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<BlockFace> getValidFacesForGenbucket(GenbucketType genbucketType) {
|
||||||
|
return genbucketValidFaces.get(genbucketType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockFace getDefaultFaceForGenbucket(GenbucketType genbucketType) {
|
||||||
|
return genbucketDefaultFace.get(genbucketType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<BlockFace> getLogicalFacesForGenbucket(GenbucketType genbucketType) {
|
||||||
|
return genbucketLogicalFaces.get(genbucketType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,18 +59,15 @@ public abstract class Genbucket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isValidBlockFace() {
|
public boolean isValidBlockFace() {
|
||||||
switch(genbucketType) {
|
return epicBuckets.getConfigManager().getValidFacesForGenbucket(getGenbucketType()).contains(getBlockFace());
|
||||||
case VERTICAL:
|
|
||||||
case PSUEDO:
|
|
||||||
if (blockFace == BlockFace.UP || blockFace == BlockFace.DOWN) return true;
|
|
||||||
return false;
|
|
||||||
case HORIZONTAL:
|
|
||||||
case INFUSED:
|
|
||||||
if (blockFace == BlockFace.UP || blockFace == BlockFace.DOWN) return false;
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean calculateBlockFace() {
|
||||||
|
if (!isValidBlockFace()) return false;
|
||||||
|
if (!epicBuckets.getConfigManager().getLogicalFacesForGenbucket(getGenbucketType()).contains(getBlockFace())) {
|
||||||
|
blockFace = epicBuckets.getConfigManager().getDefaultFaceForGenbucket(genbucketType);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isBelowVoid(int moved) {
|
protected boolean isBelowVoid(int moved) {
|
||||||
|
@ -44,6 +44,39 @@ CUSTOM-ACTIVE-GEN-PER-PLAY: # Put the highest first
|
|||||||
VETERAN: "25:genbucket.limit.veteran"
|
VETERAN: "25:genbucket.limit.veteran"
|
||||||
VIP: "20:genbucket.limit.vip"
|
VIP: "20:genbucket.limit.vip"
|
||||||
|
|
||||||
|
# Valid values are: UP, DOWN, SOUTH, NORTH, EAST, WEST
|
||||||
|
# Whitelist means what faces the genbucket will work on
|
||||||
|
# Default means when, for example, you allow a vertical genbucket to work on a side that is different from
|
||||||
|
# UP or DOWN, the plugin will then get this value to allow the genbucket to work. Please make sure this value
|
||||||
|
# is logical. For the vertical genbucket, that would be either UP or DOWN. Any other value just makes it
|
||||||
|
# act like a horizontal genbucket, which ofcourse isnt going to work
|
||||||
|
|
||||||
|
VALID-FACES:
|
||||||
|
HORIZONTAL:
|
||||||
|
WHITELIST:
|
||||||
|
- "EAST"
|
||||||
|
- "WEST"
|
||||||
|
- "NORTH"
|
||||||
|
- "SOUTH"
|
||||||
|
DEFAULT: "NORTH"
|
||||||
|
VERTICAL:
|
||||||
|
WHITELIST:
|
||||||
|
- "UP"
|
||||||
|
- "DOWN"
|
||||||
|
DEFAULT: "UP"
|
||||||
|
PSUEDO:
|
||||||
|
WHITELIST:
|
||||||
|
- "UP"
|
||||||
|
- "DOWN"
|
||||||
|
DEFAULT: "UP"
|
||||||
|
INFUSED:
|
||||||
|
WHITELIST:
|
||||||
|
- "EAST"
|
||||||
|
- "WEST"
|
||||||
|
- "NORTH"
|
||||||
|
- "SOUTH"
|
||||||
|
DEFAULT: "NORTH"
|
||||||
|
|
||||||
# All genbuckets will run over these materials
|
# All genbuckets will run over these materials
|
||||||
# except the psuedo.
|
# except the psuedo.
|
||||||
# Make all words capital!
|
# Make all words capital!
|
||||||
|
Loading…
Reference in New Issue
Block a user