Rename Classes

This commit is contained in:
jameslfc19 2020-07-02 14:05:55 +01:00
parent 53651b4fe5
commit 054232f1ba
3 changed files with 29 additions and 29 deletions

View File

@ -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);

View File

@ -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());
}
}
}

View File

@ -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<String, HashMap<String, ChestLinkStorage>> chests;
public HashMap<String, HashMap<String, AutoCraftingStorage>> autocraftingtables;
@ -22,9 +22,14 @@ public class LinkedChest implements ConfigurationSerializable {
}
@SuppressWarnings("unchecked")
public LinkedChest(Map<String, Object> map){
public ConfigStorage(Map<String, Object> map){
//Legacy handling
chests = (HashMap<String, HashMap<String, ChestLinkStorage>>) map.get("chests");
if(chests == null) chests = new HashMap<>();
if (chests == null) chests = new HashMap<>();
// }
autocraftingtables = (HashMap<String, HashMap<String, AutoCraftingStorage>>) 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<>();
}