From 49764c151dca48f9329fb27f43aee0ccf560f31b Mon Sep 17 00:00:00 2001 From: Tastybento Date: Mon, 19 Feb 2018 12:05:59 -0800 Subject: [PATCH] Reverted f3d7bf2af395dfa2f3c33df8bc8d824dccf945b8 It breaks the addon class loading and using lamda functions doesn't end up being neater because it must be able to throw a ClassNotFoundExcepetion to the Bukkit code. --- .../api/addons/AddonClassLoader.java | 25 +++++++------------ .../api/commands/CompositeCommand.java | 2 -- .../island/IslandSettingsCommand.java | 4 +-- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/main/java/us/tastybento/bskyblock/api/addons/AddonClassLoader.java b/src/main/java/us/tastybento/bskyblock/api/addons/AddonClassLoader.java index 8dd14c6bf..368d8120d 100644 --- a/src/main/java/us/tastybento/bskyblock/api/addons/AddonClassLoader.java +++ b/src/main/java/us/tastybento/bskyblock/api/addons/AddonClassLoader.java @@ -90,24 +90,17 @@ public class AddonClassLoader extends URLClassLoader { if (name.startsWith("us.tastybento.")) { throw new ClassNotFoundException(name); } - return classes.computeIfAbsent(name, k -> createFor(k, checkGlobal)); - } - - private Class createFor(String name, boolean checkGlobal) { - Class result = null; - if (checkGlobal) { - result = loader.getClassByName(name); - } - + Class result = classes.get(name); if (result == null) { - try { - result = super.findClass(name); - } catch (ClassNotFoundException e) { - Bukkit.getLogger().severe("Could not find class! " + e.getMessage()); + if (checkGlobal) { + result = loader.getClassByName(name); } - - if (result != null) { - loader.setClass(name, result); + if (result == null) { + result = super.findClass(name); + if (result != null) { + loader.setClass(name, result); + } + classes.put(name, result); } } return result; diff --git a/src/main/java/us/tastybento/bskyblock/api/commands/CompositeCommand.java b/src/main/java/us/tastybento/bskyblock/api/commands/CompositeCommand.java index 4ebe1676a..37dbc66cf 100644 --- a/src/main/java/us/tastybento/bskyblock/api/commands/CompositeCommand.java +++ b/src/main/java/us/tastybento/bskyblock/api/commands/CompositeCommand.java @@ -6,13 +6,11 @@ import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Optional; import java.util.Set; import java.util.UUID; import java.util.logging.Logger; -import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.PluginIdentifiableCommand; diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/IslandSettingsCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/IslandSettingsCommand.java index b53b97c73..76d69b4a2 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/IslandSettingsCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/IslandSettingsCommand.java @@ -1,12 +1,12 @@ package us.tastybento.bskyblock.commands.island; +import java.util.List; + import us.tastybento.bskyblock.Constants; import us.tastybento.bskyblock.api.commands.CompositeCommand; import us.tastybento.bskyblock.api.commands.User; import us.tastybento.bskyblock.commands.IslandCommand; -import java.util.List; - /** * @author Poslovitch */