Skip to content

Commit

Permalink
🐺📖
Browse files Browse the repository at this point in the history
  • Loading branch information
AmarokIce committed Nov 8, 2024
1 parent 80157f7 commit 5bc9c72
Show file tree
Hide file tree
Showing 131 changed files with 305 additions and 402 deletions.
11 changes: 7 additions & 4 deletions base/common/src/main/java/band/kessoku/lib/api/KessokuLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@
*/
package band.kessoku.lib.api;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.*;

import org.jetbrains.annotations.UnmodifiableView;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.ServiceLoader;

public final class KessokuLib {
private static final List<Class<?>> initializedModules = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@
*/
package band.kessoku.lib.api.base;

import java.lang.reflect.Constructor;
import java.util.*;

import org.jetbrains.annotations.NotNull;

import java.lang.reflect.Constructor;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public final class KessokuUtils {
private KessokuUtils() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import band.kessoku.lib.api.KessokuLib;
import band.kessoku.lib.api.base.KessokuBase;

import net.fabricmc.api.ModInitializer;

public final class KessokuBaseFabric implements ModInitializer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
*/
package band.kessoku.lib.api.base.neoforge;

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 final class NeoEventUtils {
private NeoEventUtils() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import band.kessoku.lib.api.KessokuLib;
import band.kessoku.lib.api.base.KessokuBase;

import net.neoforged.fml.common.Mod;

@Mod(KessokuBase.MOD_ID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
import band.kessoku.lib.api.util.command.ClientCommandSourceExtension;
import band.kessoku.lib.event.api.Event;
import com.mojang.brigadier.CommandDispatcher;
import org.jetbrains.annotations.ApiStatus;

import net.minecraft.command.CommandRegistryAccess;
import org.jetbrains.annotations.ApiStatus;

@ApiStatus.NonExtendable
public interface ClientCommandRegistryEvent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@

import band.kessoku.lib.event.api.Event;
import com.mojang.brigadier.CommandDispatcher;
import org.jetbrains.annotations.ApiStatus;

import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import org.jetbrains.annotations.ApiStatus;

@ApiStatus.NonExtendable
public interface CommandRegistryEvent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
*/
package band.kessoku.lib.api.util.command;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import band.kessoku.lib.api.KessokuLib;
import band.kessoku.lib.command.KessokuCommand;
import band.kessoku.lib.mixin.command.HelpCommandAccessor;
Expand All @@ -34,11 +30,14 @@
import com.mojang.brigadier.exceptions.CommandExceptionType;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.tree.CommandNode;
import org.jetbrains.annotations.Nullable;

import net.minecraft.client.MinecraftClient;
import net.minecraft.text.Text;
import net.minecraft.text.Texts;
import org.jetbrains.annotations.Nullable;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public final class ClientCommandUtils {
private static @Nullable CommandDispatcher<ClientCommandSourceExtension> activeDispatcher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
package band.kessoku.lib.mixin.command;

import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import net.minecraft.server.command.HelpCommand;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

import net.minecraft.server.command.HelpCommand;

@Mixin(HelpCommand.class)
public interface HelpCommandAccessor {
@Accessor("FAILED_EXCEPTION")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import band.kessoku.lib.api.entrypoint.entrypoints.KessokuModInitializer;
import band.kessoku.lib.api.event.command.CommandRegistryEvent;

import net.minecraft.server.command.CommandManager;
import net.minecraft.text.Text;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import band.kessoku.lib.api.KessokuLib;
import band.kessoku.lib.command.KessokuCommand;

import net.fabricmc.api.ModInitializer;

public final class KessokuCommandFabric implements ModInitializer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import band.kessoku.lib.api.event.command.CommandRegistryEvent;
import band.kessoku.lib.api.util.command.ClientCommandSourceExtension;
import com.mojang.brigadier.CommandDispatcher;

import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@
package band.kessoku.lib.mixin.command.fabric;

import band.kessoku.lib.api.util.command.ClientCommandSourceExtension;
import org.spongepowered.asm.mixin.Mixin;

import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.text.Text;
import net.minecraft.util.math.Vec2f;
import net.minecraft.util.math.Vec3d;

import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import org.spongepowered.asm.mixin.Mixin;

@Mixin(FabricClientCommandSource.class)
public interface FabricClientCommandSourceMixin extends ClientCommandSourceExtension {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import band.kessoku.lib.api.event.command.CommandRegistryEvent;
import band.kessoku.lib.api.util.command.ClientCommandSourceExtension;
import com.mojang.brigadier.CommandDispatcher;

import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.client.event.RegisterClientCommandsEvent;
import net.neoforged.neoforge.event.RegisterCommandsEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import band.kessoku.lib.api.KessokuLib;
import band.kessoku.lib.command.KessokuCommand;

import net.neoforged.fml.common.Mod;
import net.neoforged.fml.loading.FMLLoader;
import net.neoforged.neoforge.common.NeoForge;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@
package band.kessoku.lib.mixin.command.neoforge;

import band.kessoku.lib.api.util.command.ClientCommandSourceExtension;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientCommandSource;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

@Mixin(ClientCommandSource.class)
abstract class ClientCommandSourceMixin implements ClientCommandSourceExtension {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,6 @@
*/
package band.kessoku.lib.api.config;

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.api.KessokuLib;
import band.kessoku.lib.api.base.reflect.ModifiersUtil;
import band.kessoku.lib.api.base.reflect.ReflectUtil;
Expand All @@ -38,6 +27,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<Consumer<AbstractConfig>> preSave = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public static Type asType(Object o) {
case Float ignored -> FLOAT;
case Double ignored -> DOUBLE;

/* AmarokIce Note:
/*
AmarokIce Note:
try catch 对性能会造成额外影响。此处 throw 后在 { @code AbstractConfig } 中捕获是无意义的。
因此,改用 NULL 作为空置对象。
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
*/
package band.kessoku.lib.api.config;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

import org.apache.commons.io.FileUtils;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
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<AbstractConfig, Class<ConfigSerializer>> configs = new HashMap<>();
private static final Map<Class<? extends ConfigSerializer>, ConfigSerializer> serializerCache = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
*/
package band.kessoku.lib.api.config.serializers;

import java.util.Map;

import band.kessoku.lib.api.config.AbstractConfig;
import band.kessoku.lib.api.config.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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package band.kessoku.lib.api.config.serializers;

import java.util.Map;

import band.kessoku.lib.api.config.AbstractConfig;
import band.kessoku.lib.api.config.ConfigSerializer;
import club.someoneice.json.JSON;
Expand All @@ -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<String, AbstractConfig.ValueWithComment> value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
*/
package band.kessoku.lib.api.config.serializers;

import java.util.Map;

import band.kessoku.lib.api.config.AbstractConfig;
import band.kessoku.lib.api.config.ConfigSerializer;
import com.electronwill.nightconfig.core.CommentedConfig;

import java.util.Map;

//todo
public class TomlSerializer implements ConfigSerializer {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
*/
package band.kessoku.lib.api.config.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<Boolean> {
private BooleanValue(Supplier<Boolean> defaultValue) {
super(defaultValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*/
package band.kessoku.lib.api.config.values;

import java.util.function.Supplier;

import band.kessoku.lib.api.config.ConfigValue;

import java.util.function.Supplier;

sealed abstract class DefaultConfigValue<T> implements ConfigValue<T, T> permits BooleanValue, DoubleValue, FloatValue, IntegerValue, ListValue, LongValue, MapValue, StringValue {
public final Supplier<T> defaultValue;
public T value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
*/
package band.kessoku.lib.api.config.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<Double> {
private DoubleValue(Supplier<Double> defaultValue) {
super(defaultValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
*/
package band.kessoku.lib.api.config.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<Float> {
private FloatValue(Supplier<Float> defaultValue) {
super(defaultValue);
Expand Down
Loading

0 comments on commit 5bc9c72

Please sign in to comment.