SteamWar/BauSystem2.0
Archiviert
12
0

Optimize some init stuff
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-08-26 20:45:43 +02:00
Ursprung 6830852c78
Commit 5758820679
2 geänderte Dateien mit 8 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -58,7 +58,6 @@ public class BauSystem extends JavaPlugin implements Listener {
@Override
public void onEnable() {
SWScoreboard.class.getName();
world = Bukkit.getWorlds().get(0);
fixBauSystem();
@ -149,6 +148,8 @@ public class BauSystem extends JavaPlugin implements Listener {
Bukkit.shutdown();
return;
}
} else {
return;
}
int number = -1;
try {

Datei anzeigen

@ -34,6 +34,7 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
import java.util.stream.Collectors;
@ -61,10 +62,13 @@ public class LinkageUtils {
}
private void internalLinkOrUnlink(boolean unlink, Class<?> toLink) {
AtomicLong totalTime = new AtomicLong();
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(BauSystem.class.getResourceAsStream("/de.steamwar.bausystem/" + toLink.getTypeName().replace("$", "."))))) {
bufferedReader.lines().forEach(s -> {
try {
long time = System.currentTimeMillis();
linkOrUnlink(Class.forName(s), unlink);
totalTime.addAndGet(System.currentTimeMillis() - time);
} catch (ClassNotFoundException e) {
// ignored
} catch (Exception e) {
@ -76,6 +80,7 @@ public class LinkageUtils {
} catch (NullPointerException e) {
// Ignored
}
BauSystem.getInstance().getLogger().info("Linkage took " + totalTime + "ms");
}
private void internalLinkFields() {
@ -101,12 +106,11 @@ public class LinkageUtils {
return;
}
List<LinkageType> linkageTypeList = Arrays.stream(linkages).filter(Objects::nonNull).map(Linked::value).filter(linkageType -> linkageType.getLinkagePredicate().test(clazz)).filter(linkageType -> linkageType.isUnlink() == unlink).collect(Collectors.toList());
List<LinkageType> linkageTypeList = Arrays.stream(linkages).map(Linked::value).filter(linkageType -> linkageType.isUnlink() == unlink).filter(linkageType -> linkageType.getLinkagePredicate().test(clazz)).collect(Collectors.toList());
if (linkageTypeList.isEmpty()) {
return;
}
linkageTypeList.sort(Comparator.comparingInt(LinkageType::getOrder));
if (unlink) {
Object object = objectMap.remove(clazz);
if (object == null) {