Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
c7b21bfc74
Commit
eb352a36dd
@ -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<Class<?>> linkagePredicate;
|
||||
final Predicate<Class<?>> linkagePredicate;
|
||||
|
||||
@SuppressWarnings("FieldMayBeFinal")
|
||||
private Consumer<Object> linkageConsumer = o -> {
|
||||
};
|
||||
final Consumer<Object> linkageConsumer;
|
||||
}
|
@ -101,7 +101,7 @@ public class LinkageUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
List<LinkageType> linkageTypeList = Arrays.stream(linkages).map(Linked::value).filter(linkageType -> linkageType.isUnlink() == unlink).filter(linkageType -> linkageType.getLinkagePredicate().test(clazz)).collect(Collectors.toList());
|
||||
List<LinkageType> 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);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren