diff --git a/src/main/java/one/oth3r/sit/file/CustomBlock.java b/src/main/java/one/oth3r/sit/file/CustomBlock.java index 4260d90..3ef6095 100644 --- a/src/main/java/one/oth3r/sit/file/CustomBlock.java +++ b/src/main/java/one/oth3r/sit/file/CustomBlock.java @@ -17,16 +17,14 @@ public class CustomBlock { private ArrayList blockTags = new ArrayList<>(); @SerializedName("blockstates") private ArrayList blockStates = new ArrayList<>(); - @SerializedName("sitting-height") - private Double sittingHeight = 0.5; + public CustomBlock() {} - public CustomBlock(ArrayList blockIds, ArrayList blockTags, ArrayList blockStates, Double sittingHeight) { + public CustomBlock(ArrayList blockIds, ArrayList blockTags, ArrayList blockStates) { this.blockIds = blockIds; this.blockTags = blockTags; this.blockStates = blockStates; - this.sittingHeight = sittingHeight; } public ArrayList getBlockIds() { @@ -41,9 +39,7 @@ public class CustomBlock { return blockStates; } - public Double getSittingHeight() { - return sittingHeight; - } + /** * checks if the blockstate matches the CustomBlock params diff --git a/src/main/java/one/oth3r/sit/file/FileData.java b/src/main/java/one/oth3r/sit/file/FileData.java index 3e0e515..78877f0 100644 --- a/src/main/java/one/oth3r/sit/file/FileData.java +++ b/src/main/java/one/oth3r/sit/file/FileData.java @@ -92,10 +92,10 @@ public class FileData { } public static class Defaults { - public static final ArrayList CUSTOM_BLOCKS = new ArrayList<>(Arrays.asList( - new CustomBlock(new ArrayList<>(),new ArrayList<>(Arrays.asList("#minecraft:campfires")), new ArrayList<>(Arrays.asList("lit=false")),.43), - new CustomBlock(new ArrayList<>(Arrays.asList("!minecraft:oak_log", "minecraft:crimson_stem")), new ArrayList<>(Arrays.asList("#minecraft:logs")), new ArrayList<>(Arrays.asList("!axis=y")),1.0), - new CustomBlock(new ArrayList<>(Arrays.asList()), new ArrayList<>(Arrays.asList("#minecraft:beds")), new ArrayList<>(Arrays.asList("part=foot","occupied=false")),.5) + public static final ArrayList SITTING_BLOCKS = new ArrayList<>(Arrays.asList( + new SittingBlock(new ArrayList<>(),new ArrayList<>(Arrays.asList("#minecraft:campfires")), new ArrayList<>(Arrays.asList("lit=false")),.43), + new SittingBlock(new ArrayList<>(Arrays.asList("!minecraft:oak_log", "minecraft:crimson_stem")), new ArrayList<>(Arrays.asList("#minecraft:logs")), new ArrayList<>(Arrays.asList("!axis=y")),1.0), + new SittingBlock(new ArrayList<>(Arrays.asList()), new ArrayList<>(Arrays.asList("#minecraft:beds")), new ArrayList<>(Arrays.asList("part=foot","occupied=false")),.5) )); public static final HandSetting MAIN_HAND = new HandSetting(HandSetting.SittingRequirement.EMPTY, new HandSetting.Filter( diff --git a/src/main/java/one/oth3r/sit/file/ServerConfig.java b/src/main/java/one/oth3r/sit/file/ServerConfig.java index a1a0cb6..36db623 100644 --- a/src/main/java/one/oth3r/sit/file/ServerConfig.java +++ b/src/main/java/one/oth3r/sit/file/ServerConfig.java @@ -34,9 +34,11 @@ public class ServerConfig implements CustomFile { @SerializedName("custom-enabled") private Boolean customEnabled = false; @SerializedName("custom-blocks") - private ArrayList customBlocks = FileData.Defaults.CUSTOM_BLOCKS; + private ArrayList sittingBlocks = FileData.Defaults.SITTING_BLOCKS; @SerializedName("blacklisted-blocks") private ArrayList blacklistedBlocks = new ArrayList<>(); + @SerializedName("blacklisted-interactions") + private ArrayList blacklistedInteractions = new ArrayList<>(); public ServerConfig() {} @@ -47,18 +49,18 @@ public class ServerConfig implements CustomFile { this.sitWhileSeated = serverConfig.sitWhileSeated; this.presetBlocks = serverConfig.presetBlocks; this.customEnabled = serverConfig.customEnabled; - this.customBlocks = serverConfig.customBlocks; + this.sittingBlocks = serverConfig.sittingBlocks; this.blacklistedBlocks = serverConfig.blacklistedBlocks; } - public ServerConfig(Double version, String lang, boolean keepActive, boolean sitWhileSeated, PresetBlocks presetBlocks, boolean customEnabled, ArrayList customBlocks, ArrayList blacklistedBlocks) { + public ServerConfig(Double version, String lang, boolean keepActive, boolean sitWhileSeated, PresetBlocks presetBlocks, boolean customEnabled, ArrayList sittingBlocks, ArrayList blacklistedBlocks) { this.version = version; this.lang = lang; this.keepActive = keepActive; this.sitWhileSeated = sitWhileSeated; this.presetBlocks = presetBlocks; this.customEnabled = customEnabled; - this.customBlocks = customBlocks; + this.sittingBlocks = sittingBlocks; this.blacklistedBlocks = blacklistedBlocks; } @@ -86,8 +88,8 @@ public class ServerConfig implements CustomFile { return customEnabled; } - public ArrayList getCustomBlocks() { - return customBlocks; + public ArrayList getSittingBlocks() { + return sittingBlocks; } public ArrayList getBlacklistedBlocks() { @@ -149,7 +151,7 @@ public class ServerConfig implements CustomFile { this.sitWhileSeated = newFile.sitWhileSeated; this.presetBlocks = newFile.presetBlocks; this.customEnabled = newFile.customEnabled; - this.customBlocks = newFile.customBlocks; + this.sittingBlocks = newFile.sittingBlocks; this.blacklistedBlocks = newFile.blacklistedBlocks; } @@ -229,9 +231,9 @@ public class ServerConfig implements CustomFile { /** * gets a list of custom blocks from the legacy way of entering custom sit blocks */ - private static ArrayList getCustomBlocks(ArrayList fix) { + private static ArrayList getCustomBlocks(ArrayList fix) { //eg. minecraft:campfire|.46|1|lit=false - ArrayList out = new ArrayList<>(); + ArrayList out = new ArrayList<>(); for (String entry : fix) { String[] split = entry.split("\\|"); // skip if not the right size @@ -247,7 +249,7 @@ public class ServerConfig implements CustomFile { } // add if everything is A-OK - out.add(new CustomBlock( + out.add(new SittingBlock( new ArrayList<>(Arrays.asList(split[0])), new ArrayList<>(),blockstates,Double.parseDouble(split[1]))); } diff --git a/src/main/java/one/oth3r/sit/file/SittingBlock.java b/src/main/java/one/oth3r/sit/file/SittingBlock.java new file mode 100644 index 0000000..7eba7f1 --- /dev/null +++ b/src/main/java/one/oth3r/sit/file/SittingBlock.java @@ -0,0 +1,21 @@ +package one.oth3r.sit.file; + +import com.google.gson.annotations.SerializedName; + +import java.util.ArrayList; + +public class SittingBlock extends CustomBlock { + @SerializedName("sitting-height") + private Double sittingHeight = 0.5; + + public Double getSittingHeight() { + return sittingHeight; + } + + public SittingBlock() {} + + public SittingBlock(ArrayList blockIds, ArrayList blockTags, ArrayList blockStates, Double sittingHeight) { + super(blockIds, blockTags, blockStates); + this.sittingHeight = sittingHeight; + } +} diff --git a/src/main/java/one/oth3r/sit/utl/Utl.java b/src/main/java/one/oth3r/sit/utl/Utl.java index 815500c..e77bddd 100644 --- a/src/main/java/one/oth3r/sit/utl/Utl.java +++ b/src/main/java/one/oth3r/sit/utl/Utl.java @@ -180,9 +180,9 @@ public class Utl { // if the block is on the blacklist, false if (config.getBlacklistedBlocks().contains(getBlockID(blockState))) return null; - for (CustomBlock customBlock : config.getCustomBlocks()) { + for (SittingBlock dittingBlock : config.getSittingBlocks()) { // if the block is valid, true - if (customBlock.isValid(blockState)) return customBlock.getSittingHeight(); + if (dittingBlock.isValid(blockState)) return dittingBlock.getSittingHeight(); } }