From eb352a36ddf40570b14a96c908e2c3f3cd26c653 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 26 Aug 2022 21:00:22 +0200 Subject: [PATCH] Fix somes stuff Signed-off-by: yoyosource --- .../de/steamwar/bausystem/linkage/LinkageType.java | 13 ++++--------- .../de/steamwar/bausystem/linkage/LinkageUtils.java | 6 +++--- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/linkage/LinkageType.java b/BauSystem_Main/src/de/steamwar/bausystem/linkage/LinkageType.java index be535b0e..5d2ebef0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/linkage/LinkageType.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/linkage/LinkageType.java @@ -25,7 +25,6 @@ import de.steamwar.bausystem.configplayer.ConfigConverter; import de.steamwar.bausystem.features.gui.BauGUI; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; -import de.steamwar.bausystem.features.slaves.panzern.Panzern; import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm; import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithmLazyInit; import de.steamwar.bausystem.features.smartplace.SmartPlaceBehaviour; @@ -44,15 +43,13 @@ import java.util.function.Consumer; import java.util.function.Predicate; @RequiredArgsConstructor -@AllArgsConstructor -@Getter public enum LinkageType { // NORMAL COMMAND(false, SWCommand.class::isAssignableFrom, o -> ((SWCommand) o).setMessage(BauSystem.MESSAGE)), ENABLE_LINK(false, Enable.class::isAssignableFrom, o -> ((Enable) o).enable()), DISABLE_LINK(true, Disable.class::isAssignableFrom, o -> ((Disable) o).disable()), - PLAIN(false, clazz -> true), + PLAIN(false, clazz -> true, o -> {}), LISTENER(false, Listener.class::isAssignableFrom, o -> Bukkit.getPluginManager().registerEvents((Listener) o, BauSystem.getInstance())), UNLINK_LISTENER(true, Listener.class::isAssignableFrom, o -> HandlerList.unregisterAll((Listener) o)), @@ -64,11 +61,9 @@ public enum LinkageType { PANZERN(false, PanzernAlgorithm.class::isAssignableFrom, o -> PanzernAlgorithmLazyInit.add((PanzernAlgorithm) o)), SMART_PLACE(false, SmartPlaceBehaviour.class::isAssignableFrom, o -> SmartPlaceListener.add((SmartPlaceBehaviour) o)); - private final boolean unlink; + final boolean unlink; - private final Predicate> linkagePredicate; + final Predicate> linkagePredicate; - @SuppressWarnings("FieldMayBeFinal") - private Consumer linkageConsumer = o -> { - }; + final Consumer linkageConsumer; } \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/linkage/LinkageUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/linkage/LinkageUtils.java index 4cad8c7f..81f4878b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/linkage/LinkageUtils.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/linkage/LinkageUtils.java @@ -101,7 +101,7 @@ public class LinkageUtils { return; } - List linkageTypeList = Arrays.stream(linkages).map(Linked::value).filter(linkageType -> linkageType.isUnlink() == unlink).filter(linkageType -> linkageType.getLinkagePredicate().test(clazz)).collect(Collectors.toList()); + List linkageTypeList = Arrays.stream(linkages).map(Linked::value).filter(linkageType -> linkageType.unlink == unlink).filter(linkageType -> linkageType.linkagePredicate.test(clazz)).collect(Collectors.toList()); if (linkageTypeList.isEmpty()) { return; } @@ -111,10 +111,10 @@ public class LinkageUtils { if (object == null) { return; } - linkageTypeList.forEach(linkageType -> linkageType.getLinkageConsumer().accept(object)); + linkageTypeList.forEach(linkageType -> linkageType.linkageConsumer.accept(object)); } else { Object object = objectMap.computeIfAbsent(clazz, LinkageUtils::constructInstance); - linkageTypeList.forEach(linkageType -> linkageType.getLinkageConsumer().accept(object)); + linkageTypeList.forEach(linkageType -> linkageType.linkageConsumer.accept(object)); for (Field field : clazz.getDeclaredFields()) { LinkedInstance linkedInstance = field.getDeclaredAnnotation(LinkedInstance.class);