From 7da90b3a6be48d3d13bb0f8d71b95018d1b9359e Mon Sep 17 00:00:00 2001 From: md678685 Date: Sat, 12 Jan 2019 21:30:02 +0000 Subject: [PATCH] Load item spawn blacklist after item DB Partially resolves #2360. --- .../src/com/earth2me/essentials/Essentials.java | 11 +++++++++++ Essentials/src/com/earth2me/essentials/Settings.java | 12 +++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 3dafde61c..31db97ee3 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -196,27 +196,34 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials { final EssentialsUpgrade upgrade = new EssentialsUpgrade(this); upgrade.beforeSettings(); execTimer.mark("Upgrade"); + confList = new ArrayList<>(); settings = new Settings(this); confList.add(settings); execTimer.mark("Settings"); + userMap = new UserMap(this); confList.add(userMap); execTimer.mark("Init(Usermap)"); + kits = new Kits(this); confList.add(kits); upgrade.convertKits(); execTimer.mark("Kits"); + upgrade.afterSettings(); execTimer.mark("Upgrade2"); + warps = new Warps(getServer(), this.getDataFolder()); confList.add(warps); execTimer.mark("Init(Spawn/Warp)"); + worth = new Worth(this.getDataFolder()); confList.add(worth); itemDb = getItemDbFromConfig(); confList.add(itemDb); execTimer.mark("Init(Worth/ItemDB)"); + jails = new Jails(this); confList.add(jails); execTimer.mark("Init(Jails)"); @@ -241,6 +248,10 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials { ), "potion meta").getProvider(); execTimer.mark("Init(Providers)"); reload(); + + // The item spawn blacklist is loaded with all other settings, before the item + // DB, but it depends on the item DB, so we need to reload it again here: + ((Settings) settings)._lateLoadItemSpawnBlacklist(); } catch (YAMLException exception) { if (pm.getPlugin("EssentialsUpdate") != null) { LOGGER.log(Level.SEVERE, tl("essentialsHelp2")); diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index 93e409ab0..d2d6b4aaf 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -1,5 +1,6 @@ package com.earth2me.essentials; +import com.earth2me.essentials.api.IItemDb; import com.earth2me.essentials.commands.IEssentialsCommand; import com.earth2me.essentials.signs.EssentialsSign; import com.earth2me.essentials.signs.Signs; @@ -541,7 +542,11 @@ public class Settings implements net.ess3.api.ISettings { allowOldIdSigns = _allowOldIdSigns(); } - private List itemSpawnBl = new ArrayList(); + void _lateLoadItemSpawnBlacklist() { + itemSpawnBl = _getItemSpawnBlacklist(); + } + + private List itemSpawnBl = new ArrayList<>(); @Override public List itemSpawnBlacklist() { @@ -550,7 +555,8 @@ public class Settings implements net.ess3.api.ISettings { private List _getItemSpawnBlacklist() { final List epItemSpwn = new ArrayList<>(); - if (ess.getItemDb() == null) { + final IItemDb itemDb = ess.getItemDb(); + if (itemDb == null || !itemDb.isReady()) { logger.log(Level.FINE, "Skipping item spawn blacklist read; item DB not yet loaded."); return epItemSpwn; } @@ -560,7 +566,7 @@ public class Settings implements net.ess3.api.ISettings { continue; } try { - final ItemStack iStack = ess.getItemDb().get(itemName); + final ItemStack iStack = itemDb.get(itemName); epItemSpwn.add(iStack.getType()); } catch (Exception ex) { logger.log(Level.SEVERE, tl("unknownItemInList", itemName, "item-spawn-blacklist"), ex);