Removed code smells.

This commit is contained in:
tastybento 2018-08-03 23:31:02 -07:00
parent 5c46265771
commit 93c3d3ce47
2 changed files with 13 additions and 12 deletions

View File

@ -5,6 +5,9 @@ package world.bentobox.bentobox;
* @author tastybento
*/
public class Constants {
private Constants() {}
// The spawn command (Essentials spawn for example)
public static final String SPAWNCOMMAND = "spawn";
}

View File

@ -103,26 +103,24 @@ public class AddonClassLoader extends URLClassLoader {
* @return Class - class if found
*/
public Class<?> findClass(String name, boolean checkGlobal) {
if (name.startsWith("us.tastybento.")) {
if (name.startsWith("world.bentobox.")) {
return null;
}
Class<?> result = classes.get(name);
if (result == null) {
if (checkGlobal) {
result = loader.getClassByName(name);
}
if (result == null) {
Class<?> result = classes.computeIfAbsent(name, k -> {
if (checkGlobal && loader.getClassByName(name) != null) {
return loader.getClassByName(name);
} else {
try {
result = super.findClass(name);
return super.findClass(name);
} catch (ClassNotFoundException e) {
return null;
}
}
});
if (result != null) {
loader.setClass(name, result);
}
classes.put(name, result);
}
}
return result;
}