mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-08 19:51:05 +00:00
Prevent NPEs when disabling plugin in onEnable
This commit is contained in:
parent
c9ce45dc0c
commit
27212f0496
@ -180,12 +180,9 @@ public class ShopChest extends JavaPlugin {
|
|||||||
getLogger().warning("Plugin may still work, but more errors are expected!");
|
getLogger().warning("Plugin may still work, but more errors are expected!");
|
||||||
}
|
}
|
||||||
|
|
||||||
loadExternalPlugins();
|
shopUtils = new ShopUtils(this);
|
||||||
|
|
||||||
debug("Loading utils and extras...");
|
|
||||||
LanguageUtils.load();
|
|
||||||
|
|
||||||
saveResource("item_names.txt", true);
|
saveResource("item_names.txt", true);
|
||||||
|
LanguageUtils.load();
|
||||||
|
|
||||||
File hologramFormatFile = new File(getDataFolder(), "hologram-format.yml");
|
File hologramFormatFile = new File(getDataFolder(), "hologram-format.yml");
|
||||||
if (!hologramFormatFile.exists()) {
|
if (!hologramFormatFile.exists()) {
|
||||||
@ -193,16 +190,14 @@ public class ShopChest extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hologramFormat = new HologramFormat(this);
|
hologramFormat = new HologramFormat(this);
|
||||||
|
|
||||||
loadMetrics();
|
|
||||||
initDatabase();
|
|
||||||
checkForUpdates();
|
|
||||||
|
|
||||||
shopUtils = new ShopUtils(this);
|
|
||||||
shopCommand = new ShopCommand(this);
|
shopCommand = new ShopCommand(this);
|
||||||
shopCreationThreadPool = new ThreadPoolExecutor(0, 8,
|
shopCreationThreadPool = new ThreadPoolExecutor(0, 8,
|
||||||
5L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
|
5L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
|
||||||
|
|
||||||
|
loadExternalPlugins();
|
||||||
|
loadMetrics();
|
||||||
|
initDatabase();
|
||||||
|
checkForUpdates();
|
||||||
registerListeners();
|
registerListeners();
|
||||||
registerExternalListeners();
|
registerExternalListeners();
|
||||||
initializeShops();
|
initializeShops();
|
||||||
@ -215,6 +210,20 @@ public class ShopChest extends JavaPlugin {
|
|||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
debug("Disabling ShopChest...");
|
debug("Disabling ShopChest...");
|
||||||
|
|
||||||
|
if (shopUtils == null) {
|
||||||
|
// Plugin has not been fully enabled (probably due to errors),
|
||||||
|
// so only close file writer.
|
||||||
|
if (fw != null && Config.enableDebugLog) {
|
||||||
|
try {
|
||||||
|
fw.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
getLogger().severe("Failed to close FileWriter");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ClickType.clear();
|
ClickType.clear();
|
||||||
|
|
||||||
if (updater != null) {
|
if (updater != null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user