From 054232f1bae9535590dee208c3329d6658dacf26 Mon Sep 17 00:00:00 2001 From: jameslfc19 Date: Thu, 2 Jul 2020 14:05:55 +0100 Subject: [PATCH] Rename Classes --- .../minecraft/chests/ChestsPlusPlus.java | 15 ++++++------ ...LinkListener.java => StorageListener.java} | 24 +++++++------------ .../{LinkedChest.java => ConfigStorage.java} | 19 +++++++++------ 3 files changed, 29 insertions(+), 29 deletions(-) rename src/main/java/com/jamesdpeters/minecraft/chests/listeners/{ChestLinkListener.java => StorageListener.java} (81%) rename src/main/java/com/jamesdpeters/minecraft/chests/serialize/{LinkedChest.java => ConfigStorage.java} (75%) diff --git a/src/main/java/com/jamesdpeters/minecraft/chests/ChestsPlusPlus.java b/src/main/java/com/jamesdpeters/minecraft/chests/ChestsPlusPlus.java index 992377e..0db41d8 100644 --- a/src/main/java/com/jamesdpeters/minecraft/chests/ChestsPlusPlus.java +++ b/src/main/java/com/jamesdpeters/minecraft/chests/ChestsPlusPlus.java @@ -3,7 +3,7 @@ package com.jamesdpeters.minecraft.chests; import com.jamesdpeters.minecraft.chests.commands.AutoCraftCommand; import com.jamesdpeters.minecraft.chests.commands.ChestLinkCommand; import com.jamesdpeters.minecraft.chests.crafting.Crafting; -import com.jamesdpeters.minecraft.chests.listeners.ChestLinkListener; +import com.jamesdpeters.minecraft.chests.listeners.StorageListener; import com.jamesdpeters.minecraft.chests.listeners.HopperListener; import com.jamesdpeters.minecraft.chests.listeners.InventoryListener; import com.jamesdpeters.minecraft.chests.listeners.WorldListener; @@ -12,10 +12,10 @@ import com.jamesdpeters.minecraft.chests.misc.Permissions; import com.jamesdpeters.minecraft.chests.misc.Settings; import com.jamesdpeters.minecraft.chests.misc.Stats; import com.jamesdpeters.minecraft.chests.misc.Utils; -import com.jamesdpeters.minecraft.chests.storage.AutoCraftingStorage; +import com.jamesdpeters.minecraft.chests.storage.autocraft.AutoCraftingStorage; import com.jamesdpeters.minecraft.chests.serialize.Config; -import com.jamesdpeters.minecraft.chests.storage.ChestLinkStorage; -import com.jamesdpeters.minecraft.chests.serialize.LinkedChest; +import com.jamesdpeters.minecraft.chests.storage.chestlink.ChestLinkStorage; +import com.jamesdpeters.minecraft.chests.serialize.ConfigStorage; import com.jamesdpeters.minecraft.chests.serialize.LocationInfo; import com.jamesdpeters.minecraft.chests.serialize.MaterialSerializer; import com.jamesdpeters.minecraft.chests.serialize.RecipeSerializable; @@ -60,12 +60,13 @@ public class ChestsPlusPlus extends JavaPlugin { private static boolean boot = false; static { - ConfigurationSerialization.registerClass(LinkedChest.class, "LinkedChest"); - ConfigurationSerialization.registerClass(ChestLinkStorage.class, "InventoryStorage"); + ConfigurationSerialization.registerClass(ConfigStorage.class, "ConfigStorage"); + ConfigurationSerialization.registerClass(ChestLinkStorage.class, "ChestLinkStorage"); ConfigurationSerialization.registerClass(MaterialSerializer.class, "Material"); ConfigurationSerialization.registerClass(AutoCraftingStorage.class, "AutoCraftingStorage"); ConfigurationSerialization.registerClass(RecipeSerializable.class, "Recipe"); ConfigurationSerialization.registerClass(LocationInfo.class, "LocationInfo"); + } @SuppressWarnings("ConstantConditions") @@ -85,7 +86,7 @@ public class ChestsPlusPlus extends JavaPlugin { new ChestLinkCommand().register(this); new AutoCraftCommand().register(this); - getServer().getPluginManager().registerEvents(new ChestLinkListener(),this); + getServer().getPluginManager().registerEvents(new StorageListener(),this); getServer().getPluginManager().registerEvents(new InventoryListener(),this); getServer().getPluginManager().registerEvents(new HopperListener(),this); getServer().getPluginManager().registerEvents(new WorldListener(),this); diff --git a/src/main/java/com/jamesdpeters/minecraft/chests/listeners/ChestLinkListener.java b/src/main/java/com/jamesdpeters/minecraft/chests/listeners/StorageListener.java similarity index 81% rename from src/main/java/com/jamesdpeters/minecraft/chests/listeners/ChestLinkListener.java rename to src/main/java/com/jamesdpeters/minecraft/chests/listeners/StorageListener.java index 0fa1b8a..a513eff 100644 --- a/src/main/java/com/jamesdpeters/minecraft/chests/listeners/ChestLinkListener.java +++ b/src/main/java/com/jamesdpeters/minecraft/chests/listeners/StorageListener.java @@ -1,11 +1,11 @@ package com.jamesdpeters.minecraft.chests.listeners; -import com.jamesdpeters.minecraft.chests.storage.StorageInfo; +import com.jamesdpeters.minecraft.chests.storage.abstracts.StorageInfo; import com.jamesdpeters.minecraft.chests.misc.*; import com.jamesdpeters.minecraft.chests.runnables.ChestLinkVerifier; -import com.jamesdpeters.minecraft.chests.storage.AbstractStorage; +import com.jamesdpeters.minecraft.chests.storage.abstracts.AbstractStorage; import com.jamesdpeters.minecraft.chests.serialize.Config; -import com.jamesdpeters.minecraft.chests.storage.StorageType; +import com.jamesdpeters.minecraft.chests.storage.abstracts.StorageType; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.OfflinePlayer; @@ -23,7 +23,7 @@ import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.SignChangeEvent; import org.bukkit.persistence.PersistentDataType; -public class ChestLinkListener implements Listener { +public class StorageListener implements Listener { @EventHandler public void playerInteract(BlockPlaceEvent event){ @@ -41,17 +41,15 @@ public class ChestLinkListener implements Listener { if (info != null) { Location signLocation = event.getBlockPlaced().getLocation(); if (storageType.getStorageUtils().isValidSignPosition(signLocation)) { - if(!storageType.add(event.getPlayer(), info.getGroup(), event.getBlockAgainst().getLocation(), event.getPlayer())){ + if(!storageType.add(event.getPlayer(), info.getGroup(), event.getBlockAgainst().getLocation(), info.getPlayer())){ sign.getBlock().breakNaturally(); done(); return; } - //TODO Reformat messages. - Messages.CHEST_ADDED(event.getPlayer(), signChangeEvent.getLine(1), info.getPlayer().getName()); + storageType.getMessages().storageAdded(event.getPlayer(), signChangeEvent.getLine(1), info.getPlayer().getName()); signChange(sign,signChangeEvent,info.getPlayer(),event.getPlayer()); } else { - //TODO Reformat messages. - Messages.SIGN_FRONT_OF_CHEST(event.getPlayer()); + storageType.getMessages().invalidSignPlacement(event.getPlayer()); } } } else { @@ -90,9 +88,7 @@ public class ChestLinkListener implements Listener { if(info != null){ storageType.removeBlock(info.getPlayer(), info.getGroup(), block.getLocation()); storageType.onSignRemoval(block); - //TODO Reformat messages. - Messages.CHEST_REMOVED(event.getPlayer(),info.getGroup(),info.getPlayer().getName()); - Messages.AUTOCRAFT_REMOVED(event.getPlayer(),info.getGroup(),info.getPlayer().getName()); + storageType.getMessages().storageRemoved(event.getPlayer(), info.getGroup(), info.getPlayer().getName()); } } }); @@ -114,9 +110,7 @@ public class ChestLinkListener implements Listener { if(storageType.isValidBlockType(event.getBlock())) { AbstractStorage storage = storageType.removeBlock(event.getBlock().getLocation()); if (storage != null) { - //TODO Reformat messages - Messages.CHEST_REMOVED(event.getPlayer(), storage.getIdentifier(), storage.getOwner().getName()); - Messages.AUTOCRAFT_REMOVED(event.getPlayer(), storage.getIdentifier(), storage.getOwner().getName()); + storageType.getMessages().storageRemoved(event.getPlayer(), storage.getIdentifier(), storage.getOwner().getName()); } } } diff --git a/src/main/java/com/jamesdpeters/minecraft/chests/serialize/LinkedChest.java b/src/main/java/com/jamesdpeters/minecraft/chests/serialize/ConfigStorage.java similarity index 75% rename from src/main/java/com/jamesdpeters/minecraft/chests/serialize/LinkedChest.java rename to src/main/java/com/jamesdpeters/minecraft/chests/serialize/ConfigStorage.java index 54f1bfa..1eb983e 100644 --- a/src/main/java/com/jamesdpeters/minecraft/chests/serialize/LinkedChest.java +++ b/src/main/java/com/jamesdpeters/minecraft/chests/serialize/ConfigStorage.java @@ -1,14 +1,14 @@ package com.jamesdpeters.minecraft.chests.serialize; -import com.jamesdpeters.minecraft.chests.storage.AutoCraftingStorage; -import com.jamesdpeters.minecraft.chests.storage.ChestLinkStorage; +import com.jamesdpeters.minecraft.chests.storage.autocraft.AutoCraftingStorage; +import com.jamesdpeters.minecraft.chests.storage.chestlink.ChestLinkStorage; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.configuration.serialization.SerializableAs; import java.util.*; -@SerializableAs("LinkedChest") -public class LinkedChest implements ConfigurationSerializable { +@SerializableAs("ConfigStorage") +public class ConfigStorage implements ConfigurationSerializable { public HashMap> chests; public HashMap> autocraftingtables; @@ -22,9 +22,14 @@ public class LinkedChest implements ConfigurationSerializable { } @SuppressWarnings("unchecked") - public LinkedChest(Map map){ + public ConfigStorage(Map map){ + //Legacy handling + + chests = (HashMap>) map.get("chests"); - if(chests == null) chests = new HashMap<>(); + if (chests == null) chests = new HashMap<>(); +// } + autocraftingtables = (HashMap>) map.get("autocraftingtables"); if(autocraftingtables == null) autocraftingtables = new HashMap<>(); validate(); @@ -35,7 +40,7 @@ public class LinkedChest implements ConfigurationSerializable { if(autocraftingtables != null) autocraftingtables.forEach((s, craftMap) -> craftMap.values().removeIf(Objects::isNull)); } - public LinkedChest(){ + public ConfigStorage(){ chests = new HashMap<>(); autocraftingtables = new HashMap<>(); }