From dab6b80064fbb2716736ad301a9ec4b50238ffe5 Mon Sep 17 00:00:00 2001 From: jameslfc19 Date: Sat, 4 Jul 2020 21:58:29 +0100 Subject: [PATCH] Armour Stand Setting Added --- .../minecraft/chests/misc/Settings.java | 14 ++++++++++++++ .../chests/storage/abstracts/AbstractStorage.java | 3 ++- .../storage/autocraft/AutoCraftingStorage.java | 8 ++++++-- .../chests/storage/chestlink/ChestLinkStorage.java | 10 +++++++--- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/misc/Settings.java b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/misc/Settings.java index 4780ed9..50c706d 100644 --- a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/misc/Settings.java +++ b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/misc/Settings.java @@ -11,6 +11,8 @@ public class Settings { private static String LIMIT_CHESTS_NUMBER = "limit-chestlinks-amount"; private static String SHOULD_ANIMATE_ALL_CHESTS = "should-animate-all-chests"; private static String RUN_HOPPERS_UNLOADED_CHUNKS = "run-hoppers-unloaded-chunks"; + private static String SHOULD_CHEST_ARMOUR_STAND = "display_chestlink_armour_stands"; + private static String SHOULD_AUTOCRAFT_ARMOUR_STAND = "display_chestlink_armour_stands"; private static Settings cf; private FileConfiguration configuration; @@ -22,6 +24,8 @@ public class Settings { private static int limitChestsAmount; private static boolean shouldAnimateAllChests; private static boolean runHoppersInUnloadedChunks; + private static boolean shouldDisplayChestLinkStand; + private static boolean shouldDisplayAutoCraftStand; public static void initConfig(Plugin plugin){ cf = new Settings(); @@ -35,6 +39,8 @@ public class Settings { cf.configuration.addDefault(LIMIT_CHESTS_NUMBER,0); cf.configuration.addDefault(SHOULD_ANIMATE_ALL_CHESTS,false); cf.configuration.addDefault(RUN_HOPPERS_UNLOADED_CHUNKS,false); + cf.configuration.addDefault(SHOULD_CHEST_ARMOUR_STAND,true); + cf.configuration.addDefault(SHOULD_AUTOCRAFT_ARMOUR_STAND,true); cf.configuration.options().copyDefaults(true); cf.plugin.saveConfig(); @@ -55,6 +61,8 @@ public class Settings { limitChestsAmount = cf.configuration.getInt(LIMIT_CHESTS_NUMBER); shouldAnimateAllChests = cf.configuration.getBoolean(SHOULD_ANIMATE_ALL_CHESTS); runHoppersInUnloadedChunks = cf.configuration.getBoolean(RUN_HOPPERS_UNLOADED_CHUNKS); + shouldDisplayChestLinkStand = cf.configuration.getBoolean(SHOULD_CHEST_ARMOUR_STAND); + shouldDisplayAutoCraftStand = cf.configuration.getBoolean(SHOULD_AUTOCRAFT_ARMOUR_STAND); } /** @@ -72,4 +80,10 @@ public class Settings { public static boolean isRunHoppersInUnloadedChunks() { return runHoppersInUnloadedChunks; } + public static boolean isShouldDisplayChestLinkStand() { + return shouldDisplayChestLinkStand; + } + public static boolean isShouldDisplayAutoCraftStand() { + return shouldDisplayAutoCraftStand; + } } diff --git a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/storage/abstracts/AbstractStorage.java b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/storage/abstracts/AbstractStorage.java index 9c8cd63..d9eb4b3 100644 --- a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/storage/abstracts/AbstractStorage.java +++ b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/storage/abstracts/AbstractStorage.java @@ -117,7 +117,7 @@ public abstract class AbstractStorage implements ConfigurationSerializable { } private void init(){ - Bukkit.getScheduler().scheduleSyncRepeatingTask(ChestsPlusPlus.PLUGIN, this::updateClients, 1, 5); + if(shouldDisplayArmourStands()) Bukkit.getScheduler().scheduleSyncRepeatingTask(ChestsPlusPlus.PLUGIN, this::updateClients, 1, 5); } public abstract StorageType getStorageType(); @@ -142,6 +142,7 @@ public abstract class AbstractStorage implements ConfigurationSerializable { protected abstract Inventory initInventory(); protected abstract void setIdentifier(String newIdentifier); public abstract String getIdentifier(); + public abstract boolean shouldDisplayArmourStands(); /** * This is the distance from a full block to the size of the storage block. (e.g Chest is smaller than a regular block.) diff --git a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/storage/autocraft/AutoCraftingStorage.java b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/storage/autocraft/AutoCraftingStorage.java index 36dccc2..927d3c6 100644 --- a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/storage/autocraft/AutoCraftingStorage.java +++ b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/storage/autocraft/AutoCraftingStorage.java @@ -1,11 +1,10 @@ package com.jamesdpeters.minecraft.chests.storage.autocraft; import com.jamesdpeters.minecraft.chests.interfaces.VirtualCraftingHolder; +import com.jamesdpeters.minecraft.chests.misc.Settings; import com.jamesdpeters.minecraft.chests.serialize.Config; import com.jamesdpeters.minecraft.chests.serialize.RecipeSerializable; import com.jamesdpeters.minecraft.chests.storage.abstracts.AbstractStorage; -import com.jamesdpeters.minecraft.chests.storage.abstracts.StorageType; -import com.jamesdpeters.minecraft.chests.storage.chestlink.ChestLinkStorageType; import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.block.Block; @@ -84,6 +83,11 @@ public class AutoCraftingStorage extends AbstractStorage implements Configuratio return identifier; } + @Override + public boolean shouldDisplayArmourStands() { + return Settings.isShouldDisplayAutoCraftStand(); + } + @Override public double getBlockOffset() { return -0.07; diff --git a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/storage/chestlink/ChestLinkStorage.java b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/storage/chestlink/ChestLinkStorage.java index f8848dc..db052d0 100644 --- a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/storage/chestlink/ChestLinkStorage.java +++ b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/storage/chestlink/ChestLinkStorage.java @@ -4,13 +4,13 @@ import com.jamesdpeters.minecraft.chests.ChestsPlusPlus; import com.jamesdpeters.minecraft.chests.interfaces.VirtualInventoryHolder; import com.jamesdpeters.minecraft.chests.inventories.ChestLinkMenu; import com.jamesdpeters.minecraft.chests.misc.Messages; +import com.jamesdpeters.minecraft.chests.misc.Settings; import com.jamesdpeters.minecraft.chests.misc.Utils; import com.jamesdpeters.minecraft.chests.runnables.VirtualChestToHopper; import com.jamesdpeters.minecraft.chests.serialize.Config; import com.jamesdpeters.minecraft.chests.sort.InventorySorter; import com.jamesdpeters.minecraft.chests.sort.SortMethod; import com.jamesdpeters.minecraft.chests.storage.abstracts.AbstractStorage; -import com.jamesdpeters.minecraft.chests.storage.abstracts.StorageType; import fr.minuskube.inv.ClickableItem; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -35,7 +35,6 @@ import java.util.Map; public class ChestLinkStorage extends AbstractStorage implements ConfigurationSerializable { private String inventoryName; - private VirtualChestToHopper chestToHopper; private SortMethod sortMethod; public ChestLinkStorage(Map map){ @@ -79,7 +78,7 @@ public class ChestLinkStorage extends AbstractStorage implements ConfigurationSe } private void init(){ - chestToHopper = new VirtualChestToHopper(this); + VirtualChestToHopper chestToHopper = new VirtualChestToHopper(this); chestToHopper.start(); } @@ -188,6 +187,11 @@ public class ChestLinkStorage extends AbstractStorage implements ConfigurationSe return inventoryName; } + @Override + public boolean shouldDisplayArmourStands() { + return Settings.isShouldDisplayChestLinkStand(); + } + @Override public double getBlockOffset() { return 0;