aboutsummaryrefslogtreecommitdiff
path: root/mod/src
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2025-01-08 19:25:29 +0100
committerLinnea Gräf <nea@nea.moe>2025-01-08 19:25:29 +0100
commitd1e16a47819509ed645bb93e1a173e0a97025cef (patch)
treeefbe886d9ac1ab4ea01788cb4842812fd0af9079 /mod/src
parentf694daf322bbb4ff530a9332547c5c8337c3e0c0 (diff)
downloadLocalTransactionLedger-d1e16a47819509ed645bb93e1a173e0a97025cef.tar.gz
LocalTransactionLedger-d1e16a47819509ed645bb93e1a173e0a97025cef.tar.bz2
LocalTransactionLedger-d1e16a47819509ed645bb93e1a173e0a97025cef.zip
build: Move mod to subproject
Diffstat (limited to 'mod/src')
-rw-r--r--mod/src/main/java/moe/nea/ledger/init/AutoDiscoveryMixinPlugin.java193
-rw-r--r--mod/src/main/java/moe/nea/ledger/mixin/AccessorGuiEditSign.java12
-rw-r--r--mod/src/main/java/moe/nea/ledger/mixin/MouseClickEventPatch.java18
-rw-r--r--mod/src/main/java/moe/nea/ledger/mixin/OnInitializationCompletePatch.java18
-rw-r--r--mod/src/main/java/moe/nea/ledger/mixin/devenv/RegisterModResourcesPatch.java66
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/ConfigCommand.kt31
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/DebouncedValue.kt38
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/DebugDataCommand.kt34
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/DevUtil.kt7
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/ExpiringValue.kt30
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/ItemChange.kt84
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/ItemId.kt35
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/ItemIdProvider.kt188
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/ItemUtil.kt90
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/Ledger.kt205
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/LedgerEntry.kt29
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/LedgerLogger.kt136
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/LogChatCommand.kt27
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/MCUUIDUtil.kt22
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/NumberUtil.kt117
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/QueryCommand.kt197
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/ScoreboardUtil.kt29
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/TelemetryProvider.kt66
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/TransactionType.kt35
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/TriggerCommand.kt34
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/config/DebugOptions.kt13
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/config/LedgerConfig.kt35
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/config/MainOptions.kt27
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/config/SynchronizationOptions.kt11
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/config/UpdateUi.kt17
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/config/UpdateUiMarker.kt6
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/database/DBLogEntry.kt24
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/database/DBUpgrade.kt68
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/database/Database.kt57
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/database/Upgrades.kt20
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/database/schema.dot23
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/events/BeforeGuiAction.kt11
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/events/ChatReceived.kt15
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/events/ExtraSupplyIdEvent.kt12
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/events/GuiClickEvent.kt9
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/events/InitializationComplete.kt6
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/events/RegistrationFinishedEvent.kt7
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/events/SupplyDebugInfo.kt10
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/events/TriggerEvent.kt7
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/events/WorldLoadEvent.kt5
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/events/WorldSwitchEvent.kt6
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/AccessorySwapperDetection.kt34
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/AllowanceDetection.kt37
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/AuctionHouseDetection.kt143
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/BankDetection.kt49
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/BazaarDetection.kt58
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/BazaarOrderDetection.kt95
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/BitsDetection.kt62
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/BitsShopDetection.kt66
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/ChestDetection.kt48
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/DragonEyePlacementDetection.kt47
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/DragonSacrificeDetection.kt72
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/DungeonChestDetection.kt95
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/ExternalDataProvider.kt43
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/EyedropsDetection.kt35
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/ForgeDetection.kt48
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/GambleDetection.kt62
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/GodPotionDetection.kt35
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/GodPotionMixinDetection.kt38
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/KatDetection.kt95
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/KuudraChestDetection.kt45
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/MineshaftCorpseDetection.kt81
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/MinionDetection.kt61
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/NpcDetection.kt111
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/UpdateChecker.kt167
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/VisitorDetection.kt87
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/utils/BorderedTextTracker.kt41
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/utils/ErrorUtil.kt52
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/utils/GsonUtil.kt10
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/utils/MinecraftExecutor.kt10
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/utils/NoSideEffects.kt4
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/utils/network/Request.kt40
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/utils/network/RequestUtil.kt63
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/utils/network/Response.kt19
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/utils/telemetry/BooleanContext.kt10
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/utils/telemetry/CommonKeys.kt9
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/utils/telemetry/Context.kt57
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/utils/telemetry/ContextValue.kt70
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/utils/telemetry/EventRecorder.kt9
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/utils/telemetry/ExceptionContextValue.kt39
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/utils/telemetry/JsonElementContext.kt9
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/utils/telemetry/LoggingEventRecorder.kt25
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/utils/telemetry/RecordedEvent.kt5
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/utils/telemetry/Severity.kt8
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/utils/telemetry/Span.kt146
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/utils/telemetry/StringContext.kt11
-rw-r--r--mod/src/main/resources/ledgerkeystore.jksbin0 -> 104393 bytes
-rw-r--r--mod/src/main/resources/mcmod.info18
-rw-r--r--mod/src/main/resources/mixins.moneyledger.json7
-rw-r--r--mod/src/test/kotlin/moe/nea/ledger/NumberUtilKtTest.kt17
95 files changed, 4523 insertions, 0 deletions
diff --git a/mod/src/main/java/moe/nea/ledger/init/AutoDiscoveryMixinPlugin.java b/mod/src/main/java/moe/nea/ledger/init/AutoDiscoveryMixinPlugin.java
new file mode 100644
index 0000000..56841b5
--- /dev/null
+++ b/mod/src/main/java/moe/nea/ledger/init/AutoDiscoveryMixinPlugin.java
@@ -0,0 +1,193 @@
+package moe.nea.ledger.init;
+
+import net.minecraft.launchwrapper.Launch;
+import org.spongepowered.asm.lib.tree.ClassNode;
+import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
+import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Stream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+/**
+ * A mixin plugin to automatically discover all mixins in the current JAR.
+ * <p>
+ * This mixin plugin automatically scans your entire JAR (or class directory, in case of an in-IDE launch) for classes inside of your
+ * mixin package and registers those. It does this recursively for sub packages of the mixin package as well. This means you will need
+ * to only have mixin classes inside of your mixin package, which is good style anyway.
+ *
+ * @author Linnea Gräf
+ */
+public class AutoDiscoveryMixinPlugin implements IMixinConfigPlugin {
+ private static final List<AutoDiscoveryMixinPlugin> mixinPlugins = new ArrayList<>();
+
+ public static List<AutoDiscoveryMixinPlugin> getMixinPlugins() {
+ return mixinPlugins;
+ }
+
+ private String mixinPackage;
+
+ @Override
+ public void onLoad(String mixinPackage) {
+ this.mixinPackage = mixinPackage;
+ mixinPlugins.add(this);
+ }
+
+ /**
+ * Resolves the base class root for a given class URL. This resolves either the JAR root, or the class file root.
+ * In either case the return value of this + the class name will resolve back to the original class url, or to other
+ * class urls for other classes.
+ */
+ public URL getBaseUrlForClassUrl(URL classUrl) {
+ String string = classUrl.toString();
+ if (classUrl.getProtocol().equals("jar")) {
+ try {
+ return new URL(string.substring(4).split("!")[0]);
+ } catch (MalformedURLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ if (string.endsWith(".class")) {
+ try {
+ return new URL(string.replace("\\", "/")
+ .replace(getClass().getCanonicalName()
+ .replace(".", "/") + ".class", ""));
+ } catch (MalformedURLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return classUrl;
+ }
+
+ /**
+ * Get the package that contains all the mixins. This value is set by mixin itself using {@link #onLoad}.
+ */
+ public String getMixinPackage() {
+ return mixinPackage;
+ }
+
+ /**
+ * Get the path inside the class root to the mixin package
+ */
+ public String getMixinBaseDir() {
+ return mixinPackage.replace(".", "/");
+ }
+
+ /**
+ * A list of all discovered mixins.
+ */
+ private List<String> mixins = null;
+
+ /**
+ * Try to add mixin class ot the mixins based on the filepath inside of the class root.
+ * Removes the {@code .class} file suffix, as well as the base mixin package.
+ * <p><b>This method cannot be called after mixin initialization.</p>
+ *
+ * @param className the name or path of a class to be registered as a mixin.
+ */
+ public void tryAddMixinClass(String className) {
+ String norm = (className.endsWith(".class") ? className.substring(0, className.length() - ".class".length()) : className)
+ .replace("\\", "/")
+ .replace("/", ".");
+ if (norm.startsWith(getMixinPackage() + ".") && !norm.endsWith(".")) {
+ mixins.add(norm.substring(getMixinPackage().length() + 1));
+ }
+ }
+
+ /**
+ * Search through the JAR or class directory to find mixins contained in {@link #getMixinPackage()}
+ */
+ @Override
+ public List<String> getMixins() {
+ if (mixins != null) return mixins;
+ System.out.println("Trying to discover mixins");
+ mixins = new ArrayList<>();
+ URL classUrl = getClass().getProtectionDomain().getCodeSource().getLocation();
+ System.out.println("Found classes at " + classUrl);
+ Path file;
+ try {
+ file = Paths.get(getBaseUrlForClassUrl(classUrl).toURI());
+ } catch (URISyntaxException e) {
+ throw new RuntimeException(e);
+ }
+ System.out.println("Base directory found at " + file);
+ if (Files.isDirectory(file)) {
+ walkDir(file);
+ } else {
+ walkJar(file);
+ }
+ System.out.println("Found mixins: " + mixins);
+
+ if (!(Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment")) {
+ mixins.removeIf(it -> it.contains("devenv"));
+ }
+
+ return mixins;
+ }
+
+ /**
+ * Search through directory for mixin classes based on {@link #getMixinBaseDir}.
+ *
+ * @param classRoot The root directory in which classes are stored for the default package.
+ */
+ private void walkDir(Path classRoot) {
+ System.out.println("Trying to find mixins from directory");
+ try (Stream<Path> classes = Files.walk(classRoot.resolve(getMixinBaseDir()))) {
+ classes.map(it -> classRoot.relativize(it).toString())
+ .forEach(this::tryAddMixinClass);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Read through a JAR file, trying to find all mixins inside.
+ */
+ private void walkJar(Path file) {
+ System.out.println("Trying to find mixins from jar file");
+ try (ZipInputStream zis = new ZipInputStream(Files.newInputStream(file))) {
+ ZipEntry next;
+ while ((next = zis.getNextEntry()) != null) {
+ tryAddMixinClass(next.getName());
+ zis.closeEntry();
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
+
+ }
+
+ @Override
+ public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
+
+ }
+
+ @Override
+ public String getRefMapperConfig() {
+ return null;
+ }
+
+ @Override
+ public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
+ return true;
+ }
+
+ @Override