mirror of
https://github.com/JamesPeters98/ChestsPlusPlus.git
synced 2024-11-14 22:56:27 +01:00
Clean Up & Fixes
Last clean up before v1.4! Remove unused import and methods. Config now gets saved with World Save Event Added update-checker metric.
This commit is contained in:
parent
df23078d80
commit
097174b221
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.jamesdpeters.chests</groupId>
|
||||
<artifactId>ChestsPlusPlus</artifactId>
|
||||
<version>1.15 v1.4-DEV</version>
|
||||
<version>1.15 v1.4</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
|
@ -4,6 +4,7 @@ import com.jamesdpeters.minecraft.chests.commands.RemoteChestCommand;
|
||||
import com.jamesdpeters.minecraft.chests.listeners.ChestLinkListener;
|
||||
import com.jamesdpeters.minecraft.chests.listeners.HopperListener;
|
||||
import com.jamesdpeters.minecraft.chests.listeners.InventoryListener;
|
||||
import com.jamesdpeters.minecraft.chests.listeners.WorldListener;
|
||||
import com.jamesdpeters.minecraft.chests.serialize.Config;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Permissions;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Settings;
|
||||
@ -65,6 +66,7 @@ public class ChestsPlusPlus extends JavaPlugin {
|
||||
getServer().getPluginManager().registerEvents(new ChestLinkListener(),this);
|
||||
getServer().getPluginManager().registerEvents(new InventoryListener(),this);
|
||||
getServer().getPluginManager().registerEvents(new HopperListener(),this);
|
||||
getServer().getPluginManager().registerEvents(new WorldListener(),this);
|
||||
|
||||
new Config();
|
||||
|
||||
|
@ -69,9 +69,10 @@ public class RemoteChestCommand extends ServerCommand {
|
||||
switch (OPTIONS.valueOf(args[0].toUpperCase())){
|
||||
case HELP:
|
||||
for(OPTIONS option : OPTIONS.values()){
|
||||
if(!option.equals(OPTIONS.HELP));
|
||||
player.sendMessage(ChatColor.RED+option.commandHelp);
|
||||
player.sendMessage(ChatColor.WHITE+option.description);
|
||||
if(!option.equals(OPTIONS.HELP)) {
|
||||
player.sendMessage(ChatColor.RED + option.commandHelp);
|
||||
player.sendMessage(ChatColor.WHITE + option.description);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case ADD:
|
||||
@ -188,8 +189,6 @@ public class RemoteChestCommand extends ServerCommand {
|
||||
if(storage != null){
|
||||
Messages.LIST_MEMBERS(player,storage);
|
||||
return true;
|
||||
} else {
|
||||
// No chest.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.jamesdpeters.minecraft.chests.commands;
|
||||
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@ -10,8 +11,11 @@ public abstract class ServerCommand implements CommandExecutor, TabCompleter {
|
||||
* @param plugin Registers command to given plugin.
|
||||
*/
|
||||
public void register(JavaPlugin plugin){
|
||||
plugin.getCommand(getCommandName()).setExecutor(this);
|
||||
plugin.getCommand(getCommandName()).setTabCompleter(this);
|
||||
PluginCommand command = plugin.getCommand(getCommandName());
|
||||
if(command != null) {
|
||||
command.setExecutor(this);
|
||||
command.setTabCompleter(this);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract String getCommandName();
|
||||
|
@ -10,7 +10,6 @@ import java.util.UUID;
|
||||
public class ChestLinkInfo {
|
||||
|
||||
private String group;
|
||||
private UUID playerUUID;
|
||||
private OfflinePlayer player;
|
||||
private InventoryStorage storage;
|
||||
|
||||
@ -22,17 +21,12 @@ public class ChestLinkInfo {
|
||||
this.group = group;
|
||||
this.storage = Config.getInventoryStorage(playerUUID,group);
|
||||
this.player = Bukkit.getOfflinePlayer(playerUUID);
|
||||
this.playerUUID = playerUUID;
|
||||
}
|
||||
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public UUID getPlayerUUID() {
|
||||
return playerUUID;
|
||||
}
|
||||
|
||||
public OfflinePlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
@ -5,21 +5,17 @@ import org.bukkit.inventory.ItemStack;
|
||||
public class Filter {
|
||||
|
||||
private ItemStack filter;
|
||||
private boolean filterByItemMeta = true;
|
||||
private boolean filterByItemMeta;
|
||||
|
||||
public Filter(ItemStack filter, boolean filterByItemMeta){
|
||||
this.filter = filter;
|
||||
this.filterByItemMeta = filterByItemMeta;
|
||||
}
|
||||
|
||||
public ItemStack getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
public boolean isFiltered(ItemStack itemStack){
|
||||
if(filter.isSimilar(itemStack)) return true;
|
||||
if(!filterByItemMeta){
|
||||
if(filter.getType().equals(itemStack.getType())) return true;
|
||||
return filter.getType().equals(itemStack.getType());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.jamesdpeters.minecraft.chests.filters;
|
||||
|
||||
import org.bukkit.Rotation;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
@ -22,7 +23,7 @@ public class HopperFilter {
|
||||
}
|
||||
|
||||
public static List<Filter> getHopperFilters(Block block){
|
||||
Collection<Entity> ent = block.getLocation().getWorld().getNearbyEntities(block.getLocation(),1.01,1.01,1.01);
|
||||
Collection<Entity> ent = block.getWorld().getNearbyEntities(block.getLocation(),1.01,1.01,1.01);
|
||||
List<Filter> filters = new ArrayList<>(ent.size());
|
||||
for(Entity entity : ent){
|
||||
if(entity instanceof ItemFrame){
|
||||
|
@ -1,62 +0,0 @@
|
||||
package com.jamesdpeters.minecraft.chests.inventories;
|
||||
|
||||
import com.jamesdpeters.minecraft.chests.ChestsPlusPlus;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Utils;
|
||||
import com.jamesdpeters.minecraft.chests.serialize.InventoryStorage;
|
||||
import fr.minuskube.inv.ClickableItem;
|
||||
import fr.minuskube.inv.SmartInventory;
|
||||
import fr.minuskube.inv.content.InventoryContents;
|
||||
import fr.minuskube.inv.content.InventoryProvider;
|
||||
import fr.minuskube.inv.content.Pagination;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ChestLinkInventory implements InventoryProvider {
|
||||
|
||||
ArrayList<ItemStack> items;
|
||||
SmartInventory inventory;
|
||||
InventoryStorage storage;
|
||||
|
||||
public ChestLinkInventory(InventoryStorage storage){
|
||||
items = new ArrayList<>();
|
||||
this.storage = storage;
|
||||
inventory = SmartInventory.builder()
|
||||
.id("chestLinkInventory")
|
||||
.title(storage.getIdentifier())
|
||||
.provider(this)
|
||||
.manager(ChestsPlusPlus.INVENTORY_MANAGER)
|
||||
.build();
|
||||
|
||||
//inventory.setInsertable(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void init(Player player, InventoryContents contents) {
|
||||
Pagination pagination = contents.pagination();
|
||||
// List<ClickableItem> itemList = new ArrayList<>();
|
||||
//
|
||||
// pagination.setItems(itemList.toArray(new ClickableItem[0]));
|
||||
pagination.setItemsPerPage(28);
|
||||
|
||||
contents.fillBorders(ClickableItem.empty(Utils.getNamedItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE)," ")));
|
||||
for(ClickableItem item : pagination.getPageItems()){
|
||||
contents.add(item);
|
||||
}
|
||||
|
||||
contents.set(2, 2, ClickableItem.from(Utils.getNamedItem(new ItemStack(Material.ARROW),"Previous"),
|
||||
e -> inventory.open(player, pagination.previous().getPage())));
|
||||
contents.set(2, 6, ClickableItem.from(Utils.getNamedItem(new ItemStack(Material.ARROW),"Next"),
|
||||
e -> inventory.open(player, pagination.next().getPage())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Player player, InventoryContents contents) {
|
||||
|
||||
}
|
||||
}
|
@ -73,7 +73,7 @@ public class ChestLinkListener implements Listener {
|
||||
//If block sign is placed on is a chest we can remove it.
|
||||
if(chest.getState() instanceof Chest) {
|
||||
ChestLinkInfo info = Utils.getChestLinkInfo(sign,sign.getLines());
|
||||
if (info != null) { ;
|
||||
if (info != null) {
|
||||
Config.removeChest(info.getPlayer(), info.getGroup(), chest.getLocation());
|
||||
((Chest) chest.getState()).getInventory().clear();
|
||||
Messages.CHEST_REMOVED(event.getPlayer(),info.getGroup(),info.getPlayer().getName());
|
||||
|
@ -64,7 +64,7 @@ public class HopperListener implements Listener {
|
||||
public void itemFrameInteract(PlayerInteractEntityEvent event){
|
||||
if(event.getRightClicked().getType().equals(EntityType.ITEM_FRAME)){
|
||||
ItemFrame itemFrame = (ItemFrame) event.getRightClicked();
|
||||
Block attachedBlock = itemFrame.getLocation().getBlock().getRelative(((ItemFrame) itemFrame).getAttachedFace());
|
||||
Block attachedBlock = itemFrame.getLocation().getBlock().getRelative(itemFrame.getAttachedFace());
|
||||
if(!(attachedBlock.getState() instanceof Hopper)) return;
|
||||
Rotation rotation = itemFrame.getRotation().rotateClockwise();
|
||||
if(rotation.equals(Rotation.FLIPPED)){
|
||||
@ -74,33 +74,4 @@ public class HopperListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// public static boolean isItemInFilter(Block block, ItemStack item){
|
||||
// Bukkit.broadcastMessage("Cheking item: "+item.getType().name());
|
||||
// Collection<Entity> ent = block.getLocation().getWorld().getNearbyEntities(block.getLocation(),1.01,1.01,1.01);
|
||||
// boolean hasFilter = false;
|
||||
// for(Entity entity : ent){
|
||||
// if(entity instanceof ItemFrame){
|
||||
// ItemFrame frame = (ItemFrame) entity;
|
||||
// Block attachedBlock = frame.getLocation().getBlock().getRelative(frame.getAttachedFace());
|
||||
// if(block.equals(attachedBlock)){
|
||||
// ItemStack itemStack = frame.getItem();
|
||||
// Bukkit.broadcastMessage("Item Filter!");
|
||||
// if(itemStack.getType() != Material.AIR) hasFilter = true;
|
||||
// if(item.isSimilar(itemStack)){
|
||||
// return true;
|
||||
// }
|
||||
// Rotation rotation = frame.getRotation();
|
||||
// Bukkit.broadcastMessage("Frame rotation: "+rotation.toString());
|
||||
// if(rotation.equals(Rotation.FLIPPED)){
|
||||
// if(item.getType().equals(itemStack.getType())) return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return !hasFilter;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ public class InventoryListener implements Listener {
|
||||
public void onInventoryPlayerUpdate(InventoryClickEvent event){
|
||||
if(event.getInventory().getHolder() instanceof VirtualInventoryHolder){
|
||||
inventoryUpdate(event);
|
||||
Config.save();
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,7 +53,6 @@ public class InventoryListener implements Listener {
|
||||
if (event.getInventory().getLocation() == null) {
|
||||
Utils.closeInventorySound((Player) event.getPlayer(), event.getInventory());
|
||||
}
|
||||
Config.save();
|
||||
}
|
||||
} catch (NullPointerException ignore){} //Essentials does something weird with enderchests - shit fix but works :)
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
package com.jamesdpeters.minecraft.chests.listeners;
|
||||
|
||||
import com.jamesdpeters.minecraft.chests.ChestsPlusPlus;
|
||||
import com.jamesdpeters.minecraft.chests.serialize.Config;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.WorldSaveEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class WorldListener implements Listener {
|
||||
|
||||
private static boolean justSaved = false;
|
||||
|
||||
@EventHandler
|
||||
public void onWorldSave(WorldSaveEvent event){
|
||||
if(!justSaved){
|
||||
Config.save();
|
||||
justSaved = true;
|
||||
new BukkitRunnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
justSaved = false;
|
||||
}
|
||||
}.runTaskLater(ChestsPlusPlus.PLUGIN,5);
|
||||
}
|
||||
}
|
||||
}
|
@ -26,7 +26,7 @@ public class Settings {
|
||||
}
|
||||
|
||||
private static void save(){
|
||||
cf.plugin.saveConfig();;
|
||||
cf.plugin.saveConfig();
|
||||
}
|
||||
|
||||
public static void reloadConfig(){
|
||||
|
@ -10,5 +10,10 @@ public class Stats {
|
||||
int chestlinks = Config.getTotalChestLinks();
|
||||
return chestlinks+"";
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new Metrics.SimplePie("update_checker_setting", () -> {
|
||||
if(Settings.isUpdateCheckEnabled()) return "enabled";
|
||||
else return "disabled";
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
@ -84,10 +84,6 @@ public class Utils {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String locationPrettyPrint(Location location){
|
||||
return "["+location.getX()+","+location.getY()+","+location.getZ()+"] in "+location.getWorld().getName();
|
||||
}
|
||||
|
||||
public static void openInventory(Player player, Inventory inventory){
|
||||
if(inventory.getLocation() != null) player.getWorld().playSound(inventory.getLocation(), Sound.BLOCK_CHEST_OPEN,0.5f,1f);
|
||||
else player.getWorld().playSound(player.getLocation(), Sound.BLOCK_CHEST_OPEN,0.5f,1f);
|
||||
@ -248,18 +244,6 @@ public class Utils {
|
||||
public static String prettyPrintPlayers(ChatColor highlight, List<OfflinePlayer> players){
|
||||
String playerString = players.stream().map(OfflinePlayer::getName).collect(Collectors.joining(","));
|
||||
return highlight+"["+ChatColor.WHITE+playerString+highlight+"]";
|
||||
//
|
||||
// StringBuilder str = new StringBuilder();
|
||||
// str.append(players.size());
|
||||
// if(players.size() > 0) {
|
||||
// str.append(" - " + highlight + "[");
|
||||
// for (OfflinePlayer player : players) {
|
||||
// str.append(ChatColor.WHITE + ChatColor.stripColor(player.getName())).append(", ");
|
||||
// }
|
||||
// str.delete(str.length() - 2, str.length());
|
||||
// str.append(highlight + "]");
|
||||
// }
|
||||
// return str.toString();
|
||||
}
|
||||
|
||||
public static List<String> getInventoryStorageList(Player player){
|
||||
@ -272,9 +256,4 @@ public class Utils {
|
||||
playerList.addAll(memberList);
|
||||
return playerList;
|
||||
}
|
||||
|
||||
public static boolean validateChestID(String id){
|
||||
return !id.contains(":");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.block.DoubleChest;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class ChestLinkVerifier extends BukkitRunnable {
|
||||
@ -34,10 +35,12 @@ public class ChestLinkVerifier extends BukkitRunnable {
|
||||
|
||||
if(chest.getInventory().getHolder() instanceof DoubleChest) {
|
||||
DoubleChest doubleChest = (DoubleChest) chest.getInventory().getHolder();
|
||||
if(isChestLinked(doubleChest)) {
|
||||
convertToSingleChest(doubleChest.getRightSide().getInventory());
|
||||
convertToSingleChest(doubleChest.getLeftSide().getInventory());
|
||||
convertToSingleChest(doubleChest.getRightSide().getInventory());
|
||||
InventoryHolder right = doubleChest.getRightSide();
|
||||
InventoryHolder left = doubleChest.getLeftSide();
|
||||
if(isChestLinked(doubleChest) && left != null && right != null) {
|
||||
convertToSingleChest(right.getInventory());
|
||||
convertToSingleChest(left.getInventory());
|
||||
convertToSingleChest(right.getInventory());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -58,9 +61,6 @@ public class ChestLinkVerifier extends BukkitRunnable {
|
||||
InventoryStorage leftStorage = Config.getInventoryStorage(chestSide1);
|
||||
InventoryStorage rightStorage = Config.getInventoryStorage(chestSide2);
|
||||
|
||||
if((leftStorage != null) || (rightStorage != null)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return (leftStorage != null) || (rightStorage != null);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,8 @@
|
||||
package com.jamesdpeters.minecraft.chests.serialize;
|
||||
|
||||
import com.jamesdpeters.minecraft.chests.ChestsPlusPlus;
|
||||
import com.jamesdpeters.minecraft.chests.containers.ChestLinkInfo;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Messages;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Utils;
|
||||
import com.jamesdpeters.minecraft.chests.serialize.InventoryStorage;
|
||||
import com.jamesdpeters.minecraft.chests.serialize.LinkedChest;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -15,8 +12,6 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -39,21 +34,14 @@ public class Config {
|
||||
}
|
||||
}
|
||||
|
||||
private static BukkitRunnable saveRunnable = new BukkitRunnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
if(config == null) config = new YamlConfiguration();
|
||||
config.set("chests++", store);
|
||||
try{
|
||||
config.save("chests.yml");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static void save(){
|
||||
saveRunnable.runTaskAsynchronously(ChestsPlusPlus.PLUGIN);
|
||||
if(config == null) config = new YamlConfiguration();
|
||||
config.set("chests++", store);
|
||||
try{
|
||||
config.save("chests.yml");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<InventoryStorage> getInventoryStorageMemberOf(Player player){
|
||||
@ -127,7 +115,7 @@ public class Config {
|
||||
inventoryStorage.getLocations().add(chestLocation);
|
||||
}
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP,1.0f,1f);
|
||||
save();
|
||||
//saveASync();
|
||||
}
|
||||
|
||||
public static InventoryStorage removeChest(InventoryStorage storage, Location location){
|
||||
@ -137,7 +125,7 @@ public class Config {
|
||||
storage.dropInventory(location);
|
||||
getInventoryStorageMap(storage.getOwner().getUniqueId()).remove(storage.getIdentifier());
|
||||
}
|
||||
save();
|
||||
//saveASync();
|
||||
return storage;
|
||||
}
|
||||
return null;
|
||||
@ -159,7 +147,7 @@ public class Config {
|
||||
Messages.GROUP_DOESNT_EXIST(player,group);
|
||||
}
|
||||
|
||||
save();
|
||||
//saveASync();
|
||||
}
|
||||
|
||||
public static InventoryStorage removeChest(OfflinePlayer owner, String identifier, Location chestLocation){
|
||||
@ -171,13 +159,6 @@ public class Config {
|
||||
return removeChest(storage,chestLocation);
|
||||
}
|
||||
|
||||
public static boolean setChests(Player player, String group, InventoryStorage storage){
|
||||
HashMap<String, InventoryStorage> groups = getInventoryStorageMap(player.getUniqueId());
|
||||
groups.put(group,storage);
|
||||
save();
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int getTotalChestLinks(){
|
||||
AtomicInteger total = new AtomicInteger();
|
||||
store.chests.forEach((s, InventoryStorageHashMap) -> {
|
||||
@ -193,10 +174,7 @@ public class Config {
|
||||
String[] args = playerChestID.split(":");
|
||||
String playerName = args[0];
|
||||
String chestlinkID = args[1];
|
||||
Optional<InventoryStorage> invStorage = getInventoryStorageMemberOf(member).stream().filter(storage -> {
|
||||
if (storage.getOwner().getName().equals(playerName) && storage.getIdentifier().equals(chestlinkID)) return true;
|
||||
return false;
|
||||
}).findFirst();
|
||||
Optional<InventoryStorage> invStorage = getInventoryStorageMemberOf(member).stream().filter(storage -> storage.getOwner().getName().equals(playerName) && storage.getIdentifier().equals(chestlinkID)).findFirst();
|
||||
if(invStorage.isPresent()) return invStorage.get();
|
||||
}
|
||||
return null;
|
||||
@ -224,7 +202,7 @@ public class Config {
|
||||
storage.rename(newIdentifier);
|
||||
map.remove(oldIdentifier);
|
||||
map.put(newIdentifier,storage);
|
||||
save();
|
||||
//saveASync();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class InventoryStorage implements ConfigurationSerializable {
|
||||
OfflinePlayer player;
|
||||
UUID playerUUID;
|
||||
boolean isPublic;
|
||||
SortMethod sortMethod = SortMethod.OFF;
|
||||
SortMethod sortMethod;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> serialize() {
|
||||
@ -74,8 +74,10 @@ public class InventoryStorage implements ConfigurationSerializable {
|
||||
player = Bukkit.getOfflinePlayer(playerUUID);
|
||||
|
||||
if(map.containsKey("isPublic")) isPublic = (boolean) map.get("isPublic");
|
||||
if(map.containsKey("sortMethod")) sortMethod = Enum.valueOf(SortMethod.class, (String) map.get("sortMethod"));
|
||||
else isPublic = false;
|
||||
|
||||
if(map.containsKey("sortMethod")) sortMethod = Enum.valueOf(SortMethod.class, (String) map.get("sortMethod"));
|
||||
else sortMethod = SortMethod.OFF;
|
||||
|
||||
if(map.get("members") != null){
|
||||
members = (ArrayList<String>) map.get("members");
|
||||
@ -203,7 +205,6 @@ public class InventoryStorage implements ConfigurationSerializable {
|
||||
if(bukkitMembers == null) bukkitMembers = new ArrayList<>();
|
||||
members.add(player.getUniqueId().toString());
|
||||
bukkitMembers.add(player);
|
||||
Config.save();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -214,7 +215,6 @@ public class InventoryStorage implements ConfigurationSerializable {
|
||||
if(bukkitMembers != null) bukkitMembers.remove(player);
|
||||
if(members != null){
|
||||
members.remove(player.getUniqueId().toString());
|
||||
Config.save();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.jamesdpeters.minecraft.chests.serialize;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user