Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"console": "internalConsole",
"stopOnEntry": false,
"mainClass": "net.fabricmc.devlaunchinjector.Main",
"vmArgs": "\"-Dfabric.dli.config\u003dE:\\CoflWork\\SkyblockMod\\.gradle\\loom-cache\\launch.cfg\" \"-Dfabric.dli.env\u003dclient\" \"-Dfabric.dli.main\u003dnet.minecraft.launchwrapper.Launch\"",
"vmArgs": "\"-Dfabric.dli.config\u003dC:\\Coding\\Cofl\\SkyCofl-GUI\\.gradle\\loom-cache\\launch.cfg\" \"-Dfabric.dli.env\u003dclient\" \"-Dfabric.dli.main\u003dnet.minecraft.launchwrapper.Launch\"",
"args": "",
"env": {},
"projectName": ""
Expand All @@ -22,7 +22,7 @@
"console": "internalConsole",
"stopOnEntry": false,
"mainClass": "net.fabricmc.devlaunchinjector.Main",
"vmArgs": "\"-Dfabric.dli.config\u003dE:\\CoflWork\\SkyblockMod\\.gradle\\loom-cache\\launch.cfg\" \"-Dfabric.dli.env\u003dserver\" \"-Dfabric.dli.main\u003dnet.minecraft.launchwrapper.Launch\"",
"vmArgs": "\"-Dfabric.dli.config\u003dC:\\Coding\\Cofl\\SkyCofl-GUI\\.gradle\\loom-cache\\launch.cfg\" \"-Dfabric.dli.env\u003dserver\" \"-Dfabric.dli.main\u003dnet.minecraft.launchwrapper.Launch\"",
"args": "\"nogui\"",
"env": {},
"projectName": ""
Expand Down
81 changes: 20 additions & 61 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import org.apache.commons.lang3.SystemUtils
plugins {
idea
java
Expand All @@ -7,13 +6,8 @@ plugins {
id("com.github.johnrengelman.shadow") version "7.1.2"
}

group = "de.torui.coflsky"
val baseGroup: String by project
val mcVersion: String by project
val version: String by project
val mixinGroup = "$baseGroup.mixin"
val modid: String by project
val transformerFile = file("src/main/resources/accesstransformer.cfg")
group = "de.torui.coflmod"
version = "1.6.0"

// Toolchains:
java {
Expand All @@ -22,34 +16,13 @@ java {

// Minecraft configuration:
loom {
log4jConfigs.from(file("log4j2.xml"))
launchConfigs {
"client" {
// If you don't want mixins, remove these lines
property("mixin.debug", "true")
arg("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker")
arg("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker")
}
}
runConfigs {
"client" {
if (SystemUtils.IS_OS_MAC_OSX) {
// This argument causes a crash on macOS
vmArgs.remove("-XstartOnFirstThread")
}
}
remove(getByName("server"))
}
forge {
pack200Provider.set(dev.architectury.pack200.java.Pack200Adapter())
// If you don't want mixins, remove this lines
mixinConfig("mixins.$modid.json")
if (transformerFile.exists()) {
println("Installing access transformer")
accessTransformer(transformerFile)
}
}
mixin {
defaultRefmapName.set("mixins.$modid.refmap.json")
}
}

Expand All @@ -64,7 +37,8 @@ repositories {
maven("https://repo.spongepowered.org/maven/")
// If you don't want to log in with your real minecraft account, remove this line
maven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1")
maven ("https://jitpack.io" )
// Polyfrost repo for OneConfig
maven("https://repo.polyfrost.org/releases")
}

val shadowImpl by configurations.creating {
Expand All @@ -77,19 +51,21 @@ dependencies {
forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9")

annotationProcessor("org.spongepowered:mixin:0.8.4-SNAPSHOT")
//modImplementation(include("org.greenrobot:eventbus-java:3.3.1"))
shadowImpl("org.greenrobot:eventbus-java:3.3.1")
shadowImpl("com.github.Coflnet:coflskycore:5691541e14")

shadowImpl("com.neovisionaries:nv-websocket-client:2.14")
// OneConfig library for legacy Forge 1.8.9 (compile-time only, wrapper will fetch at runtime)
compileOnly("cc.polyfrost:oneconfig-1.8.9-forge:0.2.2-alpha+")
// Shade the LaunchWrapper tweaker inside the mod jar so it runs before Forge
shadowImpl("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta17")

// If you don't want mixins, remove these lines
shadowImpl("org.spongepowered:mixin:0.7.11-SNAPSHOT") {
isTransitive = false
}
annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT")
// ByteBuddy for runtime class generation
shadowImpl("net.bytebuddy:byte-buddy-dep:1.11.22")

// If you don't want to log in with your real minecraft account, remove this line
runtimeOnly("me.djtheredstoner:DevAuth-forge-legacy:1.2.1")
modRuntimeOnly("me.djtheredstoner:DevAuth-forge-legacy:1.2.0") {
exclude(group = "org.jetbrains.kotlin")
exclude(group = "org.jetbrains.kotlinx")
}

}

Expand All @@ -99,32 +75,16 @@ tasks.withType(JavaCompile::class) {
options.encoding = "UTF-8"
}

tasks.withType(org.gradle.jvm.tasks.Jar::class) {
archiveBaseName.set(modid)
tasks.withType(Jar::class) {
archiveBaseName.set("SkyCofl")
manifest.attributes.run {
this["FMLCorePluginContainsFMLMod"] = "true"
this["ForceLoadAsMod"] = "true"

// If you don't want mixins, remove these lines
this["TweakClass"] = "org.spongepowered.asm.launch.MixinTweaker"
this["MixinConfigs"] = "mixins.$modid.json"
if (transformerFile.exists())
this["FMLAT"] = "${modid}_at.cfg"
this["Manifest-Version"] = "1.0"
this["TweakClass"] = "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker"
}
}

tasks.processResources {
inputs.property("version", project.version)
inputs.property("mcversion", mcVersion)
inputs.property("modid", modid)
inputs.property("basePackage", baseGroup)

filesMatching(listOf("mcmod.info", "mixins.$modid.json")) {
expand(inputs.properties)
}

rename("accesstransformer.cfg", "META-INF/${modid}_at.cfg")
}

val remapJar by tasks.named<net.fabricmc.loom.task.RemapJarTask>("remapJar") {
archiveClassifier.set("all")
Expand All @@ -143,4 +103,3 @@ tasks.shadowJar {
}

tasks.assemble.get().dependsOn(tasks.remapJar)

6 changes: 2 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
loom.platform=forge
org.gradle.jvmargs=-Xmx2g
baseGroup = de.torui.coflsky
mcVersion = 1.8.9
modid = skycofl
version = 1.7.0
# Use JDK 17 for Gradle itself (update path if different)
org.gradle.java.home=C:\\Program Files\\Java\\jdk-17
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 0 additions & 4 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,4 @@ pluginManagement {
}
}

plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version("0.6.0")
}

rootProject.name = "SkyCofl"
72 changes: 59 additions & 13 deletions src/main/java/de/torui/coflsky/CoflSky.java
Original file line number Diff line number Diff line change
@@ -1,41 +1,54 @@
package de.torui.coflsky;


import java.io.File;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;

import CoflCore.CoflCore;
import com.google.gson.Gson;
import de.torui.CoflCore.CoflCore.configuration.LocalConfig;
import CoflCore.configuration.GUIType;
import de.torui.coflsky.configuration.LocalConfig;
import de.torui.coflsky.config.CoflConfig;
import de.torui.coflsky.gui.GUIType;
import de.torui.coflsky.handlers.EventRegistry;
import de.torui.coflsky.listeners.ChatListener;
import de.torui.coflsky.listeners.OneConfigOpenListener;
import de.torui.coflsky.proxy.APIKeyManager;
import de.torui.coflsky.gui.tfm.ButtonRemapper;
import de.torui.coflsky.gui.tfm.ChatMessageSendHandler;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import org.lwjgl.input.Keyboard;
import CoflCore.network.WSClientWrapper;
import de.torui.coflsky.network.WSClientWrapper;
import net.minecraft.client.settings.KeyBinding;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.common.MinecraftForge;

@Mod(modid = CoflSky.MODID, version = CoflSky.VERSION)
public class CoflSky {
public static final String MODID = "CoflSky";
public static final String VERSION = "1.7.0";
public static final String VERSION = "1.6.0";

public static WSClientWrapper Wrapper;
public static KeyBinding[] keyBindings;

public static EventRegistry Events;
public static File configFile;
private File coflDir;
public static LocalConfig config;

public static final String[] webSocketURIPrefix = new String[]{
"wss://sky.coflnet.com/modsocket",
// fallback for old java versions not supporting new tls certificates
"ws://sky-mod.coflnet.com/modsocket",
};

public static String CommandUri = Config.BaseUrl + "/api/mod/commands";
private final static APIKeyManager apiKeyManager = new APIKeyManager();


@EventHandler
public void preInit(FMLPreInitializationEvent event) {
Expand All @@ -44,18 +57,35 @@ public void preInit(FMLPreInitializationEvent event) {
coflDir = new File(event.getModConfigurationDirectory(), "CoflSky");
coflDir.mkdirs();
configFile = new File(coflDir, "config.json");
CoflCore cofl = new CoflCore();
cofl.init(coflDir.getAbsoluteFile().toPath());
cofl.registerEventFile(new WSCommandHandler());
try {
if (configFile.isFile()) {
configString = new String(Files.readAllBytes(Paths.get(configFile.getPath())));
config = gson.fromJson(configString, LocalConfig.class);
}
} catch (Exception e) {
e.printStackTrace();
}
if (config == null) {
config = LocalConfig.createDefaultConfig();
}

MinecraftForge.EVENT_BUS.register(new ChatListener());
try {
this.apiKeyManager.loadIfExists();
} catch (Exception exception) {
exception.printStackTrace();
}

MinecraftForge.EVENT_BUS.register(new ChatListener());
// Initialise OneConfig configuration (GUI will open via keybind automatically)
CoflConfig oneConfig = new CoflConfig();
// Cache all the mods on load
WSCommandHandler.cacheMods();
}

@EventHandler
public void init(FMLInitializationEvent event) {
CoflSky.Wrapper = new WSClientWrapper(webSocketURIPrefix);

keyBindings = new KeyBinding[]{
new KeyBinding("key.replay_last.onclick", Keyboard.KEY_NONE, "SkyCofl"),
new KeyBinding("key.start_highest_bid", Keyboard.KEY_NONE, "SkyCofl"),
Expand All @@ -66,17 +96,33 @@ public void init(FMLInitializationEvent event) {
ClientCommandHandler.instance.registerCommand(new CoflSkyCommand());
ClientCommandHandler.instance.registerCommand(new ColfCommand());
ClientCommandHandler.instance.registerCommand(new FlipperChatCommand());
// register OneConfig command
ClientCommandHandler.instance.registerCommand(new de.torui.coflsky.commands.CoflGuiCommand());

for (int i = 0; i < keyBindings.length; ++i) {
ClientRegistry.registerKeyBinding(keyBindings[i]);
}
}
Events = new EventRegistry();
MinecraftForge.EVENT_BUS.register(Events);
if (CoflCore.config.purchaseOverlay == GUIType.TFM) {
if (config.purchaseOverlay == GUIType.TFM) {
MinecraftForge.EVENT_BUS.register(ButtonRemapper.getInstance());
}
MinecraftForge.EVENT_BUS.register(new ChatMessageSendHandler());
// GUI open listener for OneConfig to fetch server settings
MinecraftForge.EVENT_BUS.register(new OneConfigOpenListener());
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
config.saveConfig(configFile, config);
try {
apiKeyManager.saveKey();
} catch (Exception exception) {
exception.printStackTrace();
}
}));
}

public static APIKeyManager getAPIKeyManager() {
return apiKeyManager;
}

}

Loading