mirror of
https://github.com/TheWhiteDog9487/WhoProvideThisKeybind.git
synced 2026-09-16 15:04:19 +08:00
🧹 cleanup: 清理代码
This commit is contained in:
@@ -3,13 +3,9 @@ package xyz.thewhitedog9487.client.mixin;
|
||||
import xyz.thewhitedog9487.client.MiscellaneousKt;
|
||||
import xyz.thewhitedog9487.client.SettingsKt;
|
||||
import xyz.thewhitedog9487.client.WhoProvideThisKeybindModClient;
|
||||
import xyz.thewhitedog9487.client.ModInfo;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.Tooltip;
|
||||
import net.minecraft.client.gui.screens.options.controls.KeyBindsList;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@@ -10,26 +10,17 @@ 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 org.spongepowered.include.com.google.common.io.Files;
|
||||
import xyz.thewhitedog9487.client.MiscellaneousKt;
|
||||
import xyz.thewhitedog9487.client.ModInfo;
|
||||
import xyz.thewhitedog9487.client.WhoProvideThisKeybindModClient;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Mixin(KeyMapping.class)
|
||||
public class KeyMappingMixin {
|
||||
@Inject(method = "<init>(Ljava/lang/String;Lcom/mojang/blaze3d/platform/InputConstants$Type;ILnet/minecraft/client/KeyMapping$Category;I)V",
|
||||
at = @At("TAIL"))
|
||||
void DiscoverStackTrace(String name, InputConstants.Type type, int value, KeyMapping.Category category, int order, CallbackInfo ci) throws IOException, ClassNotFoundException {
|
||||
void DiscoverStackTrace(String name, InputConstants.Type type, int value, KeyMapping.Category category, int order, CallbackInfo ci) {
|
||||
var StackTraceCLassNames = Arrays.stream(Thread.currentThread().getStackTrace())
|
||||
.map(StackTraceElement::getClassName)
|
||||
.toList();
|
||||
|
||||
@@ -7,7 +7,6 @@ import net.fabricmc.loader.api.FabricLoader
|
||||
import java.nio.file.FileSystems
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.StandardWatchEventKinds
|
||||
import java.nio.file.StandardWatchEventKinds.*
|
||||
|
||||
const val CurrentConfigurationVersionCode: Long = 0
|
||||
class Settings {
|
||||
@@ -80,7 +79,7 @@ class Settings {
|
||||
|
||||
var SettingsHandler: ConfigClassHandler<Settings>? = null
|
||||
|
||||
val ConfigFilePath = FabricLoader
|
||||
val ConfigFilePath: Path = FabricLoader
|
||||
.getInstance()
|
||||
.configDir
|
||||
.resolve(WhoProvideThisKeybindModClient.FriendlyModID + ".json5")
|
||||
@@ -96,7 +95,7 @@ fun RegisterConfigFileReloadWatcher() {
|
||||
val ConfigDirectory = ConfigFilePath.parent
|
||||
try {
|
||||
val WatchService = FileSystems.getDefault().newWatchService()
|
||||
ConfigDirectory.register(WatchService, ENTRY_CREATE, ENTRY_MODIFY, ENTRY_DELETE)
|
||||
ConfigDirectory.register(WatchService, StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_MODIFY, StandardWatchEventKinds.ENTRY_DELETE)
|
||||
while (!Thread.currentThread().isInterrupted) {
|
||||
val WatchKey = WatchService.take()
|
||||
var ShouldReload = false
|
||||
@@ -114,7 +113,7 @@ fun RegisterConfigFileReloadWatcher() {
|
||||
WhoProvideThisKeybindModClient.ClientLogger.info("检测到配置文件变更,已重新加载设置。") }
|
||||
if (!WatchKey.reset()) {
|
||||
break } }
|
||||
} catch (e: InterruptedException) {
|
||||
} catch (_: InterruptedException) {
|
||||
Thread.currentThread().interrupt()
|
||||
} catch (e: IOException) {
|
||||
throw RuntimeException(e) } } }
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package xyz.thewhitedog9487.client
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import xyz.thewhitedog9487.client.Event.RegisterClientLifecycleEvents
|
||||
|
||||
object WhoProvideThisKeybindModClient : ClientModInitializer {
|
||||
const val ModID: String = "whoprovidethiskeybind"
|
||||
const val FriendlyModID = "WhoProvideThisKeybind"
|
||||
val ClientLogger = LoggerFactory.getLogger(FriendlyModID)
|
||||
val ClientLogger: Logger = LoggerFactory.getLogger(FriendlyModID)
|
||||
|
||||
override fun onInitializeClient() {
|
||||
RegisterClientLifecycleEvents() } }
|
||||
Reference in New Issue
Block a user