From ae61b1e240a935334d44293d257be132ee86888d Mon Sep 17 00:00:00 2001 From: Amarok Date: Tue, 17 Sep 2024 21:12:35 +0800 Subject: [PATCH 01/17] =?UTF-8?q?=F0=9F=90=BA=F0=9F=9B=A0=EF=B8=8F?= =?UTF-8?q?=E2=9D=8C=F0=9F=AA=84=F0=9F=A5=93=F0=9F=92=BB=F0=9F=92=BE?= =?UTF-8?q?=E2=9C=A8=F0=9F=8D=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kessoku/lib/config/KessokuConfig.java | 23 ++-- .../lib/config/api/AbstractConfig.java | 127 +++++++++++------- .../kessoku/lib/config/api/ConfigValue.java | 10 +- .../api/serializers/Json5Serializer.java | 2 +- .../api/serializers/JsonSerializer.java | 1 + 5 files changed, 99 insertions(+), 64 deletions(-) diff --git a/config/common/src/main/java/band/kessoku/lib/config/KessokuConfig.java b/config/common/src/main/java/band/kessoku/lib/config/KessokuConfig.java index a96f4909..8164f1d7 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/KessokuConfig.java +++ b/config/common/src/main/java/band/kessoku/lib/config/KessokuConfig.java @@ -19,6 +19,7 @@ import java.io.IOException; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import band.kessoku.lib.config.api.AbstractConfig; import band.kessoku.lib.config.api.ConfigSerializer; @@ -31,36 +32,40 @@ public final class KessokuConfig { private static final Map> configs = new HashMap<>(); - private static final Map, ConfigSerializer> serializerCache = new HashMap<>(); + private static final Map, ConfigSerializer> serializerCache = new HashMap<>(); + public static final String MOD_ID = "kessoku_config"; public static final Marker MARKER = MarkerFactory.getMarker("[KessokuConfig]"); @SuppressWarnings({"unchecked", "unused"}) public static T register(T config, Class serializer) { if (config.getClass().isAnonymousClass()) throw new IllegalArgumentException(); - final File file = config.getPath().toFile(); + try { - FileUtils.touch(file); + FileUtils.touch(config.getPath().toFile()); } catch (IOException e) { throw new RuntimeException(e); } + configs.put(config, (Class) serializer); return config; } @Contract(pure = true) - public static @Nullable Class getSerializer(T config) { + @Nullable + public static Class getSerializer(T config) { return configs.get(config); } @Contract(pure = true) @SuppressWarnings("unchecked") - public static @NotNull ConfigSerializer getSerializerInstance(Class serializer) { - if (serializerCache.containsKey(serializer)) return serializerCache.get(serializer); + @NotNull + public static T getSerializerInstance(Class serializer) { try { - T serializerInstance = serializer.getConstructor().newInstance(); - serializerCache.put((Class) serializer, serializerInstance); - return serializerInstance; + return (T) Objects.requireNonNull(serializerCache.containsKey(serializer) + ? serializerCache.get(serializer) + : serializerCache.put(serializer, + serializer.getConstructor().newInstance())); } catch (ReflectiveOperationException e) { throw new RuntimeException(e); } diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java b/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java index a36176d9..6f4d70ce 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java @@ -35,13 +35,14 @@ import com.google.common.collect.ImmutableMap; import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; +import org.apache.logging.log4j.core.util.ReflectionUtil; -//@SuppressWarnings({"rawtypes", "unchecked", "unused"}) +@SuppressWarnings({"rawtypes", "unused"}) public abstract class AbstractConfig { - private final List preSave = new ArrayList<>(); - private final List preLoad = new ArrayList<>(); - private final List postSave = new ArrayList<>(); - private final List postLoad = new ArrayList<>(); + private final List> preSave = new ArrayList<>(); + private final List> preLoad = new ArrayList<>(); + private final List> postSave = new ArrayList<>(); + private final List> postLoad = new ArrayList<>(); private List values; private List categories; private boolean split = false; @@ -53,13 +54,14 @@ public boolean save() { preSave.forEach(consumer -> consumer.accept(this)); File file = this.getPath().toFile(); ConfigSerializer serializer = this.getSerializer(); - boolean result; + + boolean result = true; try (FileWriter writer = new FileWriter(file, StandardCharsets.UTF_8)) { writer.write(serializer.serialize(this.serialize())); - result = true; } catch (IOException e) { result = false; } + final boolean finalResult = result; postSave.forEach(biConsumer -> biConsumer.accept(this, finalResult)); return finalResult; @@ -69,59 +71,62 @@ public boolean load() { preLoad.forEach(consumer -> consumer.accept(this)); ConfigSerializer serializer = this.getSerializer(); File file = this.getPath().toFile(); - boolean result; + + boolean result = true; try { Map map = serializer.deserialize(FileUtils.readFileToString(file, StandardCharsets.UTF_8)); // Put values into the config for (Map.Entry entry : map.entrySet()) { - String string = entry.getKey(); - Object object = entry.getValue(); + String key = entry.getKey(); + Object cValue = entry.getValue(); + ConfigValue value; // Check the value is public and not static try { - Field field = this.getClass().getField(string); + Field field = this.getClass().getField(key); if (!Modifier.isPublic(field.getModifiers()) || Modifier.isStatic(field.getModifiers())) continue; - value = (ConfigValue) field.get(this); - } catch (NoSuchFieldException | IllegalAccessException e) { + value = (ConfigValue) ReflectionUtil.getFieldValue(field, this); + } catch (NoSuchFieldException e) { continue; } - ConfigValue.Type type; + + ConfigValue.Type type = ConfigValue.Type.asType(cValue); // Check if the type is valid to deserialize - try { - type = ConfigValue.Type.asType(object); - } catch (IllegalArgumentException e) { - ModUtils.getLogger().error(KessokuConfig.MARKER, "Illegal type`{}` found in the file!", object.getClass().getName()); + if (type == ConfigValue.Type.NULL) { + ModUtils.getLogger().error(KessokuConfig.MARKER, "Illegal type`{}` found in the file!", cValue.getClass().getName()); continue; } + // Check if the type matches the value's type if (value.getType() != type) { ModUtils.getLogger().error(KessokuConfig.MARKER, "Illegal type`{}` found in the file! Expect {}.", type.toString().toLowerCase(), value.getType().toString().toLowerCase()); continue; } - value.setTo(object); + + value.setTo(cValue); } - result = true; } catch (IOException e) { result = false; } + final boolean finalResult = result; postLoad.forEach(biConsumer -> biConsumer.accept(this, finalResult)); return finalResult; } - public void registerPreSaveListener(Consumer preSave) { + public void registerPreSaveListener(Consumer preSave) { this.preSave.add(preSave); } - public void registerPreLoadListener(Consumer preLoad) { + public void registerPreLoadListener(Consumer preLoad) { this.preLoad.add(preLoad); } - public void registerPostSaveListener(BiConsumer postSave) { + public void registerPostSaveListener(BiConsumer postSave) { this.postSave.add(postSave); } - public void registerPostLoadListener(BiConsumer postLoad) { + public void registerPostLoadListener(BiConsumer postLoad) { this.postLoad.add(postLoad); } @@ -131,37 +136,41 @@ public void reset() { } public ImmutableList> getValidValues() { - if (this.values != null) - return ImmutableList.>builder().addAll(this.values.stream().map(field -> { - try { - return (ConfigValue) field.get(this); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - }).toList()).build(); + if (this.values != null) { + return ImmutableList.>builder().addAll(this.values.stream().map(field -> + (ConfigValue) ReflectionUtil.getFieldValue(field, this)).toList()).build(); + } + List fields = new ArrayList<>(); for (Field declaredField : this.getClass().getDeclaredFields()) { - if (declaredField.getDeclaringClass().isAssignableFrom(ConfigValue.class) && Modifier.isPublic(declaredField.getModifiers()) && !Modifier.isStatic(declaredField.getModifiers())) + final boolean flag0 = declaredField.getDeclaringClass().isAssignableFrom(ConfigValue.class); + final boolean flag1 = Modifier.isPublic(declaredField.getModifiers()); + final boolean flag2 = !Modifier.isStatic(declaredField.getModifiers()); + if (flag0 && flag1 && flag2) { fields.add(declaredField); + } } + this.values = fields; return this.getValidValues(); } public ImmutableList getValidCategories() { - if (this.categories != null) - return ImmutableList.builder().addAll(this.categories.stream().map(field -> { - try { - return (AbstractConfig) field.get(this); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - }).toList()).build(); + if (this.categories != null){ + return ImmutableList.builder().addAll(this.categories.stream().map(field -> + (AbstractConfig) ReflectionUtil.getFieldValue(field, this)).toList()).build(); + } + List fields = new ArrayList<>(); for (Field declaredField : this.getClass().getDeclaredFields()) { - if (declaredField.getDeclaringClass().isAssignableFrom(AbstractConfig.class) && Modifier.isPublic(declaredField.getModifiers())) + + final boolean flag0 = declaredField.getDeclaringClass().isAssignableFrom(AbstractConfig.class); + final boolean flag1 = Modifier.isPublic(declaredField.getModifiers()); + if (flag0 && flag1){ fields.add(declaredField); + } } + this.categories = fields; return this.getValidCategories(); } @@ -169,8 +178,16 @@ public ImmutableList getValidCategories() { private ImmutableList getValidFields() { ImmutableList.Builder builder = ImmutableList.builder(); for (Field declaredField : this.getClass().getDeclaredFields()) { - if ((declaredField.getDeclaringClass().isAssignableFrom(AbstractConfig.class) || declaredField.getDeclaringClass().isAssignableFrom(ConfigValue.class)) && Modifier.isPublic(declaredField.getModifiers())) + + final boolean flag0 = declaredField.getDeclaringClass().isAssignableFrom(AbstractConfig.class); + final boolean flag1 = declaredField.getDeclaringClass().isAssignableFrom(ConfigValue.class); + final boolean flag2 = Modifier.isPublic(declaredField.getModifiers()); + + final var flag = flag0 || flag1; + + if (flag && flag2){ builder.add(declaredField); + } } return builder.build(); } @@ -178,21 +195,20 @@ private ImmutableList getValidFields() { private Map serialize() { ImmutableMap.Builder builder = ImmutableMap.builder(); for (Field field : this.getValidFields()) { + field.setAccessible(true); final String name = field.isAnnotationPresent(Name.class) ? field.getAnnotation(Name.class).value() : field.getName(); final String[] comments = field.isAnnotationPresent(Comments.class) ? (String[]) Arrays.stream(field.getAnnotation(Comments.class).value()).map(Comment::value).toArray() : new String[0]; - Object o; - try { - o = field.get(this); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } + + Object fieldValue = ReflectionUtil.getFieldValue(field, this); + // ConfigValue - if (o instanceof ConfigValue value) { + if (fieldValue instanceof ConfigValue value) { builder.put(name, new ValueWithComment(value.get(), comments)); continue; } + // Category - AbstractConfig category = (AbstractConfig) o; + AbstractConfig category = (AbstractConfig) fieldValue; if (this.split) { if (!category.save()) { ModUtils.getLogger().error(KessokuConfig.MARKER, "Failed to save category `{}!`", category.getSimpleName()); @@ -212,13 +228,20 @@ public boolean isSplitToFiles() { return this.split; } + /** + * Get config full name. If it's a sub file, it will include the paths. + * @return Get the full name of the config. + */ // Not including file ext, but parent path `/` public String getName() { Name name = this.getClass().getAnnotation(Name.class); return name == null ? this.getClass().getSimpleName() : name.value(); } - // Just config name + /** + * Get the config name. Even it's a sub file, just config name. + * @return The simple config name. + */ public String getSimpleName() { String[] strings = this.getName().split("/"); return strings[strings.length - 1]; diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/ConfigValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/ConfigValue.java index b2a371f8..7868674a 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/ConfigValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/ConfigValue.java @@ -42,7 +42,7 @@ default F get() { T getDefaultTo(); enum Type { - LIST, MAP, BOOLEAN, STRING, INTEGER, LONG, FLOAT, DOUBLE; + LIST, MAP, BOOLEAN, STRING, INTEGER, LONG, FLOAT, DOUBLE, NULL; public static Type asType(Object o) { return switch (o) { @@ -54,7 +54,13 @@ public static Type asType(Object o) { case Integer ignored -> INTEGER; case Float ignored -> FLOAT; case Double ignored -> DOUBLE; - case null, default -> throw new IllegalArgumentException(); + + /* AmarokIce Note: + try catch 对性能会造成额外影响。此处 throw 后在 { @code AbstractConfig } 中捕获是无意义的。 + 因此,改用 NULL 作为空置对象。 + */ + case null, default -> NULL; + // case null, default -> throw new IllegalArgumentException(); }; } } diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/Json5Serializer.java b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/Json5Serializer.java index 28e42019..e206fd37 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/Json5Serializer.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/Json5Serializer.java @@ -23,7 +23,7 @@ import club.someoneice.json.node.JsonNode; import club.someoneice.json.processor.Json5Builder; -//todo +// TODO public class Json5Serializer implements ConfigSerializer { @Override public String serialize(Map value) { diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/JsonSerializer.java b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/JsonSerializer.java index 42b983cf..04edba7e 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/JsonSerializer.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/JsonSerializer.java @@ -33,6 +33,7 @@ public String serialize(Map value) { .map(it -> new Pair<>(it.getKey(), JsonNode.asJsonNodeOrEmpty(it.getValue().object()))) .filter(it -> it.getValue().nonNull()) .forEach(it -> node.put(it.getKey(), it.getValue())); + return JsonBuilder.prettyPrint(node); } From 995bc9eaf377437269f4828b0e95b0633c05ac54 Mon Sep 17 00:00:00 2001 From: Amarok Date: Tue, 17 Sep 2024 21:13:39 +0800 Subject: [PATCH 02/17] =?UTF-8?q?=F0=9F=90=BA=E2=81=89=EF=B8=8F?= =?UTF-8?q?=F0=9F=A6=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/band/kessoku/lib/base/ModUtils.java | 6 ++--- .../api/events/CommandRegistryEvent.java | 1 - .../testmod/command/KessokuTestCommand.java | 1 - .../lib/command/KessokuCommandEntrypoint.java | 1 - .../lib/command/impl/KessokuCommandImpl.java | 1 - .../lib/command/KessokuCommandEntrypoint.java | 1 - .../lib/command/impl/KessokuCommandImpl.java | 1 - .../kessoku/lib/config/KessokuConfig.java | 11 +++++----- .../lib/config/api/AbstractConfig.java | 22 +++++++++---------- .../api/serializers/Json5Serializer.java | 4 ++-- .../api/serializers/JsonSerializer.java | 4 ++-- .../api/serializers/TomlSerializer.java | 4 ++-- .../lib/config/api/values/BooleanValue.java | 4 ++-- .../config/api/values/DefaultConfigValue.java | 4 ++-- .../lib/config/api/values/DoubleValue.java | 4 ++-- .../lib/config/api/values/FloatValue.java | 4 ++-- .../lib/config/api/values/IntegerValue.java | 4 ++-- .../lib/config/api/values/ListValue.java | 6 ++--- .../lib/config/api/values/LongValue.java | 4 ++-- .../lib/config/api/values/MapValue.java | 9 +++++--- .../lib/config/api/values/StringValue.java | 4 ++-- .../lib/data/mixin/BlockEntityMixin.java | 4 ++-- .../api/ServerEntityWorldChangeEvent.java | 1 - .../entity/api/ServerLivingEntityEvent.java | 1 - .../events/entity/api/ServerPlayerEvent.java | 1 - .../entity/KessokuEntityEventEntrypoint.java | 1 - .../entity/KessokuEntityEventEntrypoint.java | 2 -- .../lib/events/entity/mixin/EntityMixin.java | 13 +++++------ .../entity/mixin/IItemExtensionMixin.java | 8 +++---- .../entity/mixin/LivingEntityMixin.java | 22 ++++++++++--------- .../events/entity/mixin/MobEntityMixin.java | 5 ++--- .../entity/mixin/PlayerEntityMixin.java | 3 +-- .../entity/mixin/PlayerManagerMixin.java | 7 +++--- .../entity/mixin/ServerPlayerEntityMixin.java | 21 +++++++++--------- .../mixin/elytra/LivingEntityMixin.java | 9 ++++---- .../mixin/elytra/PlayerEntityMixin.java | 9 ++++---- .../KessokuEntrypointEntrypoint.java | 11 +++++----- .../KessokuEntrypointEntrypoint.java | 9 ++++---- .../band/kessoku/lib/event/api/Event.java | 4 ++-- .../kessoku/lib/event/impl/EventImpl.java | 6 ++--- .../lib/event/KessokuEventBaseEntrypoint.java | 1 - .../kessoku/lib/event/util/NeoEventUtils.java | 4 ++-- .../lib/keybind/api/KeyBindRegister.java | 1 - .../testmod/keybind/KessokuTestKeybind.java | 1 - .../lib/keybind/KessokuKeybindEntrypoint.java | 1 - .../lib/keybind/impl/KeyBindRegisterImpl.java | 6 ++--- .../lib/keybind/KessokuKeyBindEntrypoint.java | 1 - .../lib/keybind/impl/KeyBindRegisterImpl.java | 10 ++++----- .../lib/keybind/mixin/KeyBindingAccessor.java | 7 +++--- .../events/lifecycle/api/LifecycleEvent.java | 1 - .../lifecycle/api/ServerBlockEntityEvent.java | 1 - .../lifecycle/api/ServerChunkEvent.java | 1 - .../lifecycle/api/ServerEntityEvent.java | 1 - .../lifecycle/api/ServerLifecycleEvent.java | 1 - .../events/lifecycle/api/ServerTickEvent.java | 1 - .../lifecycle/api/ServerWorldEvent.java | 1 - .../api/client/ClientBlockEntityEvent.java | 1 - .../api/client/ClientChunkEvent.java | 1 - .../api/client/ClientEntityEvent.java | 1 - .../api/client/ClientLifecycleEvent.java | 1 - .../lifecycle/api/client/ClientTickEvent.java | 1 - .../impl/KessokuLifecycleEventsImpl.java | 1 - .../lifecycle/impl/LoadedChunksCache.java | 4 ++-- .../events/lifecycle/mixin/WorldMixin.java | 9 ++++---- .../lifecycle/KessokuTestLifecycle.java | 3 ++- .../lifecycle/ServerBlockEntityTests.java | 7 +++--- .../testmod/lifecycle/ServerEntityTests.java | 7 +++--- .../testmod/lifecycle/ServerTickTests.java | 7 +++--- .../KessokuLifecycleEventsEntrypoint.java | 1 - .../KessokuLifecycleEventsImplFabric.java | 1 - .../KessokuLifecycleEventsEntrypoint.java | 1 - .../impl/KessokuLifecycleEventsImplNeo.java | 2 -- .../mixin/neo/MinecraftServerMixin.java | 7 +++--- .../mixin/neo/ServerEntityHandlerMixin.java | 5 ++--- .../lifecycle/mixin/neo/ServerWorldMixin.java | 5 ++--- .../neo/client/ClientChunkManagerMixin.java | 17 +++++++------- .../neo/client/ClientEntityHandlerMixin.java | 5 ++--- .../client/ClientPlayNetworkHandlerMixin.java | 11 +++++----- .../neo/client/MinecraftClientMixin.java | 3 +-- .../mixin/neo/client/WorldChunkMixin.java | 15 ++++++------- .../mixin/neo/server/WorldChunkMixin.java | 13 +++++------ .../kessoku-lifecycle-events.neo.mixins.json | 2 +- .../kessoku/lib/platform/api/ModLoader.java | 4 ++-- .../platform/KessokuPlatformEntrypoint.java | 1 - .../lib/platform/impl/ModDataImpl.java | 13 +++++------ .../platform/impl/ModDependencyInfoImpl.java | 1 - .../lib/platform/impl/ModLoaderImpl.java | 11 +++++----- .../platform/KessokuPlatformEntrypoint.java | 1 - .../lib/platform/impl/ModDataImpl.java | 12 +++++----- .../platform/impl/ModDependencyInfoImpl.java | 1 - .../lib/platform/impl/ModLoaderImpl.java | 11 +++++----- .../lib/registry/api/FuelRegistry.java | 17 +++++++------- .../kessoku/lib/registry/api/Registry.java | 3 +-- .../registry/KessokuRegistryEntrypoint.java | 1 - .../lib/registry/impl/RegistryImpl.java | 1 - .../AbstractFurnaceBlockEntityMixin.java | 11 +++++----- .../registry/KessokuRegistryEntrypoint.java | 2 -- .../lib/registry/impl/RegistryImpl.java | 11 +++++----- 98 files changed, 218 insertions(+), 290 deletions(-) diff --git a/base/common/src/main/java/band/kessoku/lib/base/ModUtils.java b/base/common/src/main/java/band/kessoku/lib/base/ModUtils.java index ca3b49d0..1fc1cac6 100644 --- a/base/common/src/main/java/band/kessoku/lib/base/ModUtils.java +++ b/base/common/src/main/java/band/kessoku/lib/base/ModUtils.java @@ -15,13 +15,13 @@ */ package band.kessoku.lib.base; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.lang.reflect.Constructor; import java.util.List; import java.util.ServiceLoader; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - public class ModUtils { public static T loadService(Class clazz) { return ServiceLoader.load(clazz).findFirst().orElseThrow(() -> new AssertionError("No impl found for " + clazz.getName())); diff --git a/command/common/src/main/java/band/kessoku/lib/command/api/events/CommandRegistryEvent.java b/command/common/src/main/java/band/kessoku/lib/command/api/events/CommandRegistryEvent.java index cf7cccf3..e6f1780f 100644 --- a/command/common/src/main/java/band/kessoku/lib/command/api/events/CommandRegistryEvent.java +++ b/command/common/src/main/java/band/kessoku/lib/command/api/events/CommandRegistryEvent.java @@ -17,7 +17,6 @@ import band.kessoku.lib.event.api.Event; import com.mojang.brigadier.CommandDispatcher; - import net.minecraft.command.CommandRegistryAccess; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; diff --git a/command/common/src/test/java/kessoku/testmod/command/KessokuTestCommand.java b/command/common/src/test/java/kessoku/testmod/command/KessokuTestCommand.java index b1ff2f82..c01b1a6a 100644 --- a/command/common/src/test/java/kessoku/testmod/command/KessokuTestCommand.java +++ b/command/common/src/test/java/kessoku/testmod/command/KessokuTestCommand.java @@ -17,7 +17,6 @@ import band.kessoku.lib.command.api.events.CommandRegistryEvent; import band.kessoku.lib.entrypoint.api.KessokuModInitializer; - import net.minecraft.server.command.CommandManager; import net.minecraft.text.Text; diff --git a/command/fabric/src/main/java/band/kessoku/lib/command/KessokuCommandEntrypoint.java b/command/fabric/src/main/java/band/kessoku/lib/command/KessokuCommandEntrypoint.java index 906e9535..e37cd1f3 100644 --- a/command/fabric/src/main/java/band/kessoku/lib/command/KessokuCommandEntrypoint.java +++ b/command/fabric/src/main/java/band/kessoku/lib/command/KessokuCommandEntrypoint.java @@ -17,7 +17,6 @@ import band.kessoku.lib.base.ModUtils; import band.kessoku.lib.command.impl.KessokuCommandImpl; - import net.fabricmc.api.ModInitializer; public class KessokuCommandEntrypoint implements ModInitializer { diff --git a/command/fabric/src/main/java/band/kessoku/lib/command/impl/KessokuCommandImpl.java b/command/fabric/src/main/java/band/kessoku/lib/command/impl/KessokuCommandImpl.java index 79960bc7..565b0902 100644 --- a/command/fabric/src/main/java/band/kessoku/lib/command/impl/KessokuCommandImpl.java +++ b/command/fabric/src/main/java/band/kessoku/lib/command/impl/KessokuCommandImpl.java @@ -16,7 +16,6 @@ package band.kessoku.lib.command.impl; import band.kessoku.lib.command.api.events.CommandRegistryEvent; - import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; public class KessokuCommandImpl { diff --git a/command/neo/src/main/java/band/kessoku/lib/command/KessokuCommandEntrypoint.java b/command/neo/src/main/java/band/kessoku/lib/command/KessokuCommandEntrypoint.java index 16decb44..581e8ad9 100644 --- a/command/neo/src/main/java/band/kessoku/lib/command/KessokuCommandEntrypoint.java +++ b/command/neo/src/main/java/band/kessoku/lib/command/KessokuCommandEntrypoint.java @@ -17,7 +17,6 @@ import band.kessoku.lib.base.ModUtils; import band.kessoku.lib.command.impl.KessokuCommandImpl; - import net.neoforged.bus.api.IEventBus; import net.neoforged.fml.common.Mod; import net.neoforged.neoforge.common.NeoForge; diff --git a/command/neo/src/main/java/band/kessoku/lib/command/impl/KessokuCommandImpl.java b/command/neo/src/main/java/band/kessoku/lib/command/impl/KessokuCommandImpl.java index 9ac6a938..b265eaae 100644 --- a/command/neo/src/main/java/band/kessoku/lib/command/impl/KessokuCommandImpl.java +++ b/command/neo/src/main/java/band/kessoku/lib/command/impl/KessokuCommandImpl.java @@ -17,7 +17,6 @@ import band.kessoku.lib.command.api.events.CommandRegistryEvent; import band.kessoku.lib.event.util.NeoEventUtils; - import net.neoforged.bus.api.IEventBus; import net.neoforged.neoforge.event.RegisterCommandsEvent; diff --git a/config/common/src/main/java/band/kessoku/lib/config/KessokuConfig.java b/config/common/src/main/java/band/kessoku/lib/config/KessokuConfig.java index 8164f1d7..e9a021b1 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/KessokuConfig.java +++ b/config/common/src/main/java/band/kessoku/lib/config/KessokuConfig.java @@ -15,12 +15,6 @@ */ package band.kessoku.lib.config; -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - import band.kessoku.lib.config.api.AbstractConfig; import band.kessoku.lib.config.api.ConfigSerializer; import org.apache.commons.io.FileUtils; @@ -30,6 +24,11 @@ import org.slf4j.Marker; import org.slf4j.MarkerFactory; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + public final class KessokuConfig { private static final Map> configs = new HashMap<>(); private static final Map, ConfigSerializer> serializerCache = new HashMap<>(); diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java b/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java index 6f4d70ce..2c3041bf 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java @@ -15,17 +15,6 @@ */ package band.kessoku.lib.config.api; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.nio.charset.StandardCharsets; -import java.nio.file.Path; -import java.util.*; -import java.util.function.BiConsumer; -import java.util.function.Consumer; - import band.kessoku.lib.base.ModUtils; import band.kessoku.lib.config.KessokuConfig; import band.kessoku.lib.config.api.annotations.Comment; @@ -37,6 +26,17 @@ import org.apache.commons.io.FilenameUtils; import org.apache.logging.log4j.core.util.ReflectionUtil; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.nio.charset.StandardCharsets; +import java.nio.file.Path; +import java.util.*; +import java.util.function.BiConsumer; +import java.util.function.Consumer; + @SuppressWarnings({"rawtypes", "unused"}) public abstract class AbstractConfig { private final List> preSave = new ArrayList<>(); diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/Json5Serializer.java b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/Json5Serializer.java index e206fd37..3e5c3f40 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/Json5Serializer.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/Json5Serializer.java @@ -15,14 +15,14 @@ */ package band.kessoku.lib.config.api.serializers; -import java.util.Map; - import band.kessoku.lib.config.api.AbstractConfig; import band.kessoku.lib.config.api.ConfigSerializer; import club.someoneice.json.JSON; import club.someoneice.json.node.JsonNode; import club.someoneice.json.processor.Json5Builder; +import java.util.Map; + // TODO public class Json5Serializer implements ConfigSerializer { @Override diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/JsonSerializer.java b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/JsonSerializer.java index 04edba7e..38d331a4 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/JsonSerializer.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/JsonSerializer.java @@ -15,8 +15,6 @@ */ package band.kessoku.lib.config.api.serializers; -import java.util.Map; - import band.kessoku.lib.config.api.AbstractConfig; import band.kessoku.lib.config.api.ConfigSerializer; import club.someoneice.json.JSON; @@ -25,6 +23,8 @@ import club.someoneice.json.node.MapNode; import club.someoneice.json.processor.JsonBuilder; +import java.util.Map; + public class JsonSerializer implements ConfigSerializer { @Override public String serialize(Map value) { diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/TomlSerializer.java b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/TomlSerializer.java index 23bbd29c..5b5afe5b 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/TomlSerializer.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/TomlSerializer.java @@ -15,12 +15,12 @@ */ package band.kessoku.lib.config.api.serializers; -import java.util.Map; - import band.kessoku.lib.config.api.AbstractConfig; import band.kessoku.lib.config.api.ConfigSerializer; import com.electronwill.nightconfig.core.CommentedConfig; +import java.util.Map; + //todo public class TomlSerializer implements ConfigSerializer { @Override diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/BooleanValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/BooleanValue.java index 34ff72d2..b9120543 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/BooleanValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/BooleanValue.java @@ -15,11 +15,11 @@ */ package band.kessoku.lib.config.api.values; -import java.util.function.Supplier; - import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; +import java.util.function.Supplier; + public final class BooleanValue extends DefaultConfigValue { private BooleanValue(Supplier defaultValue) { super(defaultValue); diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/DefaultConfigValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/DefaultConfigValue.java index 220814f5..460c8623 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/DefaultConfigValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/DefaultConfigValue.java @@ -15,10 +15,10 @@ */ package band.kessoku.lib.config.api.values; -import java.util.function.Supplier; - import band.kessoku.lib.config.api.ConfigValue; +import java.util.function.Supplier; + sealed abstract class DefaultConfigValue implements ConfigValue permits BooleanValue, DoubleValue, FloatValue, IntegerValue, ListValue, LongValue, MapValue, StringValue { public final Supplier defaultValue; public T value; diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/DoubleValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/DoubleValue.java index 966e0913..3c05a1b7 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/DoubleValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/DoubleValue.java @@ -15,11 +15,11 @@ */ package band.kessoku.lib.config.api.values; -import java.util.function.Supplier; - import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; +import java.util.function.Supplier; + public final class DoubleValue extends DefaultConfigValue { private DoubleValue(Supplier defaultValue) { super(defaultValue); diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/FloatValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/FloatValue.java index 40a495d4..1d66d0ff 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/FloatValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/FloatValue.java @@ -15,11 +15,11 @@ */ package band.kessoku.lib.config.api.values; -import java.util.function.Supplier; - import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; +import java.util.function.Supplier; + public final class FloatValue extends DefaultConfigValue { private FloatValue(Supplier defaultValue) { super(defaultValue); diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/IntegerValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/IntegerValue.java index b8f778f1..ce7539cb 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/IntegerValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/IntegerValue.java @@ -15,11 +15,11 @@ */ package band.kessoku.lib.config.api.values; -import java.util.function.Supplier; - import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; +import java.util.function.Supplier; + public final class IntegerValue extends DefaultConfigValue { private IntegerValue(Supplier defaultValue) { super(defaultValue); diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/ListValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/ListValue.java index 193d9a63..ecf17e84 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/ListValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/ListValue.java @@ -15,14 +15,14 @@ */ package band.kessoku.lib.config.api.values; -import java.util.*; -import java.util.function.Supplier; - import com.google.common.collect.ImmutableList; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Unmodifiable; +import java.util.*; +import java.util.function.Supplier; + @SuppressWarnings({"rawtypes"}) public final class ListValue extends DefaultConfigValue> implements List { private ListValue(Supplier> defaultValue) { diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/LongValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/LongValue.java index e068ea14..2de89dc5 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/LongValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/LongValue.java @@ -15,11 +15,11 @@ */ package band.kessoku.lib.config.api.values; -import java.util.function.Supplier; - import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; +import java.util.function.Supplier; + public final class LongValue extends DefaultConfigValue { private LongValue(Supplier defaultValue) { super(defaultValue); diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/MapValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/MapValue.java index 9a583caf..39858f37 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/MapValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/MapValue.java @@ -15,15 +15,18 @@ */ package band.kessoku.lib.config.api.values; -import java.util.*; -import java.util.function.Supplier; - import com.google.common.collect.ImmutableMap; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Unmodifiable; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.function.Supplier; + public final class MapValue extends DefaultConfigValue> implements Map { private MapValue(Supplier> defaultValue) { super(defaultValue); diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/StringValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/StringValue.java index db6a43aa..6d75a28e 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/StringValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/StringValue.java @@ -15,11 +15,11 @@ */ package band.kessoku.lib.config.api.values; -import java.util.function.Supplier; - import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; +import java.util.function.Supplier; + public final class StringValue extends DefaultConfigValue { private StringValue(Supplier defaultValue) { super(defaultValue); diff --git a/data/common/src/main/java/band/kessoku/lib/data/mixin/BlockEntityMixin.java b/data/common/src/main/java/band/kessoku/lib/data/mixin/BlockEntityMixin.java index 959b7b27..d01a2982 100644 --- a/data/common/src/main/java/band/kessoku/lib/data/mixin/BlockEntityMixin.java +++ b/data/common/src/main/java/band/kessoku/lib/data/mixin/BlockEntityMixin.java @@ -1,9 +1,9 @@ package band.kessoku.lib.data.mixin; +import band.kessoku.lib.data.api.BlockEntityStructure; import band.kessoku.lib.data.api.Data; -import band.kessoku.lib.data.api.NBTSerializable; import band.kessoku.lib.data.api.DataStructure; -import band.kessoku.lib.data.api.BlockEntityStructure; +import band.kessoku.lib.data.api.NBTSerializable; import net.minecraft.block.entity.BlockEntity; import net.minecraft.nbt.NbtCompound; import net.minecraft.registry.RegistryWrapper; diff --git a/entity-events/common/src/main/java/band/kessoku/lib/events/entity/api/ServerEntityWorldChangeEvent.java b/entity-events/common/src/main/java/band/kessoku/lib/events/entity/api/ServerEntityWorldChangeEvent.java index 724fb1d7..1208e598 100644 --- a/entity-events/common/src/main/java/band/kessoku/lib/events/entity/api/ServerEntityWorldChangeEvent.java +++ b/entity-events/common/src/main/java/band/kessoku/lib/events/entity/api/ServerEntityWorldChangeEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.entity.api; import band.kessoku.lib.event.api.Event; - import net.minecraft.entity.Entity; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; diff --git a/entity-events/common/src/main/java/band/kessoku/lib/events/entity/api/ServerLivingEntityEvent.java b/entity-events/common/src/main/java/band/kessoku/lib/events/entity/api/ServerLivingEntityEvent.java index 359aa10e..55a8602f 100644 --- a/entity-events/common/src/main/java/band/kessoku/lib/events/entity/api/ServerLivingEntityEvent.java +++ b/entity-events/common/src/main/java/band/kessoku/lib/events/entity/api/ServerLivingEntityEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.entity.api; import band.kessoku.lib.event.api.Event; - import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.mob.MobEntity; diff --git a/entity-events/common/src/main/java/band/kessoku/lib/events/entity/api/ServerPlayerEvent.java b/entity-events/common/src/main/java/band/kessoku/lib/events/entity/api/ServerPlayerEvent.java index 2f70fa21..6a00958f 100644 --- a/entity-events/common/src/main/java/band/kessoku/lib/events/entity/api/ServerPlayerEvent.java +++ b/entity-events/common/src/main/java/band/kessoku/lib/events/entity/api/ServerPlayerEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.entity.api; import band.kessoku.lib.event.api.Event; - import net.minecraft.server.network.ServerPlayerEntity; public class ServerPlayerEvent { diff --git a/entity-events/fabric/src/main/java/band/kessoku/lib/events/entity/KessokuEntityEventEntrypoint.java b/entity-events/fabric/src/main/java/band/kessoku/lib/events/entity/KessokuEntityEventEntrypoint.java index d1b65fdd..9ae2dcc4 100644 --- a/entity-events/fabric/src/main/java/band/kessoku/lib/events/entity/KessokuEntityEventEntrypoint.java +++ b/entity-events/fabric/src/main/java/band/kessoku/lib/events/entity/KessokuEntityEventEntrypoint.java @@ -17,7 +17,6 @@ import band.kessoku.lib.events.entity.api.EntityElytraEvent; import band.kessoku.lib.events.entity.api.EntitySleepEvent; - import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.entity.event.v1.EntityElytraEvents; import net.fabricmc.fabric.api.entity.event.v1.EntitySleepEvents; diff --git a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/KessokuEntityEventEntrypoint.java b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/KessokuEntityEventEntrypoint.java index 18e450ca..1355e9a2 100644 --- a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/KessokuEntityEventEntrypoint.java +++ b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/KessokuEntityEventEntrypoint.java @@ -19,12 +19,10 @@ import band.kessoku.lib.events.entity.api.EntitySleepEvent; import band.kessoku.lib.events.entity.api.ServerLivingEntityEvent; import band.kessoku.lib.events.entity.api.ServerPlayerEvent; - import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.ActionResult; - import net.neoforged.fml.common.Mod; import net.neoforged.neoforge.common.NeoForge; import net.neoforged.neoforge.event.entity.living.LivingConversionEvent; diff --git a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/EntityMixin.java b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/EntityMixin.java index a771b369..bbc7b00b 100644 --- a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/EntityMixin.java +++ b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/EntityMixin.java @@ -15,21 +15,20 @@ */ package band.kessoku.lib.events.entity.mixin; -import java.util.Set; - import band.kessoku.lib.events.entity.api.ServerEntityWorldChangeEvent; import com.llamalad7.mixinextras.sugar.Local; +import net.minecraft.entity.Entity; +import net.minecraft.network.packet.s2c.play.PositionFlag; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.world.TeleportTarget; +import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.entity.Entity; -import net.minecraft.network.packet.s2c.play.PositionFlag; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.world.TeleportTarget; -import net.minecraft.world.World; +import java.util.Set; @Mixin(Entity.class) abstract class EntityMixin { diff --git a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/IItemExtensionMixin.java b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/IItemExtensionMixin.java index 7605d65e..7156960e 100644 --- a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/IItemExtensionMixin.java +++ b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/IItemExtensionMixin.java @@ -16,16 +16,14 @@ package band.kessoku.lib.events.entity.mixin; import band.kessoku.lib.events.entity.api.item.KessokuElytraItem; +import net.minecraft.entity.LivingEntity; +import net.minecraft.item.ItemStack; +import net.neoforged.neoforge.common.extensions.IItemExtension; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.ItemStack; - -import net.neoforged.neoforge.common.extensions.IItemExtension; - @Mixin(IItemExtension.class) public interface IItemExtensionMixin { @Inject(method = "canElytraFly", at = @At("HEAD"), cancellable = true) diff --git a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/LivingEntityMixin.java b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/LivingEntityMixin.java index 89c9a4f5..8f7a3141 100644 --- a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/LivingEntityMixin.java +++ b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/LivingEntityMixin.java @@ -15,22 +15,12 @@ */ package band.kessoku.lib.events.entity.mixin; -import java.util.Optional; - import band.kessoku.lib.events.entity.api.EntitySleepEvent; import band.kessoku.lib.events.entity.api.ServerEntityCombatEvent; import band.kessoku.lib.events.entity.api.ServerLivingEntityEvent; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.llamalad7.mixinextras.sugar.Local; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Dynamic; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.*; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - import net.minecraft.block.BedBlock; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -46,6 +36,18 @@ import net.minecraft.world.CollisionView; import net.minecraft.world.World; import net.minecraft.world.WorldView; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Dynamic; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.Optional; @Mixin(LivingEntity.class) diff --git a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/MobEntityMixin.java b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/MobEntityMixin.java index beadba7d..ee612144 100644 --- a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/MobEntityMixin.java +++ b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/MobEntityMixin.java @@ -17,13 +17,12 @@ import band.kessoku.lib.events.entity.api.ServerLivingEntityEvent; import com.llamalad7.mixinextras.sugar.Local; +import net.minecraft.entity.Entity; +import net.minecraft.entity.mob.MobEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyArg; -import net.minecraft.entity.Entity; -import net.minecraft.entity.mob.MobEntity; - @Mixin(MobEntity.class) public class MobEntityMixin { @ModifyArg(method = "convertTo", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;spawnEntity(Lnet/minecraft/entity/Entity;)Z")) diff --git a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/PlayerEntityMixin.java b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/PlayerEntityMixin.java index 3a33f202..3a4e042d 100644 --- a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/PlayerEntityMixin.java +++ b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/PlayerEntityMixin.java @@ -16,13 +16,12 @@ package band.kessoku.lib.events.entity.mixin; import band.kessoku.lib.events.entity.api.EntitySleepEvent; +import net.minecraft.entity.player.PlayerEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.entity.player.PlayerEntity; - @Mixin(PlayerEntity.class) abstract class PlayerEntityMixin { @Inject(method = "canResetTimeBySleeping", at = @At("RETURN"), cancellable = true) diff --git a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/PlayerManagerMixin.java b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/PlayerManagerMixin.java index d4a2d9e8..e9e255a3 100644 --- a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/PlayerManagerMixin.java +++ b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/PlayerManagerMixin.java @@ -16,15 +16,14 @@ package band.kessoku.lib.events.entity.mixin; import band.kessoku.lib.events.entity.api.ServerPlayerEvent; +import net.minecraft.entity.Entity; +import net.minecraft.server.PlayerManager; +import net.minecraft.server.network.ServerPlayerEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.entity.Entity; -import net.minecraft.server.PlayerManager; -import net.minecraft.server.network.ServerPlayerEntity; - @Mixin(PlayerManager.class) abstract class PlayerManagerMixin { @Inject(method = "respawnPlayer", at = @At("TAIL")) diff --git a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/ServerPlayerEntityMixin.java b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/ServerPlayerEntityMixin.java index 1c45fd24..78e9dc39 100644 --- a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/ServerPlayerEntityMixin.java +++ b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/ServerPlayerEntityMixin.java @@ -15,20 +15,9 @@ */ package band.kessoku.lib.events.entity.mixin; -import java.util.List; - import band.kessoku.lib.events.entity.api.*; import com.llamalad7.mixinextras.sugar.Local; import com.mojang.datafixers.util.Either; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; @@ -44,6 +33,16 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.World; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.List; @Mixin(ServerPlayerEntity.class) abstract class ServerPlayerEntityMixin extends LivingEntityMixin { diff --git a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/elytra/LivingEntityMixin.java b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/elytra/LivingEntityMixin.java index 3e5c653d..6d1bc813 100644 --- a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/elytra/LivingEntityMixin.java +++ b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/elytra/LivingEntityMixin.java @@ -16,15 +16,14 @@ package band.kessoku.lib.events.entity.mixin.elytra; import band.kessoku.lib.events.entity.api.EntityElytraEvent; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @SuppressWarnings("unused") @Mixin(LivingEntity.class) diff --git a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/elytra/PlayerEntityMixin.java b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/elytra/PlayerEntityMixin.java index 61431727..4f976263 100644 --- a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/elytra/PlayerEntityMixin.java +++ b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/elytra/PlayerEntityMixin.java @@ -16,17 +16,16 @@ package band.kessoku.lib.events.entity.mixin.elytra; import band.kessoku.lib.events.entity.api.EntityElytraEvent; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.world.World; - @SuppressWarnings("unused") @Mixin(PlayerEntity.class) abstract class PlayerEntityMixin extends LivingEntity { diff --git a/entrypoint/fabric/src/main/java/band/kessoku/lib/entrypoint/KessokuEntrypointEntrypoint.java b/entrypoint/fabric/src/main/java/band/kessoku/lib/entrypoint/KessokuEntrypointEntrypoint.java index 77ebc5b7..d26a67db 100644 --- a/entrypoint/fabric/src/main/java/band/kessoku/lib/entrypoint/KessokuEntrypointEntrypoint.java +++ b/entrypoint/fabric/src/main/java/band/kessoku/lib/entrypoint/KessokuEntrypointEntrypoint.java @@ -15,17 +15,11 @@ */ package band.kessoku.lib.entrypoint; -import java.lang.reflect.InvocationTargetException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Map; - import band.kessoku.lib.base.ModUtils; import band.kessoku.lib.entrypoint.api.KessokuClientModInitializer; import band.kessoku.lib.entrypoint.api.KessokuDedicatedServerModInitializer; import band.kessoku.lib.entrypoint.api.KessokuModInitializer; import com.google.common.collect.ImmutableMap; - import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.DedicatedServerModInitializer; import net.fabricmc.api.ModInitializer; @@ -33,6 +27,11 @@ import net.fabricmc.loader.api.ModContainer; import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint; +import java.lang.reflect.InvocationTargetException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Map; + public class KessokuEntrypointEntrypoint implements ModInitializer, ClientModInitializer, DedicatedServerModInitializer, PreLaunchEntrypoint { private static ImmutableMap modInfoList; diff --git a/entrypoint/neo/src/main/java/band/kessoku/lib/entrypoint/KessokuEntrypointEntrypoint.java b/entrypoint/neo/src/main/java/band/kessoku/lib/entrypoint/KessokuEntrypointEntrypoint.java index 95b992b1..3585114b 100644 --- a/entrypoint/neo/src/main/java/band/kessoku/lib/entrypoint/KessokuEntrypointEntrypoint.java +++ b/entrypoint/neo/src/main/java/band/kessoku/lib/entrypoint/KessokuEntrypointEntrypoint.java @@ -15,20 +15,19 @@ */ package band.kessoku.lib.entrypoint; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import band.kessoku.lib.base.ModUtils; import band.kessoku.lib.entrypoint.api.KessokuClientModInitializer; import band.kessoku.lib.entrypoint.api.KessokuDedicatedServerModInitializer; import band.kessoku.lib.entrypoint.api.KessokuModInitializer; import com.google.common.collect.ImmutableList; - import net.neoforged.api.distmarker.Dist; import net.neoforged.fml.ModList; import net.neoforged.fml.common.Mod; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + @Mod(KessokuEntrypoint.MOD_ID) public final class KessokuEntrypointEntrypoint { private static final Map> entrypointMap = new HashMap<>(); diff --git a/event-base/common/src/main/java/band/kessoku/lib/event/api/Event.java b/event-base/common/src/main/java/band/kessoku/lib/event/api/Event.java index 667fb68f..c2d742fb 100644 --- a/event-base/common/src/main/java/band/kessoku/lib/event/api/Event.java +++ b/event-base/common/src/main/java/band/kessoku/lib/event/api/Event.java @@ -15,11 +15,11 @@ */ package band.kessoku.lib.event.api; +import band.kessoku.lib.event.impl.EventImpl; + import java.util.List; import java.util.function.Function; -import band.kessoku.lib.event.impl.EventImpl; - public interface Event { T invoker(); diff --git a/event-base/common/src/main/java/band/kessoku/lib/event/impl/EventImpl.java b/event-base/common/src/main/java/band/kessoku/lib/event/impl/EventImpl.java index 15d17394..9336c11f 100644 --- a/event-base/common/src/main/java/band/kessoku/lib/event/impl/EventImpl.java +++ b/event-base/common/src/main/java/band/kessoku/lib/event/impl/EventImpl.java @@ -15,15 +15,15 @@ */ package band.kessoku.lib.event.impl; +import band.kessoku.lib.event.api.Event; +import band.kessoku.lib.event.api.EventPhase; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.Function; -import band.kessoku.lib.event.api.Event; -import band.kessoku.lib.event.api.EventPhase; - public class EventImpl implements Event { private Map> listeners = new HashMap<>(); diff --git a/event-base/fabric/src/main/java/band/kessoku/lib/event/KessokuEventBaseEntrypoint.java b/event-base/fabric/src/main/java/band/kessoku/lib/event/KessokuEventBaseEntrypoint.java index 2b954047..a41b9cec 100644 --- a/event-base/fabric/src/main/java/band/kessoku/lib/event/KessokuEventBaseEntrypoint.java +++ b/event-base/fabric/src/main/java/band/kessoku/lib/event/KessokuEventBaseEntrypoint.java @@ -16,7 +16,6 @@ package band.kessoku.lib.event; import band.kessoku.lib.base.ModUtils; - import net.fabricmc.api.ModInitializer; public class KessokuEventBaseEntrypoint implements ModInitializer { diff --git a/event-base/neo/src/main/java/band/kessoku/lib/event/util/NeoEventUtils.java b/event-base/neo/src/main/java/band/kessoku/lib/event/util/NeoEventUtils.java index 96d4d952..7684094d 100644 --- a/event-base/neo/src/main/java/band/kessoku/lib/event/util/NeoEventUtils.java +++ b/event-base/neo/src/main/java/band/kessoku/lib/event/util/NeoEventUtils.java @@ -15,12 +15,12 @@ */ package band.kessoku.lib.event.util; -import java.util.function.Consumer; - import net.neoforged.bus.api.Event; import net.neoforged.bus.api.EventPriority; import net.neoforged.bus.api.IEventBus; +import java.util.function.Consumer; + public class NeoEventUtils { public static void registerEvent(IEventBus eventBus, Class eventClass, Consumer consumer) { eventBus.addListener(EventPriority.HIGHEST, eventClass, consumer); diff --git a/keybind/common/src/main/java/band/kessoku/lib/keybind/api/KeyBindRegister.java b/keybind/common/src/main/java/band/kessoku/lib/keybind/api/KeyBindRegister.java index 4b093883..2cbf21a0 100644 --- a/keybind/common/src/main/java/band/kessoku/lib/keybind/api/KeyBindRegister.java +++ b/keybind/common/src/main/java/band/kessoku/lib/keybind/api/KeyBindRegister.java @@ -16,7 +16,6 @@ package band.kessoku.lib.keybind.api; import band.kessoku.lib.keybind.impl.KessokuKeyBindService; - import net.minecraft.client.option.KeyBinding; import net.minecraft.client.util.InputUtil; diff --git a/keybind/common/src/test/java/kessoku/testmod/keybind/KessokuTestKeybind.java b/keybind/common/src/test/java/kessoku/testmod/keybind/KessokuTestKeybind.java index f29c5bf1..f0b7f9ca 100644 --- a/keybind/common/src/test/java/kessoku/testmod/keybind/KessokuTestKeybind.java +++ b/keybind/common/src/test/java/kessoku/testmod/keybind/KessokuTestKeybind.java @@ -17,7 +17,6 @@ import band.kessoku.lib.entrypoint.api.KessokuModInitializer; import band.kessoku.lib.keybind.api.KeyBindRegister; - import net.minecraft.client.option.KeyBinding; public class KessokuTestKeybind implements KessokuModInitializer { diff --git a/keybind/fabric/src/main/java/band/kessoku/lib/keybind/KessokuKeybindEntrypoint.java b/keybind/fabric/src/main/java/band/kessoku/lib/keybind/KessokuKeybindEntrypoint.java index 8f7747ca..dd08fd87 100644 --- a/keybind/fabric/src/main/java/band/kessoku/lib/keybind/KessokuKeybindEntrypoint.java +++ b/keybind/fabric/src/main/java/band/kessoku/lib/keybind/KessokuKeybindEntrypoint.java @@ -16,7 +16,6 @@ package band.kessoku.lib.keybind; import band.kessoku.lib.base.ModUtils; - import net.fabricmc.api.ClientModInitializer; public class KessokuKeybindEntrypoint implements ClientModInitializer { diff --git a/keybind/fabric/src/main/java/band/kessoku/lib/keybind/impl/KeyBindRegisterImpl.java b/keybind/fabric/src/main/java/band/kessoku/lib/keybind/impl/KeyBindRegisterImpl.java index 832ac4c0..d5764291 100644 --- a/keybind/fabric/src/main/java/band/kessoku/lib/keybind/impl/KeyBindRegisterImpl.java +++ b/keybind/fabric/src/main/java/band/kessoku/lib/keybind/impl/KeyBindRegisterImpl.java @@ -17,12 +17,10 @@ import band.kessoku.lib.keybind.api.KeyBindRegister; import com.google.auto.service.AutoService; - -import net.minecraft.client.option.KeyBinding; -import net.minecraft.client.util.InputUtil; - import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.fabricmc.fabric.impl.client.keybinding.KeyBindingRegistryImpl; +import net.minecraft.client.option.KeyBinding; +import net.minecraft.client.util.InputUtil; @AutoService(KeyBindRegister.class) public class KeyBindRegisterImpl implements KeyBindRegister { diff --git a/keybind/neo/src/main/java/band/kessoku/lib/keybind/KessokuKeyBindEntrypoint.java b/keybind/neo/src/main/java/band/kessoku/lib/keybind/KessokuKeyBindEntrypoint.java index b1f8642a..08b76ae1 100644 --- a/keybind/neo/src/main/java/band/kessoku/lib/keybind/KessokuKeyBindEntrypoint.java +++ b/keybind/neo/src/main/java/band/kessoku/lib/keybind/KessokuKeyBindEntrypoint.java @@ -17,7 +17,6 @@ import band.kessoku.lib.base.ModUtils; import band.kessoku.lib.keybind.impl.KeyBindRegisterImpl; - import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.IEventBus; import net.neoforged.fml.common.Mod; diff --git a/keybind/neo/src/main/java/band/kessoku/lib/keybind/impl/KeyBindRegisterImpl.java b/keybind/neo/src/main/java/band/kessoku/lib/keybind/impl/KeyBindRegisterImpl.java index 6ca1fe4f..09c9e343 100644 --- a/keybind/neo/src/main/java/band/kessoku/lib/keybind/impl/KeyBindRegisterImpl.java +++ b/keybind/neo/src/main/java/band/kessoku/lib/keybind/impl/KeyBindRegisterImpl.java @@ -15,22 +15,20 @@ */ package band.kessoku.lib.keybind.impl; -import java.util.List; -import java.util.Map; -import java.util.Optional; - import band.kessoku.lib.event.util.NeoEventUtils; import band.kessoku.lib.keybind.api.KeyBindRegister; import band.kessoku.lib.keybind.mixin.KeyBindingAccessor; import com.google.auto.service.AutoService; import it.unimi.dsi.fastutil.objects.ReferenceArrayList; - import net.minecraft.client.option.KeyBinding; import net.minecraft.client.util.InputUtil; - import net.neoforged.bus.api.IEventBus; import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent; +import java.util.List; +import java.util.Map; +import java.util.Optional; + @AutoService(KeyBindRegister.class) public class KeyBindRegisterImpl implements KeyBindRegister { private static final List KEY_BINDINGS = new ReferenceArrayList<>(); diff --git a/keybind/neo/src/main/java/band/kessoku/lib/keybind/mixin/KeyBindingAccessor.java b/keybind/neo/src/main/java/band/kessoku/lib/keybind/mixin/KeyBindingAccessor.java index 6af6106e..761b190d 100644 --- a/keybind/neo/src/main/java/band/kessoku/lib/keybind/mixin/KeyBindingAccessor.java +++ b/keybind/neo/src/main/java/band/kessoku/lib/keybind/mixin/KeyBindingAccessor.java @@ -15,13 +15,12 @@ */ package band.kessoku.lib.keybind.mixin; -import java.util.Map; - +import net.minecraft.client.option.KeyBinding; +import net.minecraft.client.util.InputUtil; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import net.minecraft.client.option.KeyBinding; -import net.minecraft.client.util.InputUtil; +import java.util.Map; @Mixin(KeyBinding.class) public interface KeyBindingAccessor { diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/LifecycleEvent.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/LifecycleEvent.java index 8eac0596..8da71c44 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/LifecycleEvent.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/LifecycleEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.lifecycle.api; import band.kessoku.lib.event.api.Event; - import net.minecraft.registry.DynamicRegistryManager; public class LifecycleEvent { diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerBlockEntityEvent.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerBlockEntityEvent.java index a361d47b..be8f5023 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerBlockEntityEvent.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerBlockEntityEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.lifecycle.api; import band.kessoku.lib.event.api.Event; - import net.minecraft.block.entity.BlockEntity; import net.minecraft.server.world.ServerWorld; diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerChunkEvent.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerChunkEvent.java index df360d56..56281165 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerChunkEvent.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerChunkEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.lifecycle.api; import band.kessoku.lib.event.api.Event; - import net.minecraft.server.world.ServerWorld; import net.minecraft.world.chunk.WorldChunk; diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerEntityEvent.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerEntityEvent.java index 5317a735..541e7f99 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerEntityEvent.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerEntityEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.lifecycle.api; import band.kessoku.lib.event.api.Event; - import net.minecraft.entity.Entity; import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.LivingEntity; diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerLifecycleEvent.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerLifecycleEvent.java index d09a8556..83855139 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerLifecycleEvent.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerLifecycleEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.lifecycle.api; import band.kessoku.lib.event.api.Event; - import net.minecraft.resource.LifecycledResourceManager; import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayerEntity; diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerTickEvent.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerTickEvent.java index c243dc31..ff4ff747 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerTickEvent.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerTickEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.lifecycle.api; import band.kessoku.lib.event.api.Event; - import net.minecraft.server.MinecraftServer; import net.minecraft.server.world.ServerWorld; diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerWorldEvent.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerWorldEvent.java index 90c799a6..ab56c956 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerWorldEvent.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerWorldEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.lifecycle.api; import band.kessoku.lib.event.api.Event; - import net.minecraft.server.MinecraftServer; import net.minecraft.server.world.ServerWorld; diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientBlockEntityEvent.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientBlockEntityEvent.java index cfe0a47e..8236ef45 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientBlockEntityEvent.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientBlockEntityEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.lifecycle.api.client; import band.kessoku.lib.event.api.Event; - import net.minecraft.block.entity.BlockEntity; import net.minecraft.client.world.ClientWorld; diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientChunkEvent.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientChunkEvent.java index 3ba54e83..902aa49e 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientChunkEvent.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientChunkEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.lifecycle.api.client; import band.kessoku.lib.event.api.Event; - import net.minecraft.client.world.ClientWorld; import net.minecraft.world.chunk.WorldChunk; diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientEntityEvent.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientEntityEvent.java index 6648b8a2..f7723e72 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientEntityEvent.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientEntityEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.lifecycle.api.client; import band.kessoku.lib.event.api.Event; - import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientLifecycleEvent.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientLifecycleEvent.java index b1077d81..c86a245b 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientLifecycleEvent.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientLifecycleEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.lifecycle.api.client; import band.kessoku.lib.event.api.Event; - import net.minecraft.client.MinecraftClient; public class ClientLifecycleEvent { diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientTickEvent.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientTickEvent.java index d9350779..16afe29a 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientTickEvent.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientTickEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.lifecycle.api.client; import band.kessoku.lib.event.api.Event; - import net.minecraft.client.MinecraftClient; import net.minecraft.client.world.ClientWorld; diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/impl/KessokuLifecycleEventsImpl.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/impl/KessokuLifecycleEventsImpl.java index 8474941f..9e6a35ea 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/impl/KessokuLifecycleEventsImpl.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/impl/KessokuLifecycleEventsImpl.java @@ -19,7 +19,6 @@ import band.kessoku.lib.events.lifecycle.api.ServerChunkEvent; import band.kessoku.lib.events.lifecycle.api.ServerEntityEvent; import band.kessoku.lib.events.lifecycle.api.ServerWorldEvent; - import net.minecraft.block.entity.BlockEntity; import net.minecraft.entity.Entity; import net.minecraft.world.chunk.WorldChunk; diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/impl/LoadedChunksCache.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/impl/LoadedChunksCache.java index 3ce366bd..8a0140ef 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/impl/LoadedChunksCache.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/impl/LoadedChunksCache.java @@ -15,10 +15,10 @@ */ package band.kessoku.lib.events.lifecycle.impl; -import java.util.Set; - import net.minecraft.world.chunk.WorldChunk; +import java.util.Set; + /** * A simple marker interface which holds references to chunks which block entities may be loaded or unloaded from. */ diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/mixin/WorldMixin.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/mixin/WorldMixin.java index 2cb52317..68a19b0c 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/mixin/WorldMixin.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/mixin/WorldMixin.java @@ -15,15 +15,14 @@ */ package band.kessoku.lib.events.lifecycle.mixin; -import java.util.HashSet; -import java.util.Set; - import band.kessoku.lib.events.lifecycle.impl.LoadedChunksCache; +import net.minecraft.world.World; +import net.minecraft.world.chunk.WorldChunk; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; -import net.minecraft.world.World; -import net.minecraft.world.chunk.WorldChunk; +import java.util.HashSet; +import java.util.Set; @Mixin(World.class) public abstract class WorldMixin implements LoadedChunksCache { diff --git a/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/KessokuTestLifecycle.java b/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/KessokuTestLifecycle.java index c404f6ac..7378a833 100644 --- a/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/KessokuTestLifecycle.java +++ b/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/KessokuTestLifecycle.java @@ -16,7 +16,8 @@ package kessoku.testmod.lifecycle; import band.kessoku.lib.entrypoint.api.KessokuModInitializer; -import band.kessoku.lib.events.lifecycle.api.*; +import band.kessoku.lib.events.lifecycle.api.ServerChunkEvent; +import band.kessoku.lib.events.lifecycle.api.ServerLifecycleEvent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/ServerBlockEntityTests.java b/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/ServerBlockEntityTests.java index 6014007c..83d6ef65 100644 --- a/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/ServerBlockEntityTests.java +++ b/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/ServerBlockEntityTests.java @@ -15,15 +15,14 @@ */ package kessoku.testmod.lifecycle; -import java.util.ArrayList; -import java.util.List; - import band.kessoku.lib.entrypoint.api.KessokuModInitializer; import band.kessoku.lib.events.lifecycle.api.ServerBlockEntityEvent; - import net.minecraft.block.entity.BlockEntity; import net.minecraft.registry.Registries; +import java.util.ArrayList; +import java.util.List; + public class ServerBlockEntityTests implements KessokuModInitializer { private final List serverBlockEntities = new ArrayList<>(); diff --git a/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/ServerEntityTests.java b/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/ServerEntityTests.java index 8b790b6a..9267e48f 100644 --- a/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/ServerEntityTests.java +++ b/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/ServerEntityTests.java @@ -15,14 +15,13 @@ */ package kessoku.testmod.lifecycle; -import java.util.ArrayList; -import java.util.List; - import band.kessoku.lib.entrypoint.api.KessokuModInitializer; import band.kessoku.lib.events.lifecycle.api.ServerEntityEvent; - import net.minecraft.entity.Entity; +import java.util.ArrayList; +import java.util.List; + public class ServerEntityTests implements KessokuModInitializer { private final List serverEntities = new ArrayList<>(); diff --git a/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/ServerTickTests.java b/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/ServerTickTests.java index 2da00487..3d7dfa89 100644 --- a/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/ServerTickTests.java +++ b/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/ServerTickTests.java @@ -15,15 +15,14 @@ */ package kessoku.testmod.lifecycle; -import java.util.HashMap; -import java.util.Map; - import band.kessoku.lib.entrypoint.api.KessokuModInitializer; import band.kessoku.lib.events.lifecycle.api.ServerTickEvent; - import net.minecraft.registry.RegistryKey; import net.minecraft.world.World; +import java.util.HashMap; +import java.util.Map; + public class ServerTickTests implements KessokuModInitializer { private final Map, Integer> tickTracker = new HashMap<>(); diff --git a/lifecycle-events/fabric/src/main/java/band/kessoku/lib/events/lifecycle/KessokuLifecycleEventsEntrypoint.java b/lifecycle-events/fabric/src/main/java/band/kessoku/lib/events/lifecycle/KessokuLifecycleEventsEntrypoint.java index 29c6ab5f..2dccd782 100644 --- a/lifecycle-events/fabric/src/main/java/band/kessoku/lib/events/lifecycle/KessokuLifecycleEventsEntrypoint.java +++ b/lifecycle-events/fabric/src/main/java/band/kessoku/lib/events/lifecycle/KessokuLifecycleEventsEntrypoint.java @@ -17,7 +17,6 @@ import band.kessoku.lib.base.ModUtils; import band.kessoku.lib.events.lifecycle.impl.KessokuLifecycleEventsImplFabric; - import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.ModInitializer; diff --git a/lifecycle-events/fabric/src/main/java/band/kessoku/lib/events/lifecycle/impl/KessokuLifecycleEventsImplFabric.java b/lifecycle-events/fabric/src/main/java/band/kessoku/lib/events/lifecycle/impl/KessokuLifecycleEventsImplFabric.java index 1fe1b20f..f08462a7 100644 --- a/lifecycle-events/fabric/src/main/java/band/kessoku/lib/events/lifecycle/impl/KessokuLifecycleEventsImplFabric.java +++ b/lifecycle-events/fabric/src/main/java/band/kessoku/lib/events/lifecycle/impl/KessokuLifecycleEventsImplFabric.java @@ -17,7 +17,6 @@ import band.kessoku.lib.events.lifecycle.api.*; import band.kessoku.lib.events.lifecycle.api.client.*; - import net.fabricmc.fabric.api.client.event.lifecycle.v1.*; import net.fabricmc.fabric.api.event.lifecycle.v1.*; diff --git a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/KessokuLifecycleEventsEntrypoint.java b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/KessokuLifecycleEventsEntrypoint.java index f0bceac8..16f01db3 100644 --- a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/KessokuLifecycleEventsEntrypoint.java +++ b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/KessokuLifecycleEventsEntrypoint.java @@ -17,7 +17,6 @@ import band.kessoku.lib.base.ModUtils; import band.kessoku.lib.events.lifecycle.impl.KessokuLifecycleEventsImplNeo; - import net.neoforged.bus.api.IEventBus; import net.neoforged.fml.ModContainer; import net.neoforged.fml.common.Mod; diff --git a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/impl/KessokuLifecycleEventsImplNeo.java b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/impl/KessokuLifecycleEventsImplNeo.java index 1175d724..29facebc 100644 --- a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/impl/KessokuLifecycleEventsImplNeo.java +++ b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/impl/KessokuLifecycleEventsImplNeo.java @@ -18,13 +18,11 @@ import band.kessoku.lib.event.util.NeoEventUtils; import band.kessoku.lib.events.lifecycle.api.*; import band.kessoku.lib.events.lifecycle.api.client.ClientChunkEvent; - import net.minecraft.client.MinecraftClient; import net.minecraft.client.world.ClientWorld; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.world.chunk.WorldChunk; - import net.neoforged.bus.api.IEventBus; import net.neoforged.neoforge.client.event.ClientTickEvent; import net.neoforged.neoforge.event.OnDatapackSyncEvent; diff --git a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/MinecraftServerMixin.java b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/MinecraftServerMixin.java index dfede6e7..4d736c41 100644 --- a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/MinecraftServerMixin.java +++ b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/MinecraftServerMixin.java @@ -15,17 +15,16 @@ */ package band.kessoku.lib.events.lifecycle.mixin.neo; -import java.util.Collection; -import java.util.concurrent.CompletableFuture; - import band.kessoku.lib.events.lifecycle.api.ServerLifecycleEvent; +import net.minecraft.server.MinecraftServer; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.server.MinecraftServer; +import java.util.Collection; +import java.util.concurrent.CompletableFuture; @Mixin(MinecraftServer.class) public abstract class MinecraftServerMixin { diff --git a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/ServerEntityHandlerMixin.java b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/ServerEntityHandlerMixin.java index 8f6ef415..c7de6c17 100644 --- a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/ServerEntityHandlerMixin.java +++ b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/ServerEntityHandlerMixin.java @@ -16,6 +16,8 @@ package band.kessoku.lib.events.lifecycle.mixin.neo; import band.kessoku.lib.events.lifecycle.api.ServerEntityEvent; +import net.minecraft.entity.Entity; +import net.minecraft.server.world.ServerWorld; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -23,9 +25,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import net.minecraft.entity.Entity; -import net.minecraft.server.world.ServerWorld; - @Mixin(targets = "net/minecraft/server/world/ServerWorld$ServerEntityHandler") public class ServerEntityHandlerMixin { // final synthetic Lnet/minecraft/server/world/ServerWorld; field_26936 diff --git a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/ServerWorldMixin.java b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/ServerWorldMixin.java index f304dda5..2689b8ce 100644 --- a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/ServerWorldMixin.java +++ b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/ServerWorldMixin.java @@ -15,16 +15,15 @@ */ package band.kessoku.lib.events.lifecycle.mixin.neo; -import java.util.function.BooleanSupplier; - import band.kessoku.lib.events.lifecycle.api.ServerTickEvent; +import net.minecraft.server.world.ServerWorld; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import net.minecraft.server.world.ServerWorld; +import java.util.function.BooleanSupplier; @Mixin(ServerWorld.class) public abstract class ServerWorldMixin { diff --git a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/ClientChunkManagerMixin.java b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/ClientChunkManagerMixin.java index 856ee813..bc38d367 100644 --- a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/ClientChunkManagerMixin.java +++ b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/ClientChunkManagerMixin.java @@ -15,9 +15,14 @@ */ package band.kessoku.lib.events.lifecycle.mixin.neo.client; -import java.util.function.Consumer; - import band.kessoku.lib.events.lifecycle.api.client.ClientChunkEvent; +import net.minecraft.client.world.ClientChunkManager; +import net.minecraft.client.world.ClientWorld; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.network.PacketByteBuf; +import net.minecraft.network.packet.s2c.play.ChunkData; +import net.minecraft.util.math.ChunkPos; +import net.minecraft.world.chunk.WorldChunk; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -27,13 +32,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import net.minecraft.client.world.ClientChunkManager; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.network.PacketByteBuf; -import net.minecraft.network.packet.s2c.play.ChunkData; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.world.chunk.WorldChunk; +import java.util.function.Consumer; @Mixin(ClientChunkManager.class) public abstract class ClientChunkManagerMixin { diff --git a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/ClientEntityHandlerMixin.java b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/ClientEntityHandlerMixin.java index eabfb56f..86012919 100644 --- a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/ClientEntityHandlerMixin.java +++ b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/ClientEntityHandlerMixin.java @@ -16,6 +16,8 @@ package band.kessoku.lib.events.lifecycle.mixin.neo.client; import band.kessoku.lib.events.lifecycle.api.client.ClientEntityEvent; +import net.minecraft.client.world.ClientWorld; +import net.minecraft.entity.Entity; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -23,9 +25,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.Entity; - @Mixin(targets = "net/minecraft/client/world/ClientWorld$ClientEntityHandler") public class ClientEntityHandlerMixin { // final synthetic Lnet/minecraft/client/world/ClientWorld; field_27735 diff --git a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/ClientPlayNetworkHandlerMixin.java b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/ClientPlayNetworkHandlerMixin.java index 4f04d185..f3007179 100644 --- a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/ClientPlayNetworkHandlerMixin.java +++ b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/ClientPlayNetworkHandlerMixin.java @@ -18,12 +18,6 @@ import band.kessoku.lib.events.lifecycle.api.client.ClientBlockEntityEvent; import band.kessoku.lib.events.lifecycle.api.client.ClientEntityEvent; import band.kessoku.lib.events.lifecycle.impl.LoadedChunksCache; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - import net.minecraft.block.entity.BlockEntity; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.world.ClientWorld; @@ -31,6 +25,11 @@ import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket; import net.minecraft.network.packet.s2c.play.PlayerRespawnS2CPacket; import net.minecraft.world.chunk.WorldChunk; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ClientPlayNetworkHandler.class) abstract class ClientPlayNetworkHandlerMixin { diff --git a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/MinecraftClientMixin.java b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/MinecraftClientMixin.java index 7573c631..5a726575 100644 --- a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/MinecraftClientMixin.java +++ b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/MinecraftClientMixin.java @@ -16,13 +16,12 @@ package band.kessoku.lib.events.lifecycle.mixin.neo.client; import band.kessoku.lib.events.lifecycle.api.client.ClientLifecycleEvent; +import net.minecraft.client.MinecraftClient; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import net.minecraft.client.MinecraftClient; - @Mixin(MinecraftClient.class) public abstract class MinecraftClientMixin { @Inject(at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;info(Ljava/lang/String;)V", shift = At.Shift.AFTER, remap = false), method = "stop") diff --git a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/WorldChunkMixin.java b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/WorldChunkMixin.java index 4440caa1..f259450f 100644 --- a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/WorldChunkMixin.java +++ b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/WorldChunkMixin.java @@ -15,11 +15,15 @@ */ package band.kessoku.lib.events.lifecycle.mixin.neo.client; -import java.util.Map; - import band.kessoku.lib.events.lifecycle.api.ServerBlockEntityEvent; import band.kessoku.lib.events.lifecycle.api.client.ClientBlockEntityEvent; import com.llamalad7.mixinextras.sugar.Local; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.client.world.ClientWorld; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.chunk.WorldChunk; import org.jetbrains.annotations.Nullable; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; @@ -31,12 +35,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.chunk.WorldChunk; +import java.util.Map; @Mixin(WorldChunk.class) abstract class WorldChunkMixin { diff --git a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/server/WorldChunkMixin.java b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/server/WorldChunkMixin.java index 24e41ad4..89e7101e 100644 --- a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/server/WorldChunkMixin.java +++ b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/server/WorldChunkMixin.java @@ -15,10 +15,13 @@ */ package band.kessoku.lib.events.lifecycle.mixin.neo.server; -import java.util.Map; - import band.kessoku.lib.events.lifecycle.api.ServerBlockEntityEvent; import com.llamalad7.mixinextras.sugar.Local; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.chunk.WorldChunk; import org.jetbrains.annotations.Nullable; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; @@ -30,11 +33,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.chunk.WorldChunk; +import java.util.Map; /** * This is a server only mixin for good reason: diff --git a/lifecycle-events/neo/src/main/resources/kessoku-lifecycle-events.neo.mixins.json b/lifecycle-events/neo/src/main/resources/kessoku-lifecycle-events.neo.mixins.json index f5267d43..8c4c7bb7 100644 --- a/lifecycle-events/neo/src/main/resources/kessoku-lifecycle-events.neo.mixins.json +++ b/lifecycle-events/neo/src/main/resources/kessoku-lifecycle-events.neo.mixins.json @@ -12,8 +12,8 @@ ], "client": [ "client.ClientChunkManagerMixin", - "client.ClientPlayNetworkHandlerMixin", "client.ClientEntityHandlerMixin", + "client.ClientPlayNetworkHandlerMixin", "client.MinecraftClientMixin", "client.WorldChunkMixin" ], diff --git a/platform/common/src/main/java/band/kessoku/lib/platform/api/ModLoader.java b/platform/common/src/main/java/band/kessoku/lib/platform/api/ModLoader.java index abb316be..b7fef091 100644 --- a/platform/common/src/main/java/band/kessoku/lib/platform/api/ModLoader.java +++ b/platform/common/src/main/java/band/kessoku/lib/platform/api/ModLoader.java @@ -15,11 +15,11 @@ */ package band.kessoku.lib.platform.api; +import band.kessoku.lib.platform.impl.KessokuPlatformServices; + import java.nio.file.Path; import java.util.Collection; -import band.kessoku.lib.platform.impl.KessokuPlatformServices; - public interface ModLoader { static ModLoader getInstance() { return KessokuPlatformServices.getModLoader(); diff --git a/platform/fabric/src/main/java/band/kessoku/lib/platform/KessokuPlatformEntrypoint.java b/platform/fabric/src/main/java/band/kessoku/lib/platform/KessokuPlatformEntrypoint.java index 8ab8bbdc..1ba1bcf0 100644 --- a/platform/fabric/src/main/java/band/kessoku/lib/platform/KessokuPlatformEntrypoint.java +++ b/platform/fabric/src/main/java/band/kessoku/lib/platform/KessokuPlatformEntrypoint.java @@ -16,7 +16,6 @@ package band.kessoku.lib.platform; import band.kessoku.lib.base.ModUtils; - import net.fabricmc.api.ModInitializer; public class KessokuPlatformEntrypoint implements ModInitializer { diff --git a/platform/fabric/src/main/java/band/kessoku/lib/platform/impl/ModDataImpl.java b/platform/fabric/src/main/java/band/kessoku/lib/platform/impl/ModDataImpl.java index 181c3bc8..d0bf3a56 100644 --- a/platform/fabric/src/main/java/band/kessoku/lib/platform/impl/ModDataImpl.java +++ b/platform/fabric/src/main/java/band/kessoku/lib/platform/impl/ModDataImpl.java @@ -15,20 +15,19 @@ */ package band.kessoku.lib.platform.impl; -import java.nio.file.Path; -import java.util.Collection; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - import band.kessoku.lib.platform.api.ModData; import band.kessoku.lib.platform.api.ModDependencyInfo; - import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.ModContainer; import net.fabricmc.loader.api.metadata.ModMetadata; import net.fabricmc.loader.api.metadata.Person; +import java.nio.file.Path; +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + public class ModDataImpl implements ModData { private final ModContainer modContainer; private final ModMetadata modMetadata; diff --git a/platform/fabric/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java b/platform/fabric/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java index 376b2f07..0d9767a4 100644 --- a/platform/fabric/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java +++ b/platform/fabric/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java @@ -16,7 +16,6 @@ package band.kessoku.lib.platform.impl; import band.kessoku.lib.platform.api.ModDependencyInfo; - import net.fabricmc.loader.api.metadata.ModDependency; public class ModDependencyInfoImpl implements ModDependencyInfo { diff --git a/platform/fabric/src/main/java/band/kessoku/lib/platform/impl/ModLoaderImpl.java b/platform/fabric/src/main/java/band/kessoku/lib/platform/impl/ModLoaderImpl.java index 010d74d7..f5e27ff6 100644 --- a/platform/fabric/src/main/java/band/kessoku/lib/platform/impl/ModLoaderImpl.java +++ b/platform/fabric/src/main/java/band/kessoku/lib/platform/impl/ModLoaderImpl.java @@ -15,21 +15,20 @@ */ package band.kessoku.lib.platform.impl; -import java.nio.file.Path; -import java.util.Collection; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - import band.kessoku.lib.platform.api.Env; import band.kessoku.lib.platform.api.ModData; import band.kessoku.lib.platform.api.ModLoader; import com.google.auto.service.AutoService; - import net.fabricmc.api.EnvType; import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.ModContainer; import net.fabricmc.loader.api.metadata.ModMetadata; +import java.nio.file.Path; +import java.util.Collection; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + @AutoService(ModLoader.class) public class ModLoaderImpl implements ModLoader { private final Map modDataMap = new ConcurrentHashMap<>(); diff --git a/platform/neo/src/main/java/band/kessoku/lib/platform/KessokuPlatformEntrypoint.java b/platform/neo/src/main/java/band/kessoku/lib/platform/KessokuPlatformEntrypoint.java index e34f78b3..c34ea948 100644 --- a/platform/neo/src/main/java/band/kessoku/lib/platform/KessokuPlatformEntrypoint.java +++ b/platform/neo/src/main/java/band/kessoku/lib/platform/KessokuPlatformEntrypoint.java @@ -16,7 +16,6 @@ package band.kessoku.lib.platform; import band.kessoku.lib.base.ModUtils; - import net.neoforged.fml.common.Mod; @Mod(KessokuPlatform.MOD_ID) diff --git a/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDataImpl.java b/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDataImpl.java index 957d2157..50f71a4a 100644 --- a/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDataImpl.java +++ b/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDataImpl.java @@ -15,19 +15,21 @@ */ package band.kessoku.lib.platform.impl; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.*; - import band.kessoku.lib.platform.api.ModData; import band.kessoku.lib.platform.api.ModDependencyInfo; - import net.neoforged.fml.ModContainer; import net.neoforged.fml.ModList; import net.neoforged.fml.loading.moddiscovery.ModFileInfo; import net.neoforged.neoforgespi.language.IModFileInfo; import net.neoforged.neoforgespi.language.IModInfo; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + public class ModDataImpl implements ModData { private final ModContainer modContainer; private final IModInfo modInfo; diff --git a/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java b/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java index 8833c91c..ad676b8d 100644 --- a/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java +++ b/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java @@ -16,7 +16,6 @@ package band.kessoku.lib.platform.impl; import band.kessoku.lib.platform.api.ModDependencyInfo; - import net.neoforged.neoforgespi.language.IModInfo; public class ModDependencyInfoImpl implements ModDependencyInfo { diff --git a/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModLoaderImpl.java b/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModLoaderImpl.java index 32641a74..525796cf 100644 --- a/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModLoaderImpl.java +++ b/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModLoaderImpl.java @@ -15,21 +15,20 @@ */ package band.kessoku.lib.platform.impl; -import java.nio.file.Path; -import java.util.Collection; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - import band.kessoku.lib.platform.api.Env; import band.kessoku.lib.platform.api.ModData; import band.kessoku.lib.platform.api.ModLoader; import com.google.auto.service.AutoService; - import net.neoforged.fml.ModList; import net.neoforged.fml.loading.FMLLoader; import net.neoforged.fml.loading.FMLPaths; import net.neoforged.neoforgespi.language.IModInfo; +import java.nio.file.Path; +import java.util.Collection; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + @AutoService(ModLoader.class) public class ModLoaderImpl implements ModLoader { private final Map modDataMap = new ConcurrentHashMap<>(); diff --git a/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java b/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java index 654b07f9..d8b3923b 100644 --- a/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java +++ b/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java @@ -15,17 +15,8 @@ */ package band.kessoku.lib.registry.api; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2IntMap; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import net.minecraft.block.AbstractFurnaceBlock; import net.minecraft.block.entity.AbstractFurnaceBlockEntity; import net.minecraft.block.entity.BlockEntity; @@ -38,6 +29,14 @@ import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.registry.tag.TagKey; import net.minecraft.util.math.BlockPos; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; /** * Poor compatibility in Fabric diff --git a/registry/common/src/main/java/band/kessoku/lib/registry/api/Registry.java b/registry/common/src/main/java/band/kessoku/lib/registry/api/Registry.java index 542ce3ba..e8cc527d 100644 --- a/registry/common/src/main/java/band/kessoku/lib/registry/api/Registry.java +++ b/registry/common/src/main/java/band/kessoku/lib/registry/api/Registry.java @@ -16,8 +16,6 @@ package band.kessoku.lib.registry.api; import band.kessoku.lib.registry.impl.KessokuRegistryServices; -import org.jetbrains.annotations.ApiStatus; - import net.minecraft.block.AbstractBlock; import net.minecraft.block.Block; import net.minecraft.item.BlockItem; @@ -25,6 +23,7 @@ import net.minecraft.registry.Registries; import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.util.Identifier; +import org.jetbrains.annotations.ApiStatus; @SuppressWarnings("unused") public interface Registry { diff --git a/registry/fabric/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java b/registry/fabric/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java index dff8702b..dc03364d 100644 --- a/registry/fabric/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java +++ b/registry/fabric/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java @@ -16,7 +16,6 @@ package band.kessoku.lib.registry; import band.kessoku.lib.base.ModUtils; - import net.fabricmc.api.ModInitializer; public class KessokuRegistryEntrypoint implements ModInitializer { diff --git a/registry/fabric/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java b/registry/fabric/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java index 1b5d9353..a48c47cb 100644 --- a/registry/fabric/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java +++ b/registry/fabric/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java @@ -17,7 +17,6 @@ import band.kessoku.lib.registry.api.Registry; import com.google.auto.service.AutoService; - import net.minecraft.util.Identifier; @AutoService(Registry.class) diff --git a/registry/fabric/src/main/java/band/kessoku/lib/registry/mixin/AbstractFurnaceBlockEntityMixin.java b/registry/fabric/src/main/java/band/kessoku/lib/registry/mixin/AbstractFurnaceBlockEntityMixin.java index ac0d82a3..8a3f0282 100644 --- a/registry/fabric/src/main/java/band/kessoku/lib/registry/mixin/AbstractFurnaceBlockEntityMixin.java +++ b/registry/fabric/src/main/java/band/kessoku/lib/registry/mixin/AbstractFurnaceBlockEntityMixin.java @@ -18,12 +18,6 @@ import band.kessoku.lib.registry.api.FuelRegistry; import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - import net.minecraft.block.BlockState; import net.minecraft.block.entity.AbstractFurnaceBlockEntity; import net.minecraft.block.entity.BlockEntityType; @@ -31,6 +25,11 @@ import net.minecraft.recipe.AbstractCookingRecipe; import net.minecraft.recipe.RecipeType; import net.minecraft.util.math.BlockPos; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(AbstractFurnaceBlockEntity.class) public class AbstractFurnaceBlockEntityMixin { diff --git a/registry/neo/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java b/registry/neo/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java index 59c53d29..278a47ae 100644 --- a/registry/neo/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java +++ b/registry/neo/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java @@ -19,10 +19,8 @@ import band.kessoku.lib.event.util.NeoEventUtils; import band.kessoku.lib.registry.api.FuelRegistry; import band.kessoku.lib.registry.impl.RegistryImpl; - import net.minecraft.item.ItemStack; import net.minecraft.recipe.RecipeType; - import net.neoforged.bus.api.IEventBus; import net.neoforged.fml.common.Mod; import net.neoforged.neoforge.common.NeoForge; diff --git a/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java b/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java index 06c707a7..70d0e7dd 100644 --- a/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java +++ b/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java @@ -15,16 +15,15 @@ */ package band.kessoku.lib.registry.impl; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; - import band.kessoku.lib.registry.api.Registry; import com.google.auto.service.AutoService; -import org.jetbrains.annotations.ApiStatus; - import net.minecraft.util.Identifier; - import net.neoforged.neoforge.registries.RegisterEvent; +import org.jetbrains.annotations.ApiStatus; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; @AutoService(Registry.class) @SuppressWarnings({"unchecked", "rawtypes"}) From 2439f74fbce900901b076f717aa847f2a0added8 Mon Sep 17 00:00:00 2001 From: Amarok Date: Fri, 20 Sep 2024 14:58:44 +0800 Subject: [PATCH 03/17] =?UTF-8?q?=F0=9F=90=BA=E2=81=89=EF=B8=8F?= =?UTF-8?q?=F0=9F=A6=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/base/KessokuBaseEntrypoint.java | 1 + .../lib/config/api/AbstractConfig.java | 5 +++++ .../platform/impl/ModDependencyInfoImpl.java | 22 ++++++------------- .../lib/registry/api/FuelRegistry.java | 10 +++------ .../registry/KessokuRegistryEntrypoint.java | 12 +++++----- .../lib/registry/impl/RegistryImpl.java | 13 ++++++++--- 6 files changed, 32 insertions(+), 31 deletions(-) diff --git a/base/neo/src/main/java/band/kessoku/lib/base/KessokuBaseEntrypoint.java b/base/neo/src/main/java/band/kessoku/lib/base/KessokuBaseEntrypoint.java index 3077d878..42047348 100644 --- a/base/neo/src/main/java/band/kessoku/lib/base/KessokuBaseEntrypoint.java +++ b/base/neo/src/main/java/band/kessoku/lib/base/KessokuBaseEntrypoint.java @@ -16,6 +16,7 @@ package band.kessoku.lib.base; import net.neoforged.fml.common.Mod; +import net.neoforged.neoforge.event.RegisterCommandsEvent; @Mod(KessokuBase.MOD_ID) public class KessokuBaseEntrypoint { diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java b/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java index 2c3041bf..416d6827 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java @@ -143,6 +143,8 @@ public void reset() { List fields = new ArrayList<>(); for (Field declaredField : this.getClass().getDeclaredFields()) { + declaredField.setAccessible(true); + final boolean flag0 = declaredField.getDeclaringClass().isAssignableFrom(ConfigValue.class); final boolean flag1 = Modifier.isPublic(declaredField.getModifiers()); final boolean flag2 = !Modifier.isStatic(declaredField.getModifiers()); @@ -163,6 +165,7 @@ public ImmutableList getValidCategories() { List fields = new ArrayList<>(); for (Field declaredField : this.getClass().getDeclaredFields()) { + declaredField.setAccessible(true); final boolean flag0 = declaredField.getDeclaringClass().isAssignableFrom(AbstractConfig.class); final boolean flag1 = Modifier.isPublic(declaredField.getModifiers()); @@ -178,6 +181,7 @@ public ImmutableList getValidCategories() { private ImmutableList getValidFields() { ImmutableList.Builder builder = ImmutableList.builder(); for (Field declaredField : this.getClass().getDeclaredFields()) { + declaredField.setAccessible(true); final boolean flag0 = declaredField.getDeclaringClass().isAssignableFrom(AbstractConfig.class); final boolean flag1 = declaredField.getDeclaringClass().isAssignableFrom(ConfigValue.class); @@ -196,6 +200,7 @@ private Map serialize() { ImmutableMap.Builder builder = ImmutableMap.builder(); for (Field field : this.getValidFields()) { field.setAccessible(true); + final String name = field.isAnnotationPresent(Name.class) ? field.getAnnotation(Name.class).value() : field.getName(); final String[] comments = field.isAnnotationPresent(Comments.class) ? (String[]) Arrays.stream(field.getAnnotation(Comments.class).value()).map(Comment::value).toArray() : new String[0]; diff --git a/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java b/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java index ad676b8d..ddeef52b 100644 --- a/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java +++ b/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java @@ -25,21 +25,13 @@ public ModDependencyInfoImpl(IModInfo.ModVersion modVersion) { } @Override public DependencyKind getKind() { - switch (value.getType()) { - case OPTIONAL -> { - return DependencyKind.OPTIONAL; - } - case REQUIRED -> { - return DependencyKind.DEPENDS; - } - case DISCOURAGED -> { - return DependencyKind.CONFLICTS; - } - case INCOMPATIBLE -> { - return DependencyKind.BREAKS; - } - } - return null; + return switch (value.getType()) { + case OPTIONAL -> DependencyKind.OPTIONAL; + case REQUIRED -> DependencyKind.DEPENDS; + case DISCOURAGED -> DependencyKind.CONFLICTS; + case INCOMPATIBLE -> DependencyKind.BREAKS; + default -> null; + }; } @Override diff --git a/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java b/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java index d8b3923b..339ccf4a 100644 --- a/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java +++ b/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java @@ -178,15 +178,11 @@ public static void setFuelTime(ItemConvertible item, int cookTime) { } /** - * @param block the block which acts like a furnace * @return The fuel time. */ - public static int getFuelTime(T block, ItemStack stack) { - BlockEntity entity = block.createBlockEntity((BlockPos) BlockPos.ZERO, block.getDefaultState()); - if (!(entity instanceof AbstractFurnaceBlockEntity)) return 0; - int fuelTime = ((AbstractFurnaceBlockEntity) entity).getFuelTime(stack); - entity.markRemoved(); - return fuelTime; + public static int getFuelTime(ItemStack stack) { + final var fuelMap = AbstractFurnaceBlockEntity.createFuelTimeMap(); + return fuelMap.getOrDefault(stack.getItem(), 0); } public record ItemWithData(ComponentMap componentMap, ItemConvertible item) { diff --git a/registry/neo/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java b/registry/neo/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java index 278a47ae..af56993b 100644 --- a/registry/neo/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java +++ b/registry/neo/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java @@ -27,18 +27,18 @@ import net.neoforged.neoforge.event.furnace.FurnaceFuelBurnTimeEvent; import net.neoforged.neoforge.registries.RegisterEvent; +import java.util.Objects; +import java.util.Optional; + @Mod(KessokuRegistry.MOD_ID) public class KessokuRegistryEntrypoint { public KessokuRegistryEntrypoint(IEventBus modEventBus) { ModUtils.getLogger().info(KessokuRegistry.MARKER, "KessokuLib-Registry is loaded!"); NeoEventUtils.registerEvent(modEventBus, RegisterEvent.class, RegistryImpl::onRegister); NeoEventUtils.registerEvent(NeoForge.EVENT_BUS, FurnaceFuelBurnTimeEvent.class, event -> { - ItemStack stack = event.getItemStack(); - RecipeType recipeType = event.getRecipeType(); - Integer burnTime; - if (recipeType != null) burnTime = FuelRegistry.of(recipeType).get(stack); - else burnTime = FuelRegistry.of(RecipeType.SMELTING).get(stack); - if (burnTime != null) event.setBurnTime(burnTime); + final ItemStack stack = event.getItemStack(); + final RecipeType recipeType = Objects.requireNonNullElse(event.getRecipeType(), RecipeType.SMELTING); + Optional.ofNullable(FuelRegistry.of(recipeType).get(stack)).ifPresent(event::setBurnTime); }); } } diff --git a/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java b/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java index 70d0e7dd..c7c859d3 100644 --- a/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java +++ b/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java @@ -17,12 +17,16 @@ import band.kessoku.lib.registry.api.Registry; import com.google.auto.service.AutoService; +import com.google.common.collect.HashBasedTable; +import com.google.common.collect.Maps; +import com.google.common.collect.Table; import net.minecraft.util.Identifier; import net.neoforged.neoforge.registries.RegisterEvent; import org.jetbrains.annotations.ApiStatus; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; @AutoService(Registry.class) @@ -39,12 +43,15 @@ public static void onRegister(RegisterEvent event) { @Override public T registerInternal(net.minecraft.registry.Registry registry, Identifier id, T entry) { - if (registered) + if (registered) { throw new IllegalStateException("Cannot register new entries after net.neoforged.neoforge.registries.RegisterEvent has been fired."); - if (!registries.containsKey(registry)) registries.put(registry, new HashMap<>()); - if (registries.get(registry).putIfAbsent(id, entry) != null) { + } + + final var map = Objects.requireNonNull(registries.putIfAbsent(registry, Maps.newHashMap())); + if (map.putIfAbsent(id, entry) != null) { throw new IllegalArgumentException("Duplicate registration " + id.toString()); } + return entry; } } From ed5c8d6f5297c2c402cb549c13d7e6122f537fbc Mon Sep 17 00:00:00 2001 From: Amarok Date: Fri, 20 Sep 2024 15:24:18 +0800 Subject: [PATCH 04/17] =?UTF-8?q?=F0=9F=90=BA=F0=9F=92=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../band/kessoku/lib/base/KessokuBaseEntrypoint.java | 1 - .../kessoku/lib/keybind/impl/KeyBindRegisterImpl.java | 9 +++++---- .../kessoku/lib/platform/impl/ModDependencyInfoImpl.java | 1 - .../java/band/kessoku/lib/registry/api/FuelRegistry.java | 3 --- .../band/kessoku/lib/registry/impl/RegistryImpl.java | 3 --- 5 files changed, 5 insertions(+), 12 deletions(-) diff --git a/base/neo/src/main/java/band/kessoku/lib/base/KessokuBaseEntrypoint.java b/base/neo/src/main/java/band/kessoku/lib/base/KessokuBaseEntrypoint.java index 42047348..3077d878 100644 --- a/base/neo/src/main/java/band/kessoku/lib/base/KessokuBaseEntrypoint.java +++ b/base/neo/src/main/java/band/kessoku/lib/base/KessokuBaseEntrypoint.java @@ -16,7 +16,6 @@ package band.kessoku.lib.base; import net.neoforged.fml.common.Mod; -import net.neoforged.neoforge.event.RegisterCommandsEvent; @Mod(KessokuBase.MOD_ID) public class KessokuBaseEntrypoint { diff --git a/keybind/neo/src/main/java/band/kessoku/lib/keybind/impl/KeyBindRegisterImpl.java b/keybind/neo/src/main/java/band/kessoku/lib/keybind/impl/KeyBindRegisterImpl.java index 09c9e343..6e34c8ce 100644 --- a/keybind/neo/src/main/java/band/kessoku/lib/keybind/impl/KeyBindRegisterImpl.java +++ b/keybind/neo/src/main/java/band/kessoku/lib/keybind/impl/KeyBindRegisterImpl.java @@ -27,13 +27,15 @@ import java.util.List; import java.util.Map; -import java.util.Optional; @AutoService(KeyBindRegister.class) public class KeyBindRegisterImpl implements KeyBindRegister { private static final List KEY_BINDINGS = new ReferenceArrayList<>(); private static boolean processed; + /* Amarok Note: + Maybe Object2IntMap ...? + */ private static Map getCategoryMap() { return KeyBindingAccessor.kessoku$getCategoryMap(); } @@ -46,9 +48,8 @@ public boolean addCategory(String categoryTranslationKey) { return false; } - Optional largest = map.values().stream().max(Integer::compareTo); - int largestInt = largest.orElse(0); - map.put(categoryTranslationKey, largestInt + 1); + final int largest = map.values().stream().max(Integer::compareTo).orElse(0); + map.put(categoryTranslationKey, largest + 1); return true; } diff --git a/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java b/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java index ddeef52b..2b202b06 100644 --- a/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java +++ b/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java @@ -30,7 +30,6 @@ public DependencyKind getKind() { case REQUIRED -> DependencyKind.DEPENDS; case DISCOURAGED -> DependencyKind.CONFLICTS; case INCOMPATIBLE -> DependencyKind.BREAKS; - default -> null; }; } diff --git a/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java b/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java index 339ccf4a..4c829c32 100644 --- a/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java +++ b/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java @@ -17,9 +17,7 @@ import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2IntMap; -import net.minecraft.block.AbstractFurnaceBlock; import net.minecraft.block.entity.AbstractFurnaceBlockEntity; -import net.minecraft.block.entity.BlockEntity; import net.minecraft.component.ComponentMap; import net.minecraft.item.Item; import net.minecraft.item.ItemConvertible; @@ -28,7 +26,6 @@ import net.minecraft.recipe.RecipeType; import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.registry.tag.TagKey; -import net.minecraft.util.math.BlockPos; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java b/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java index c7c859d3..2a352302 100644 --- a/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java +++ b/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java @@ -17,14 +17,11 @@ import band.kessoku.lib.registry.api.Registry; import com.google.auto.service.AutoService; -import com.google.common.collect.HashBasedTable; import com.google.common.collect.Maps; -import com.google.common.collect.Table; import net.minecraft.util.Identifier; import net.neoforged.neoforge.registries.RegisterEvent; import org.jetbrains.annotations.ApiStatus; -import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; From 2099f704e564be09d6381c9a765c23bba5d99ed4 Mon Sep 17 00:00:00 2001 From: H2Sxxa Date: Tue, 17 Sep 2024 21:27:37 +0800 Subject: [PATCH 05/17] Use action to setup gradle (#10) use action to setup gradle --- .github/workflows/build.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8714d595..3116d8cb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,13 +1,12 @@ name: Build Kessoku Lib -on: [pull_request, push] +on: [pull_request, push, workflow_dispatch] jobs: build: strategy: matrix: - java: [ - 21, - ] + java: + - 21 runs-on: ubuntu-22.04 steps: - name: checkout repository @@ -18,7 +17,9 @@ jobs: uses: actions/setup-java@v4 with: java-version: ${{ matrix.java }} - distribution: 'microsoft' + distribution: "microsoft" + - name: setup gradle + uses: gradle/actions/setup-gradle@v3 - name: make gradle wrapper executable run: chmod +x ./gradlew - name: build @@ -29,4 +30,4 @@ jobs: with: name: Artifacts path: | - */*/build/libs \ No newline at end of file + */*/build/libs From bdf9bea04710a69750539db2345e258ad728b9db Mon Sep 17 00:00:00 2001 From: Amarok Date: Sat, 21 Sep 2024 12:34:56 +0800 Subject: [PATCH 06/17] =?UTF-8?q?=F0=9F=90=BA=F0=9F=AA=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/registry/api/FuelRegistry.java | 29 +++++++++++-------- .../AbstractFurnaceBlockEntityMixin.java | 4 +-- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java b/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java index 4c829c32..a724a99c 100644 --- a/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java +++ b/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java @@ -30,10 +30,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; +import java.util.*; /** * Poor compatibility in Fabric @@ -85,10 +82,20 @@ public void add(ItemStack stack, int cookTime) { /** * Get current modification in KessokuLib. */ - @Nullable - public Integer get(ItemConvertible item) { + public int get(ItemConvertible item) { if (this.itemRegistries.containsKey(item)) return this.itemRegistries.get(item); + + final RegistryEntry.Reference itemReference = item.asItem().getRegistryEntry(); + final var tag = this.tagRegistries.keySet() + .stream() + .filter(itemReference::isIn) + .findFirst() + .orElse(null); + + return Objects.nonNull(tag) ? this.tagRegistries.get(tag) : -1; + + /* final ArrayList> tags = new ArrayList<>(this.tagRegistries.keySet()); Collections.reverse(tags); RegistryEntry.Reference itemReference = item.asItem().getRegistryEntry(); @@ -96,22 +103,20 @@ public Integer get(ItemConvertible item) { if (itemReference.isIn(tag)) return this.tagRegistries.getInt(tag); } return null; + */ } /** * Get current modification in KessokuLib. */ - @Nullable - public Integer get(ItemWithData data) { - if (this.dataRegistries.containsKey(data)) return this.dataRegistries.getInt(data); - return this.get(data.item()); + public int get(ItemWithData data) { + return this.dataRegistries.getOrDefault(data, this.get(data.item())); } /** * Get current modification in KessokuLib. */ - @Nullable - public Integer get(ItemStack stack) { + public int get(ItemStack stack) { return this.get(ItemWithData.of(stack)); } diff --git a/registry/fabric/src/main/java/band/kessoku/lib/registry/mixin/AbstractFurnaceBlockEntityMixin.java b/registry/fabric/src/main/java/band/kessoku/lib/registry/mixin/AbstractFurnaceBlockEntityMixin.java index 8a3f0282..425d4c06 100644 --- a/registry/fabric/src/main/java/band/kessoku/lib/registry/mixin/AbstractFurnaceBlockEntityMixin.java +++ b/registry/fabric/src/main/java/band/kessoku/lib/registry/mixin/AbstractFurnaceBlockEntityMixin.java @@ -49,7 +49,7 @@ private static boolean canUseAsFuelHook(ItemStack stack, Operation orig @WrapMethod(method = "getFuelTime") private int getFuelTimeHook(ItemStack fuel, Operation original) { if (fuel.isEmpty()) return 0; - Integer fuelTime = FuelRegistry.of(this.recipeType).get(fuel); - return fuelTime == null ? original.call(fuel) : fuelTime; + int fuelTime = FuelRegistry.of(this.recipeType).get(fuel); + return fuelTime <= 0 ? original.call(fuel) : fuelTime; } } From 12b362da71346cb6c1d82cce969547888b6c9ab5 Mon Sep 17 00:00:00 2001 From: Amarok Date: Sat, 21 Sep 2024 12:54:28 +0800 Subject: [PATCH 07/17] =?UTF-8?q?=F0=9F=90=BA=F0=9F=AA=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../KessokuEntrypointEntrypoint.java | 45 +++++++++++++------ .../lib/registry/api/FuelRegistry.java | 5 ++- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/entrypoint/neo/src/main/java/band/kessoku/lib/entrypoint/KessokuEntrypointEntrypoint.java b/entrypoint/neo/src/main/java/band/kessoku/lib/entrypoint/KessokuEntrypointEntrypoint.java index 3585114b..9b5939a9 100644 --- a/entrypoint/neo/src/main/java/band/kessoku/lib/entrypoint/KessokuEntrypointEntrypoint.java +++ b/entrypoint/neo/src/main/java/band/kessoku/lib/entrypoint/KessokuEntrypointEntrypoint.java @@ -23,7 +23,9 @@ import net.neoforged.api.distmarker.Dist; import net.neoforged.fml.ModList; import net.neoforged.fml.common.Mod; +import net.neoforged.neoforgespi.language.IModInfo; +import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -39,28 +41,45 @@ public KessokuEntrypointEntrypoint(Dist dist) { registerEntrypoint("kServer", KessokuDedicatedServerModInitializer.class); } - @SuppressWarnings("unchecked") public static void registerEntrypoint(String entrypointName, Class initializer) { if (entrypointMap.containsKey(entrypointName)) throw new UnsupportedOperationException(); final ImmutableList.Builder builder = ImmutableList.builder(); + ModList.get().getMods().forEach(info -> { try { - Map properties = info.getModProperties(); - if (properties.containsKey(entrypointName)) { - Object entrypointList = properties.get(entrypointName); - if (!(entrypointList instanceof List)) throw new IllegalArgumentException(); - if (!ModUtils.isType((List) entrypointList, String.class)) { - for (Object entrypoint : ((List) entrypointList)) { - Class clazz = Class.forName((String) entrypoint); - if (!clazz.isAssignableFrom(initializer)) throw new IllegalArgumentException(); - builder.add((T) clazz.getConstructor().newInstance()); - } - } - } + modinfoHandler(info, entrypointName, initializer, builder); } catch (Exception e) { throw new RuntimeException(e); } }); + entrypointMap.put(entrypointName, builder.build()); } + + @SuppressWarnings("unchecked") + private static void modinfoHandler(IModInfo info, String entrypointName, Class initializer, + ImmutableList.Builder builder) throws Exception { + Map properties = info.getModProperties(); + if (!properties.containsKey(entrypointName)) { + return; + } + + Object entrypointList = properties.get(entrypointName); + + if (!(entrypointList instanceof List)) { + throw new RuntimeException(new IllegalArgumentException()); + } + + if (ModUtils.isType((List) entrypointList, String.class)) { + return; + } + + for (Object entrypoint : ((List) entrypointList)) { + Class clazz = Class.forName((String) entrypoint); + if (!clazz.isAssignableFrom(initializer)) { + throw new RuntimeException(new IllegalArgumentException()); + } + builder.add((T) clazz.getConstructor().newInstance()); + } + } } diff --git a/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java b/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java index a724a99c..0bee5436 100644 --- a/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java +++ b/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java @@ -28,9 +28,10 @@ import net.minecraft.registry.tag.TagKey; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; /** * Poor compatibility in Fabric From 5af1a842ba8f0763952802ee793a07e83c6c88bb Mon Sep 17 00:00:00 2001 From: Amarok Date: Sat, 21 Sep 2024 13:03:19 +0800 Subject: [PATCH 08/17] =?UTF-8?q?=F0=9F=90=BA=F0=9F=AA=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kessoku/lib/registry/KessokuRegistryEntrypoint.java | 6 +++++- .../java/band/kessoku/lib/registry/impl/RegistryImpl.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/registry/neo/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java b/registry/neo/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java index af56993b..accf760a 100644 --- a/registry/neo/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java +++ b/registry/neo/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java @@ -38,7 +38,11 @@ public KessokuRegistryEntrypoint(IEventBus modEventBus) { NeoEventUtils.registerEvent(NeoForge.EVENT_BUS, FurnaceFuelBurnTimeEvent.class, event -> { final ItemStack stack = event.getItemStack(); final RecipeType recipeType = Objects.requireNonNullElse(event.getRecipeType(), RecipeType.SMELTING); - Optional.ofNullable(FuelRegistry.of(recipeType).get(stack)).ifPresent(event::setBurnTime); + + int burnTime; + if ((burnTime = FuelRegistry.of(recipeType).get(stack)) <= 0) { + event.setBurnTime(burnTime); + } }); } } diff --git a/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java b/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java index 2a352302..d9f5b9bc 100644 --- a/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java +++ b/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java @@ -45,7 +45,7 @@ public T registerInternal(net.minecraft.registry.Registry re } final var map = Objects.requireNonNull(registries.putIfAbsent(registry, Maps.newHashMap())); - if (map.putIfAbsent(id, entry) != null) { + if (map.putIfAbsent(id, entry) == null) { throw new IllegalArgumentException("Duplicate registration " + id.toString()); } From 3333d4912a82222c267cbe0ccea5880b5e82e04a Mon Sep 17 00:00:00 2001 From: Amarok Date: Sat, 21 Sep 2024 13:04:11 +0800 Subject: [PATCH 09/17] =?UTF-8?q?=F0=9F=90=BA=F0=9F=AA=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../KessokuEntrypointEntrypoint.java | 48 +++++++------------ .../lib/registry/api/FuelRegistry.java | 2 +- .../registry/KessokuRegistryEntrypoint.java | 1 - 3 files changed, 17 insertions(+), 34 deletions(-) diff --git a/entrypoint/neo/src/main/java/band/kessoku/lib/entrypoint/KessokuEntrypointEntrypoint.java b/entrypoint/neo/src/main/java/band/kessoku/lib/entrypoint/KessokuEntrypointEntrypoint.java index 9b5939a9..df592af0 100644 --- a/entrypoint/neo/src/main/java/band/kessoku/lib/entrypoint/KessokuEntrypointEntrypoint.java +++ b/entrypoint/neo/src/main/java/band/kessoku/lib/entrypoint/KessokuEntrypointEntrypoint.java @@ -23,9 +23,7 @@ import net.neoforged.api.distmarker.Dist; import net.neoforged.fml.ModList; import net.neoforged.fml.common.Mod; -import net.neoforged.neoforgespi.language.IModInfo; -import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -41,45 +39,31 @@ public KessokuEntrypointEntrypoint(Dist dist) { registerEntrypoint("kServer", KessokuDedicatedServerModInitializer.class); } + @SuppressWarnings("unchecked") public static void registerEntrypoint(String entrypointName, Class initializer) { if (entrypointMap.containsKey(entrypointName)) throw new UnsupportedOperationException(); final ImmutableList.Builder builder = ImmutableList.builder(); - ModList.get().getMods().forEach(info -> { try { - modinfoHandler(info, entrypointName, initializer, builder); + Map properties = info.getModProperties(); + if (properties.containsKey(entrypointName)) { + Object entrypointList = properties.get(entrypointName); + if (!(entrypointList instanceof List)) { + throw new IllegalArgumentException(); + } + + if (!ModUtils.isType((List) entrypointList, String.class)) { + for (Object entrypoint : ((List) entrypointList)) { + Class clazz = Class.forName((String) entrypoint); + if (!clazz.isAssignableFrom(initializer)) throw new IllegalArgumentException(); + builder.add((T) clazz.getConstructor().newInstance()); + } + } + } } catch (Exception e) { throw new RuntimeException(e); } }); - entrypointMap.put(entrypointName, builder.build()); } - - @SuppressWarnings("unchecked") - private static void modinfoHandler(IModInfo info, String entrypointName, Class initializer, - ImmutableList.Builder builder) throws Exception { - Map properties = info.getModProperties(); - if (!properties.containsKey(entrypointName)) { - return; - } - - Object entrypointList = properties.get(entrypointName); - - if (!(entrypointList instanceof List)) { - throw new RuntimeException(new IllegalArgumentException()); - } - - if (ModUtils.isType((List) entrypointList, String.class)) { - return; - } - - for (Object entrypoint : ((List) entrypointList)) { - Class clazz = Class.forName((String) entrypoint); - if (!clazz.isAssignableFrom(initializer)) { - throw new RuntimeException(new IllegalArgumentException()); - } - builder.add((T) clazz.getConstructor().newInstance()); - } - } } diff --git a/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java b/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java index 0bee5436..9531d4eb 100644 --- a/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java +++ b/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java @@ -123,7 +123,7 @@ public int get(ItemStack stack) { @ApiStatus.Internal public static boolean canBurn(ItemStack stack) { - return fuelRegistries.values().stream().map(registry -> registry.get(stack)).anyMatch(time -> time != null && time != 0); + return fuelRegistries.values().stream().map(registry -> registry.get(stack)).anyMatch(time -> time > 0); } public void remove(ItemConvertible item) { diff --git a/registry/neo/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java b/registry/neo/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java index accf760a..1b16a420 100644 --- a/registry/neo/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java +++ b/registry/neo/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java @@ -28,7 +28,6 @@ import net.neoforged.neoforge.registries.RegisterEvent; import java.util.Objects; -import java.util.Optional; @Mod(KessokuRegistry.MOD_ID) public class KessokuRegistryEntrypoint { From 00824b81b561f1d0914514e3297252721b3ceea6 Mon Sep 17 00:00:00 2001 From: Amarok Date: Sat, 28 Sep 2024 14:03:54 +0800 Subject: [PATCH 10/17] =?UTF-8?q?=F0=9F=90=BA=F0=9F=A6=80=F0=9F=92=BB?= =?UTF-8?q?=F0=9F=9A=80=E2=81=89=EF=B8=8F=E2=9C=A8=F0=9F=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/base/reflect/ModifiersUtil.java | 86 +++++++++++++++++++ .../kessoku/lib/base/reflect/ReflectUtil.java | 22 +++++ .../lib/config/api/AbstractConfig.java | 32 +++---- .../serializers/Json5Serializer.java | 2 +- .../{api => }/serializers/JsonSerializer.java | 2 +- .../{api => }/serializers/TomlSerializer.java | 2 +- .../config/{api => }/values/BooleanValue.java | 2 +- .../{api => }/values/DefaultConfigValue.java | 2 +- .../config/{api => }/values/DoubleValue.java | 2 +- .../config/{api => }/values/FloatValue.java | 2 +- .../config/{api => }/values/IntegerValue.java | 2 +- .../config/{api => }/values/ListValue.java | 2 +- .../config/{api => }/values/LongValue.java | 2 +- .../lib/config/{api => }/values/MapValue.java | 2 +- .../config/{api => }/values/StringValue.java | 2 +- 15 files changed, 134 insertions(+), 30 deletions(-) create mode 100644 base/common/src/main/java/band/kessoku/lib/base/reflect/ModifiersUtil.java create mode 100644 base/common/src/main/java/band/kessoku/lib/base/reflect/ReflectUtil.java rename config/common/src/main/java/band/kessoku/lib/config/{api => }/serializers/Json5Serializer.java (97%) rename config/common/src/main/java/band/kessoku/lib/config/{api => }/serializers/JsonSerializer.java (97%) rename config/common/src/main/java/band/kessoku/lib/config/{api => }/serializers/TomlSerializer.java (96%) rename config/common/src/main/java/band/kessoku/lib/config/{api => }/values/BooleanValue.java (96%) rename config/common/src/main/java/band/kessoku/lib/config/{api => }/values/DefaultConfigValue.java (97%) rename config/common/src/main/java/band/kessoku/lib/config/{api => }/values/DoubleValue.java (96%) rename config/common/src/main/java/band/kessoku/lib/config/{api => }/values/FloatValue.java (96%) rename config/common/src/main/java/band/kessoku/lib/config/{api => }/values/IntegerValue.java (96%) rename config/common/src/main/java/band/kessoku/lib/config/{api => }/values/ListValue.java (99%) rename config/common/src/main/java/band/kessoku/lib/config/{api => }/values/LongValue.java (96%) rename config/common/src/main/java/band/kessoku/lib/config/{api => }/values/MapValue.java (98%) rename config/common/src/main/java/band/kessoku/lib/config/{api => }/values/StringValue.java (96%) diff --git a/base/common/src/main/java/band/kessoku/lib/base/reflect/ModifiersUtil.java b/base/common/src/main/java/band/kessoku/lib/base/reflect/ModifiersUtil.java new file mode 100644 index 00000000..58bd6d3f --- /dev/null +++ b/base/common/src/main/java/band/kessoku/lib/base/reflect/ModifiersUtil.java @@ -0,0 +1,86 @@ +package band.kessoku.lib.base.reflect; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; + +public final class ModifiersUtil { + + /* === Common === */ + + public static boolean isPublic(Field field) { + return Modifier.isPublic(field.getModifiers()); + } + + public static boolean isPublic(Method method) { + return Modifier.isPublic(method.getModifiers()); + } + + public static boolean isStatic(Field field) { + return Modifier.isStatic(field.getModifiers()); + } + + public static boolean isStatic(Method method) { + return Modifier.isStatic(method.getModifiers()); + } + + /* === Common Combo === */ + + public static boolean isPublicAndStatic(Field field) { + return isPublic(field) && isStatic(field); + } + + public static boolean isPublicAndStatic(Method method) { + return isPublic(method) && isStatic(method); + } + + public static boolean isPublicOrStatic(Field field, boolean shouldPublic, boolean shouldStatic) { + return shouldPublic == isPublic(field) && shouldStatic == isStatic(field); + } + + public static boolean isPublicOrStatic(Method method, boolean shouldPublic, boolean shouldStatic) { + return shouldPublic == isPublic(method) && shouldStatic == isStatic(method); + } + + /* === Common End === */ + + /* === Data Object === */ + + public static boolean isVolatile(Field field) { + return Modifier.isVolatile(field.getModifiers()); + } + + public static boolean isVolatile(Method method) { + return Modifier.isVolatile(method.getModifiers()); + } + + public static boolean isTransient(Field field) { + return Modifier.isTransient(field.getModifiers()); + } + + public static boolean isTransient(Method method) { + return Modifier.isTransient(method.getModifiers()); + } + + /* === Data Object End === */ + + /* === Low Usage Tools === */ + + public static boolean isFinal(Field field) { + return Modifier.isFinal(field.getModifiers()); + } + + public static boolean isFinal(Method method) { + return Modifier.isFinal(method.getModifiers()); + } + + public static boolean isProtected(Field field) { + return Modifier.isProtected(field.getModifiers()); + } + + public static boolean isProtected(Method method) { + return Modifier.isProtected(method.getModifiers()); + } + + /* === Low Usage Tools End === */ +} diff --git a/base/common/src/main/java/band/kessoku/lib/base/reflect/ReflectUtil.java b/base/common/src/main/java/band/kessoku/lib/base/reflect/ReflectUtil.java new file mode 100644 index 00000000..ad8bd9cb --- /dev/null +++ b/base/common/src/main/java/band/kessoku/lib/base/reflect/ReflectUtil.java @@ -0,0 +1,22 @@ +package band.kessoku.lib.base.reflect; + +import org.apache.logging.log4j.core.util.ReflectionUtil; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.Arrays; + +public final class ReflectUtil { + public static void makeAccessible(Field field) { + ReflectionUtil.makeAccessible(field); + } + + public static void makeAccessible(Method method) { + ReflectionUtil.makeAccessible(method); + } + + public static boolean isAssignableFrom(Field field, Class ... clazzs) { + var flag = Arrays.stream(clazzs).anyMatch(clazz -> !field.getType().isAssignableFrom(clazz)); + return !flag; + } +} diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java b/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java index 416d6827..e7c8bd89 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java @@ -16,6 +16,8 @@ package band.kessoku.lib.config.api; import band.kessoku.lib.base.ModUtils; +import band.kessoku.lib.base.reflect.ModifiersUtil; +import band.kessoku.lib.base.reflect.ReflectUtil; import band.kessoku.lib.config.KessokuConfig; import band.kessoku.lib.config.api.annotations.Comment; import band.kessoku.lib.config.api.annotations.Comments; @@ -84,7 +86,9 @@ public boolean load() { // Check the value is public and not static try { Field field = this.getClass().getField(key); - if (!Modifier.isPublic(field.getModifiers()) || Modifier.isStatic(field.getModifiers())) continue; + if (!ModifiersUtil.isPublicOrStatic(field, true, false)) { + continue; + } value = (ConfigValue) ReflectionUtil.getFieldValue(field, this); } catch (NoSuchFieldException e) { continue; @@ -143,12 +147,9 @@ public void reset() { List fields = new ArrayList<>(); for (Field declaredField : this.getClass().getDeclaredFields()) { - declaredField.setAccessible(true); - - final boolean flag0 = declaredField.getDeclaringClass().isAssignableFrom(ConfigValue.class); - final boolean flag1 = Modifier.isPublic(declaredField.getModifiers()); - final boolean flag2 = !Modifier.isStatic(declaredField.getModifiers()); - if (flag0 && flag1 && flag2) { + final boolean flag0 = ReflectUtil.isAssignableFrom(declaredField, ConfigValue.class); + final boolean flag1 = ModifiersUtil.isPublicOrStatic(declaredField, true, false); + if (flag0 && flag1) { fields.add(declaredField); } } @@ -167,8 +168,8 @@ public ImmutableList getValidCategories() { for (Field declaredField : this.getClass().getDeclaredFields()) { declaredField.setAccessible(true); - final boolean flag0 = declaredField.getDeclaringClass().isAssignableFrom(AbstractConfig.class); - final boolean flag1 = Modifier.isPublic(declaredField.getModifiers()); + final boolean flag0 = ReflectUtil.isAssignableFrom(declaredField, AbstractConfig.class); + final boolean flag1 = ModifiersUtil.isPublic(declaredField); if (flag0 && flag1){ fields.add(declaredField); } @@ -181,15 +182,10 @@ public ImmutableList getValidCategories() { private ImmutableList getValidFields() { ImmutableList.Builder builder = ImmutableList.builder(); for (Field declaredField : this.getClass().getDeclaredFields()) { - declaredField.setAccessible(true); - - final boolean flag0 = declaredField.getDeclaringClass().isAssignableFrom(AbstractConfig.class); - final boolean flag1 = declaredField.getDeclaringClass().isAssignableFrom(ConfigValue.class); - final boolean flag2 = Modifier.isPublic(declaredField.getModifiers()); - - final var flag = flag0 || flag1; + final boolean flag0 = ReflectUtil.isAssignableFrom(declaredField, AbstractConfig.class, ConfigValue.class); + final boolean flag1 = Modifier.isPublic(declaredField.getModifiers()); - if (flag && flag2){ + if (flag0 && flag1){ builder.add(declaredField); } } @@ -199,7 +195,7 @@ private ImmutableList getValidFields() { private Map serialize() { ImmutableMap.Builder builder = ImmutableMap.builder(); for (Field field : this.getValidFields()) { - field.setAccessible(true); + ReflectUtil.makeAccessible(field); final String name = field.isAnnotationPresent(Name.class) ? field.getAnnotation(Name.class).value() : field.getName(); final String[] comments = field.isAnnotationPresent(Comments.class) ? (String[]) Arrays.stream(field.getAnnotation(Comments.class).value()).map(Comment::value).toArray() : new String[0]; diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/Json5Serializer.java b/config/common/src/main/java/band/kessoku/lib/config/serializers/Json5Serializer.java similarity index 97% rename from config/common/src/main/java/band/kessoku/lib/config/api/serializers/Json5Serializer.java rename to config/common/src/main/java/band/kessoku/lib/config/serializers/Json5Serializer.java index 3e5c3f40..5d5174aa 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/Json5Serializer.java +++ b/config/common/src/main/java/band/kessoku/lib/config/serializers/Json5Serializer.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package band.kessoku.lib.config.api.serializers; +package band.kessoku.lib.config.serializers; import band.kessoku.lib.config.api.AbstractConfig; import band.kessoku.lib.config.api.ConfigSerializer; diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/JsonSerializer.java b/config/common/src/main/java/band/kessoku/lib/config/serializers/JsonSerializer.java similarity index 97% rename from config/common/src/main/java/band/kessoku/lib/config/api/serializers/JsonSerializer.java rename to config/common/src/main/java/band/kessoku/lib/config/serializers/JsonSerializer.java index 38d331a4..4de1e205 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/JsonSerializer.java +++ b/config/common/src/main/java/band/kessoku/lib/config/serializers/JsonSerializer.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package band.kessoku.lib.config.api.serializers; +package band.kessoku.lib.config.serializers; import band.kessoku.lib.config.api.AbstractConfig; import band.kessoku.lib.config.api.ConfigSerializer; diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/TomlSerializer.java b/config/common/src/main/java/band/kessoku/lib/config/serializers/TomlSerializer.java similarity index 96% rename from config/common/src/main/java/band/kessoku/lib/config/api/serializers/TomlSerializer.java rename to config/common/src/main/java/band/kessoku/lib/config/serializers/TomlSerializer.java index 5b5afe5b..7b714eac 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/TomlSerializer.java +++ b/config/common/src/main/java/band/kessoku/lib/config/serializers/TomlSerializer.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package band.kessoku.lib.config.api.serializers; +package band.kessoku.lib.config.serializers; import band.kessoku.lib.config.api.AbstractConfig; import band.kessoku.lib.config.api.ConfigSerializer; diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/BooleanValue.java b/config/common/src/main/java/band/kessoku/lib/config/values/BooleanValue.java similarity index 96% rename from config/common/src/main/java/band/kessoku/lib/config/api/values/BooleanValue.java rename to config/common/src/main/java/band/kessoku/lib/config/values/BooleanValue.java index b9120543..f2848618 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/BooleanValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/values/BooleanValue.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package band.kessoku.lib.config.api.values; +package band.kessoku.lib.config.values; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/DefaultConfigValue.java b/config/common/src/main/java/band/kessoku/lib/config/values/DefaultConfigValue.java similarity index 97% rename from config/common/src/main/java/band/kessoku/lib/config/api/values/DefaultConfigValue.java rename to config/common/src/main/java/band/kessoku/lib/config/values/DefaultConfigValue.java index 460c8623..1caf0932 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/DefaultConfigValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/values/DefaultConfigValue.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package band.kessoku.lib.config.api.values; +package band.kessoku.lib.config.values; import band.kessoku.lib.config.api.ConfigValue; diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/DoubleValue.java b/config/common/src/main/java/band/kessoku/lib/config/values/DoubleValue.java similarity index 96% rename from config/common/src/main/java/band/kessoku/lib/config/api/values/DoubleValue.java rename to config/common/src/main/java/band/kessoku/lib/config/values/DoubleValue.java index 3c05a1b7..e80ffd27 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/DoubleValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/values/DoubleValue.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package band.kessoku.lib.config.api.values; +package band.kessoku.lib.config.values; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/FloatValue.java b/config/common/src/main/java/band/kessoku/lib/config/values/FloatValue.java similarity index 96% rename from config/common/src/main/java/band/kessoku/lib/config/api/values/FloatValue.java rename to config/common/src/main/java/band/kessoku/lib/config/values/FloatValue.java index 1d66d0ff..fb28087b 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/FloatValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/values/FloatValue.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package band.kessoku.lib.config.api.values; +package band.kessoku.lib.config.values; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/IntegerValue.java b/config/common/src/main/java/band/kessoku/lib/config/values/IntegerValue.java similarity index 96% rename from config/common/src/main/java/band/kessoku/lib/config/api/values/IntegerValue.java rename to config/common/src/main/java/band/kessoku/lib/config/values/IntegerValue.java index ce7539cb..99214ef0 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/IntegerValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/values/IntegerValue.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package band.kessoku.lib.config.api.values; +package band.kessoku.lib.config.values; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/ListValue.java b/config/common/src/main/java/band/kessoku/lib/config/values/ListValue.java similarity index 99% rename from config/common/src/main/java/band/kessoku/lib/config/api/values/ListValue.java rename to config/common/src/main/java/band/kessoku/lib/config/values/ListValue.java index ecf17e84..1a8ceab6 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/ListValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/values/ListValue.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package band.kessoku.lib.config.api.values; +package band.kessoku.lib.config.values; import com.google.common.collect.ImmutableList; import org.jetbrains.annotations.Contract; diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/LongValue.java b/config/common/src/main/java/band/kessoku/lib/config/values/LongValue.java similarity index 96% rename from config/common/src/main/java/band/kessoku/lib/config/api/values/LongValue.java rename to config/common/src/main/java/band/kessoku/lib/config/values/LongValue.java index 2de89dc5..2e4aa9bc 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/LongValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/values/LongValue.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package band.kessoku.lib.config.api.values; +package band.kessoku.lib.config.values; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/MapValue.java b/config/common/src/main/java/band/kessoku/lib/config/values/MapValue.java similarity index 98% rename from config/common/src/main/java/band/kessoku/lib/config/api/values/MapValue.java rename to config/common/src/main/java/band/kessoku/lib/config/values/MapValue.java index 39858f37..4afc78c8 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/MapValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/values/MapValue.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package band.kessoku.lib.config.api.values; +package band.kessoku.lib.config.values; import com.google.common.collect.ImmutableMap; import org.jetbrains.annotations.Contract; diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/StringValue.java b/config/common/src/main/java/band/kessoku/lib/config/values/StringValue.java similarity index 96% rename from config/common/src/main/java/band/kessoku/lib/config/api/values/StringValue.java rename to config/common/src/main/java/band/kessoku/lib/config/values/StringValue.java index 6d75a28e..3b0bd6fd 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/StringValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/values/StringValue.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package band.kessoku.lib.config.api.values; +package band.kessoku.lib.config.values; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; From faad756bf7a42b0ff9daac2a2fe38bb9573ef6df Mon Sep 17 00:00:00 2001 From: Amarok Date: Sat, 28 Sep 2024 14:09:47 +0800 Subject: [PATCH 11/17] =?UTF-8?q?=F0=9F=90=BA=F0=9F=92=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kessoku/lib/config/serializers/Json5Serializer.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/config/common/src/main/java/band/kessoku/lib/config/serializers/Json5Serializer.java b/config/common/src/main/java/band/kessoku/lib/config/serializers/Json5Serializer.java index 5d5174aa..9630be0e 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/serializers/Json5Serializer.java +++ b/config/common/src/main/java/band/kessoku/lib/config/serializers/Json5Serializer.java @@ -45,9 +45,13 @@ private Json5Builder.ObjectBean toBean(Map { - for (String comment : valueWithComment.comments()) objectBean.addNote(comment); - if (valueWithComment.object() instanceof Map) + for (String comment : valueWithComment.comments()) { + objectBean.addNote(comment); + } + + if (valueWithComment.object() instanceof Map) { objectBean.addBean(s, this.toBean((Map) valueWithComment.object())); + } }); return objectBean; } From 5d8efb82b35de736c13ec03007b6b3379280273f Mon Sep 17 00:00:00 2001 From: Amarok Date: Sat, 28 Sep 2024 14:13:56 +0800 Subject: [PATCH 12/17] =?UTF-8?q?=F0=9F=90=BA=F0=9F=92=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/band/kessoku/lib/config/values/ListValue.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/config/common/src/main/java/band/kessoku/lib/config/values/ListValue.java b/config/common/src/main/java/band/kessoku/lib/config/values/ListValue.java index 1a8ceab6..eab4155f 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/values/ListValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/values/ListValue.java @@ -16,6 +16,7 @@ package band.kessoku.lib.config.values; import com.google.common.collect.ImmutableList; +import com.google.common.collect.Sets; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Unmodifiable; @@ -113,7 +114,11 @@ public boolean remove(Object o) { @Override public boolean containsAll(@NotNull Collection c) { - return this.value.containsAll(c); + /* Amarok Note: + * ArrayList 的数据存储量不可知的情况下,悲观假设有大量数据,那么 ArrayList#containsAll 的效率会低的令人发指... + * 虽说如果数据量少的话套一层 Set 也是无端浪费性能... 但我依然建议悲观演算。 + * */ + return Sets.newHashSet(this.value).containsAll(c); } @Override From 27859df046a84f65fa1b70bc29ccc8971cc06707 Mon Sep 17 00:00:00 2001 From: RawDiamondMC Date: Fri, 4 Oct 2024 19:29:01 +0800 Subject: [PATCH 13/17] =?UTF-8?q?=F0=9F=92=8E=20:anger:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 00824b81b561f1d0914514e3297252721b3ceea6. --- .../lib/config/{ => api}/serializers/Json5Serializer.java | 2 +- .../lib/config/{ => api}/serializers/JsonSerializer.java | 2 +- .../lib/config/{ => api}/serializers/TomlSerializer.java | 2 +- .../band/kessoku/lib/config/{ => api}/values/BooleanValue.java | 2 +- .../kessoku/lib/config/{ => api}/values/DefaultConfigValue.java | 2 +- .../band/kessoku/lib/config/{ => api}/values/DoubleValue.java | 2 +- .../band/kessoku/lib/config/{ => api}/values/FloatValue.java | 2 +- .../band/kessoku/lib/config/{ => api}/values/IntegerValue.java | 2 +- .../band/kessoku/lib/config/{ => api}/values/ListValue.java | 2 +- .../band/kessoku/lib/config/{ => api}/values/LongValue.java | 2 +- .../java/band/kessoku/lib/config/{ => api}/values/MapValue.java | 2 +- .../band/kessoku/lib/config/{ => api}/values/StringValue.java | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) rename config/common/src/main/java/band/kessoku/lib/config/{ => api}/serializers/Json5Serializer.java (97%) rename config/common/src/main/java/band/kessoku/lib/config/{ => api}/serializers/JsonSerializer.java (97%) rename config/common/src/main/java/band/kessoku/lib/config/{ => api}/serializers/TomlSerializer.java (96%) rename config/common/src/main/java/band/kessoku/lib/config/{ => api}/values/BooleanValue.java (96%) rename config/common/src/main/java/band/kessoku/lib/config/{ => api}/values/DefaultConfigValue.java (97%) rename config/common/src/main/java/band/kessoku/lib/config/{ => api}/values/DoubleValue.java (96%) rename config/common/src/main/java/band/kessoku/lib/config/{ => api}/values/FloatValue.java (96%) rename config/common/src/main/java/band/kessoku/lib/config/{ => api}/values/IntegerValue.java (96%) rename config/common/src/main/java/band/kessoku/lib/config/{ => api}/values/ListValue.java (99%) rename config/common/src/main/java/band/kessoku/lib/config/{ => api}/values/LongValue.java (96%) rename config/common/src/main/java/band/kessoku/lib/config/{ => api}/values/MapValue.java (98%) rename config/common/src/main/java/band/kessoku/lib/config/{ => api}/values/StringValue.java (96%) diff --git a/config/common/src/main/java/band/kessoku/lib/config/serializers/Json5Serializer.java b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/Json5Serializer.java similarity index 97% rename from config/common/src/main/java/band/kessoku/lib/config/serializers/Json5Serializer.java rename to config/common/src/main/java/band/kessoku/lib/config/api/serializers/Json5Serializer.java index 9630be0e..bed20f94 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/serializers/Json5Serializer.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/Json5Serializer.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package band.kessoku.lib.config.serializers; +package band.kessoku.lib.config.api.serializers; import band.kessoku.lib.config.api.AbstractConfig; import band.kessoku.lib.config.api.ConfigSerializer; diff --git a/config/common/src/main/java/band/kessoku/lib/config/serializers/JsonSerializer.java b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/JsonSerializer.java similarity index 97% rename from config/common/src/main/java/band/kessoku/lib/config/serializers/JsonSerializer.java rename to config/common/src/main/java/band/kessoku/lib/config/api/serializers/JsonSerializer.java index 4de1e205..38d331a4 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/serializers/JsonSerializer.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/JsonSerializer.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package band.kessoku.lib.config.serializers; +package band.kessoku.lib.config.api.serializers; import band.kessoku.lib.config.api.AbstractConfig; import band.kessoku.lib.config.api.ConfigSerializer; diff --git a/config/common/src/main/java/band/kessoku/lib/config/serializers/TomlSerializer.java b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/TomlSerializer.java similarity index 96% rename from config/common/src/main/java/band/kessoku/lib/config/serializers/TomlSerializer.java rename to config/common/src/main/java/band/kessoku/lib/config/api/serializers/TomlSerializer.java index 7b714eac..5b5afe5b 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/serializers/TomlSerializer.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/TomlSerializer.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package band.kessoku.lib.config.serializers; +package band.kessoku.lib.config.api.serializers; import band.kessoku.lib.config.api.AbstractConfig; import band.kessoku.lib.config.api.ConfigSerializer; diff --git a/config/common/src/main/java/band/kessoku/lib/config/values/BooleanValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/BooleanValue.java similarity index 96% rename from config/common/src/main/java/band/kessoku/lib/config/values/BooleanValue.java rename to config/common/src/main/java/band/kessoku/lib/config/api/values/BooleanValue.java index f2848618..b9120543 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/values/BooleanValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/BooleanValue.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package band.kessoku.lib.config.values; +package band.kessoku.lib.config.api.values; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; diff --git a/config/common/src/main/java/band/kessoku/lib/config/values/DefaultConfigValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/DefaultConfigValue.java similarity index 97% rename from config/common/src/main/java/band/kessoku/lib/config/values/DefaultConfigValue.java rename to config/common/src/main/java/band/kessoku/lib/config/api/values/DefaultConfigValue.java index 1caf0932..460c8623 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/values/DefaultConfigValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/DefaultConfigValue.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package band.kessoku.lib.config.values; +package band.kessoku.lib.config.api.values; import band.kessoku.lib.config.api.ConfigValue; diff --git a/config/common/src/main/java/band/kessoku/lib/config/values/DoubleValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/DoubleValue.java similarity index 96% rename from config/common/src/main/java/band/kessoku/lib/config/values/DoubleValue.java rename to config/common/src/main/java/band/kessoku/lib/config/api/values/DoubleValue.java index e80ffd27..3c05a1b7 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/values/DoubleValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/DoubleValue.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package band.kessoku.lib.config.values; +package band.kessoku.lib.config.api.values; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; diff --git a/config/common/src/main/java/band/kessoku/lib/config/values/FloatValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/FloatValue.java similarity index 96% rename from config/common/src/main/java/band/kessoku/lib/config/values/FloatValue.java rename to config/common/src/main/java/band/kessoku/lib/config/api/values/FloatValue.java index fb28087b..1d66d0ff 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/values/FloatValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/FloatValue.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package band.kessoku.lib.config.values; +package band.kessoku.lib.config.api.values; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; diff --git a/config/common/src/main/java/band/kessoku/lib/config/values/IntegerValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/IntegerValue.java similarity index 96% rename from config/common/src/main/java/band/kessoku/lib/config/values/IntegerValue.java rename to config/common/src/main/java/band/kessoku/lib/config/api/values/IntegerValue.java index 99214ef0..ce7539cb 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/values/IntegerValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/IntegerValue.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package band.kessoku.lib.config.values; +package band.kessoku.lib.config.api.values; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; diff --git a/config/common/src/main/java/band/kessoku/lib/config/values/ListValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/ListValue.java similarity index 99% rename from config/common/src/main/java/band/kessoku/lib/config/values/ListValue.java rename to config/common/src/main/java/band/kessoku/lib/config/api/values/ListValue.java index eab4155f..fb703f77 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/values/ListValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/ListValue.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package band.kessoku.lib.config.values; +package band.kessoku.lib.config.api.values; import com.google.common.collect.ImmutableList; import com.google.common.collect.Sets; diff --git a/config/common/src/main/java/band/kessoku/lib/config/values/LongValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/LongValue.java similarity index 96% rename from config/common/src/main/java/band/kessoku/lib/config/values/LongValue.java rename to config/common/src/main/java/band/kessoku/lib/config/api/values/LongValue.java index 2e4aa9bc..2de89dc5 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/values/LongValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/LongValue.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package band.kessoku.lib.config.values; +package band.kessoku.lib.config.api.values; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; diff --git a/config/common/src/main/java/band/kessoku/lib/config/values/MapValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/MapValue.java similarity index 98% rename from config/common/src/main/java/band/kessoku/lib/config/values/MapValue.java rename to config/common/src/main/java/band/kessoku/lib/config/api/values/MapValue.java index 4afc78c8..39858f37 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/values/MapValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/MapValue.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package band.kessoku.lib.config.values; +package band.kessoku.lib.config.api.values; import com.google.common.collect.ImmutableMap; import org.jetbrains.annotations.Contract; diff --git a/config/common/src/main/java/band/kessoku/lib/config/values/StringValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/StringValue.java similarity index 96% rename from config/common/src/main/java/band/kessoku/lib/config/values/StringValue.java rename to config/common/src/main/java/band/kessoku/lib/config/api/values/StringValue.java index 3b0bd6fd..6d75a28e 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/values/StringValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/StringValue.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package band.kessoku.lib.config.values; +package band.kessoku.lib.config.api.values; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; From 8f97c730d033fda69c9dfd917cc8ab160b46f38d Mon Sep 17 00:00:00 2001 From: RawDiamondMC Date: Fri, 4 Oct 2024 19:29:56 +0800 Subject: [PATCH 14/17] =?UTF-8?q?Revert=20"=F0=9F=90=BA=F0=9F=92=BB"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 5d8efb82b35de736c13ec03007b6b3379280273f. --- .../java/band/kessoku/lib/config/api/values/ListValue.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/ListValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/ListValue.java index fb703f77..ecf17e84 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/ListValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/ListValue.java @@ -16,7 +16,6 @@ package band.kessoku.lib.config.api.values; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Sets; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Unmodifiable; @@ -114,11 +113,7 @@ public boolean remove(Object o) { @Override public boolean containsAll(@NotNull Collection c) { - /* Amarok Note: - * ArrayList 的数据存储量不可知的情况下,悲观假设有大量数据,那么 ArrayList#containsAll 的效率会低的令人发指... - * 虽说如果数据量少的话套一层 Set 也是无端浪费性能... 但我依然建议悲观演算。 - * */ - return Sets.newHashSet(this.value).containsAll(c); + return this.value.containsAll(c); } @Override From e8c788ec5219cdb9cd4f2751c6c12a8175928481 Mon Sep 17 00:00:00 2001 From: RawDiamondMC Date: Fri, 4 Oct 2024 19:47:21 +0800 Subject: [PATCH 15/17] =?UTF-8?q?=F0=9F=92=8E=E2=98=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/base/reflect/ModifiersUtil.java | 53 ++++--------------- .../kessoku/lib/base/reflect/ReflectUtil.java | 12 +---- 2 files changed, 13 insertions(+), 52 deletions(-) diff --git a/base/common/src/main/java/band/kessoku/lib/base/reflect/ModifiersUtil.java b/base/common/src/main/java/band/kessoku/lib/base/reflect/ModifiersUtil.java index 58bd6d3f..903be6c1 100644 --- a/base/common/src/main/java/band/kessoku/lib/base/reflect/ModifiersUtil.java +++ b/base/common/src/main/java/band/kessoku/lib/base/reflect/ModifiersUtil.java @@ -1,86 +1,55 @@ package band.kessoku.lib.base.reflect; -import java.lang.reflect.Field; -import java.lang.reflect.Method; +import java.lang.reflect.Member; import java.lang.reflect.Modifier; public final class ModifiersUtil { + private ModifiersUtil() { + } /* === Common === */ - public static boolean isPublic(Field field) { + public static boolean isPublic(Member field) { return Modifier.isPublic(field.getModifiers()); } - public static boolean isPublic(Method method) { - return Modifier.isPublic(method.getModifiers()); - } - - public static boolean isStatic(Field field) { + public static boolean isStatic(Member field) { return Modifier.isStatic(field.getModifiers()); } - public static boolean isStatic(Method method) { - return Modifier.isStatic(method.getModifiers()); - } - /* === Common Combo === */ - public static boolean isPublicAndStatic(Field field) { + public static boolean isPublicAndStatic(Member field) { return isPublic(field) && isStatic(field); } - public static boolean isPublicAndStatic(Method method) { - return isPublic(method) && isStatic(method); - } - - public static boolean isPublicOrStatic(Field field, boolean shouldPublic, boolean shouldStatic) { + public static boolean isPublicOrStatic(Member field, boolean shouldPublic, boolean shouldStatic) { return shouldPublic == isPublic(field) && shouldStatic == isStatic(field); } - public static boolean isPublicOrStatic(Method method, boolean shouldPublic, boolean shouldStatic) { - return shouldPublic == isPublic(method) && shouldStatic == isStatic(method); - } - /* === Common End === */ /* === Data Object === */ - public static boolean isVolatile(Field field) { + public static boolean isVolatile(Member field) { return Modifier.isVolatile(field.getModifiers()); } - public static boolean isVolatile(Method method) { - return Modifier.isVolatile(method.getModifiers()); - } - - public static boolean isTransient(Field field) { + public static boolean isTransient(Member field) { return Modifier.isTransient(field.getModifiers()); } - public static boolean isTransient(Method method) { - return Modifier.isTransient(method.getModifiers()); - } - /* === Data Object End === */ /* === Low Usage Tools === */ - public static boolean isFinal(Field field) { + public static boolean isFinal(Member field) { return Modifier.isFinal(field.getModifiers()); } - public static boolean isFinal(Method method) { - return Modifier.isFinal(method.getModifiers()); - } - - public static boolean isProtected(Field field) { + public static boolean isProtected(Member field) { return Modifier.isProtected(field.getModifiers()); } - public static boolean isProtected(Method method) { - return Modifier.isProtected(method.getModifiers()); - } - /* === Low Usage Tools End === */ } diff --git a/base/common/src/main/java/band/kessoku/lib/base/reflect/ReflectUtil.java b/base/common/src/main/java/band/kessoku/lib/base/reflect/ReflectUtil.java index ad8bd9cb..27db667e 100644 --- a/base/common/src/main/java/band/kessoku/lib/base/reflect/ReflectUtil.java +++ b/base/common/src/main/java/band/kessoku/lib/base/reflect/ReflectUtil.java @@ -1,21 +1,13 @@ package band.kessoku.lib.base.reflect; -import org.apache.logging.log4j.core.util.ReflectionUtil; - import java.lang.reflect.Field; -import java.lang.reflect.Method; import java.util.Arrays; public final class ReflectUtil { - public static void makeAccessible(Field field) { - ReflectionUtil.makeAccessible(field); - } - - public static void makeAccessible(Method method) { - ReflectionUtil.makeAccessible(method); + private ReflectUtil() { } - public static boolean isAssignableFrom(Field field, Class ... clazzs) { + public static boolean isAssignableFrom(Field field, Class... clazzs) { var flag = Arrays.stream(clazzs).anyMatch(clazz -> !field.getType().isAssignableFrom(clazz)); return !flag; } From 037e32ab63819f697bd49bf03eeea6a514e20347 Mon Sep 17 00:00:00 2001 From: RawDiamondMC Date: Fri, 4 Oct 2024 19:50:45 +0800 Subject: [PATCH 16/17] =?UTF-8?q?=F0=9F=92=8E=F0=9F=92=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/band/kessoku/lib/config/api/AbstractConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java b/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java index e7c8bd89..aaddaee1 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java @@ -195,7 +195,7 @@ private ImmutableList getValidFields() { private Map serialize() { ImmutableMap.Builder builder = ImmutableMap.builder(); for (Field field : this.getValidFields()) { - ReflectUtil.makeAccessible(field); + ReflectionUtil.makeAccessible(field); final String name = field.isAnnotationPresent(Name.class) ? field.getAnnotation(Name.class).value() : field.getName(); final String[] comments = field.isAnnotationPresent(Comments.class) ? (String[]) Arrays.stream(field.getAnnotation(Comments.class).value()).map(Comment::value).toArray() : new String[0]; From c88962655ca54e434648d9579abbf196baaedbab Mon Sep 17 00:00:00 2001 From: RawDiamondMC Date: Fri, 4 Oct 2024 19:59:37 +0800 Subject: [PATCH 17/17] move it --- .../band/kessoku/lib/{ => api}/base/reflect/ModifiersUtil.java | 2 +- .../band/kessoku/lib/{ => api}/base/reflect/ReflectUtil.java | 2 +- .../main/java/band/kessoku/lib/api/config/AbstractConfig.java | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) rename base/common/src/main/java/band/kessoku/lib/{ => api}/base/reflect/ModifiersUtil.java (96%) rename base/common/src/main/java/band/kessoku/lib/{ => api}/base/reflect/ReflectUtil.java (88%) diff --git a/base/common/src/main/java/band/kessoku/lib/base/reflect/ModifiersUtil.java b/base/common/src/main/java/band/kessoku/lib/api/base/reflect/ModifiersUtil.java similarity index 96% rename from base/common/src/main/java/band/kessoku/lib/base/reflect/ModifiersUtil.java rename to base/common/src/main/java/band/kessoku/lib/api/base/reflect/ModifiersUtil.java index 903be6c1..c26a1aa4 100644 --- a/base/common/src/main/java/band/kessoku/lib/base/reflect/ModifiersUtil.java +++ b/base/common/src/main/java/band/kessoku/lib/api/base/reflect/ModifiersUtil.java @@ -1,4 +1,4 @@ -package band.kessoku.lib.base.reflect; +package band.kessoku.lib.api.base.reflect; import java.lang.reflect.Member; import java.lang.reflect.Modifier; diff --git a/base/common/src/main/java/band/kessoku/lib/base/reflect/ReflectUtil.java b/base/common/src/main/java/band/kessoku/lib/api/base/reflect/ReflectUtil.java similarity index 88% rename from base/common/src/main/java/band/kessoku/lib/base/reflect/ReflectUtil.java rename to base/common/src/main/java/band/kessoku/lib/api/base/reflect/ReflectUtil.java index 27db667e..ef6df4db 100644 --- a/base/common/src/main/java/band/kessoku/lib/base/reflect/ReflectUtil.java +++ b/base/common/src/main/java/band/kessoku/lib/api/base/reflect/ReflectUtil.java @@ -1,4 +1,4 @@ -package band.kessoku.lib.base.reflect; +package band.kessoku.lib.api.base.reflect; import java.lang.reflect.Field; import java.util.Arrays; diff --git a/config/common/src/main/java/band/kessoku/lib/api/config/AbstractConfig.java b/config/common/src/main/java/band/kessoku/lib/api/config/AbstractConfig.java index a22073bd..d3e35313 100644 --- a/config/common/src/main/java/band/kessoku/lib/api/config/AbstractConfig.java +++ b/config/common/src/main/java/band/kessoku/lib/api/config/AbstractConfig.java @@ -27,6 +27,8 @@ import java.util.function.Consumer; import band.kessoku.lib.api.KessokuLib; +import band.kessoku.lib.api.base.reflect.ModifiersUtil; +import band.kessoku.lib.api.base.reflect.ReflectUtil; import band.kessoku.lib.api.config.annotations.Comment; import band.kessoku.lib.api.config.annotations.Comments; import band.kessoku.lib.api.config.annotations.Name;