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.
This commit is contained in:
Tastybento 2018-02-19 12:05:59 -08:00
parent 25b4f674bb
commit 49764c151d
3 changed files with 11 additions and 20 deletions

View File

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

View File

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

View File

@ -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
*/