Skip to content
Merged
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
197 changes: 20 additions & 177 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,192 +1,35 @@
@file:Suppress("UnstableApiUsage", "PropertyName")
import dev.deftu.gradle.utils.GameSide

import org.polyfrost.gradle.util.noServerRunConfigs
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

// Adds support for kotlin, and adds the Polyfrost Gradle Toolkit
// which we use to prepare the environment.
plugins {
kotlin("jvm")
id("org.polyfrost.multi-version")
id("org.polyfrost.defaults.repo")
id("org.polyfrost.defaults.java")
id("org.polyfrost.defaults.loom")
id("com.github.johnrengelman.shadow")
id("net.kyori.blossom") version "1.3.2"
id("signing")
java
}

// Gets the mod name, version and id from the `gradle.properties` file.
val mod_name: String by project
val mod_version: String by project
val mod_id: String by project
val mod_archives_name: String by project

// Replaces the variables in `ExampleMod.java` to the ones specified in `gradle.properties`.
blossom {
replaceToken("@VER@", mod_version)
replaceToken("@NAME@", mod_name)
replaceToken("@ID@", mod_id)
}

// Sets the mod version to the one specified in `gradle.properties`. Make sure to change this following semver!
version = mod_version
// Sets the group, make sure to change this to your own. It can be a website you own backwards or your GitHub username.
// e.g. com.github.<your username> or com.<your domain>
group = "org.polyfrost"

// Sets the name of the output jar (the one you put in your mods folder and send to other people)
// It outputs all versions of the mod into the `versions/{mcVersion}/build` directory.
base {
archivesName.set("$mod_archives_name-$platform")
}

// Configures Polyfrost Loom, our plugin fork to easily set up the programming environment.
loom {
// Removes the server configs from IntelliJ IDEA, leaving only client runs.
noServerRunConfigs()

// Adds the tweak class if we are building legacy version of forge as per the documentation (https://docs.polyfrost.org)
if (project.platform.isLegacyForge) {
runConfigs {
"client" {
programArgs("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker")
property("mixin.debug.export", "true") // Outputs all mixin changes to `versions/{mcVersion}/run/.mixin.out/class`
}
}
}
// Configures the mixins if we are building for forge
if (project.platform.isForge) {
forge {
mixinConfig("mixins.${mod_id}.json")
}
}
// Configures the name of the mixin "refmap"
mixin.defaultRefmapName.set("mixins.${mod_id}.refmap.json")
id("java")
id("dev.deftu.gradle.tools") version("2.69.+")
id("dev.deftu.gradle.tools.resources") version("2.69.+")
id("dev.deftu.gradle.tools.bloom") version("2.69.+")
id("dev.deftu.gradle.tools.shadow") version("2.69.+")
id("dev.deftu.gradle.tools.minecraft.loom") version("2.69.+")
}

// Creates the shade/shadow configuration, so we can include libraries inside our mod, rather than having to add them separately.
val shade: Configuration by configurations.creating {
configurations.implementation.get().extendsFrom(this)
}
val modShade: Configuration by configurations.creating {
configurations.modImplementation.get().extendsFrom(this)
}

// Configures the output directory for when building from the `src/resources` directory.
sourceSets {
main {
output.setResourcesDir(java.classesDirectory)
}
}

// Adds the Polyfrost maven repository so that we can get the libraries necessary to develop the mod.
repositories {
maven("https://repo.polyfrost.org/releases")
maven("https://repo.polyfrost.org/snapshots")
}

// Configures the libraries/dependencies for your mod.
dependencies {
// Adds the OneConfig library, so we can develop with it.
modCompileOnly("cc.polyfrost:oneconfig-$platform:0.2.2-alpha+")
compileOnly("cc.polyfrost:oneconfig-1.8.9-forge:0.2.2-alpha+")

// Adds DevAuth, which we can use to log in to Minecraft in development.
modRuntimeOnly("me.djtheredstoner:DevAuth-${if (platform.isFabric) "fabric" else if (platform.isLegacyForge) "forge-legacy" else "forge-latest"}:1.2.0")
shade("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta+")
implementation("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta+")

// If we are building for legacy forge, includes the launch wrapper with `shade` as we configured earlier, as well as mixin 0.7.11
if (platform.isLegacyForge) {
compileOnly("org.spongepowered:mixin:0.7.11-SNAPSHOT")
shade("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta17")
}
compileOnly("org.spongepowered:mixin:0.7.11-SNAPSHOT")
}

tasks {
// Processes the `src/resources/mcmod.info`, `fabric.mod.json`, or `mixins.${mod_id}.json` and replaces
// the mod id, name and version with the ones in `gradle.properties`
processResources {
inputs.property("id", mod_id)
inputs.property("name", mod_name)
val java = if (project.platform.mcMinor >= 18) {
17 // If we are playing on version 1.18, set the java version to 17
} else {
// Else if we are playing on version 1.17, use java 16.
if (project.platform.mcMinor == 17)
16
else
8 // For all previous versions, we **need** java 8 (for Forge support).
}
val compatLevel = "JAVA_${java}"
inputs.property("java", java)
inputs.property("java_level", compatLevel)
inputs.property("version", mod_version)
inputs.property("mcVersionStr", project.platform.mcVersionStr)
filesMatching(listOf("mcmod.info", "mixins.${mod_id}.json", "mods.toml")) {
expand(
mapOf(
"id" to mod_id,
"name" to mod_name,
"java" to java,
"java_level" to compatLevel,
"version" to mod_version,
"mcVersionStr" to project.platform.mcVersionStr
)
)
}
filesMatching("fabric.mod.json") {
expand(
mapOf(
"id" to mod_id,
"name" to mod_name,
"java" to java,
"java_level" to compatLevel,
"version" to mod_version,
"mcVersionStr" to project.platform.mcVersionStr.substringBeforeLast(".") + ".x"
)
)
}
}

// Configures the resources to include if we are building for forge or fabric.
withType(Jar::class.java) {
if (project.platform.isFabric) {
exclude("mcmod.info", "mods.toml")
} else {
exclude("fabric.mod.json")
if (project.platform.isLegacyForge) {
exclude("mods.toml")
} else {
exclude("mcmod.info")
}
}
}
toolkitLoomHelper {
useMixinRefMap(modData.id)
useForgeMixin(modData.id)

// Configures our shadow/shade configuration, so we can
// include some dependencies within our mod jar file.
named<ShadowJar>("shadowJar") {
archiveClassifier.set("dev")
configurations = listOf(shade, modShade)
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
useTweaker("cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker")

remapJar {
inputFile.set(shadowJar.get().archiveFile)
archiveClassifier.set("")
}

jar {
// Sets the jar manifest attributes.
if (platform.isLegacyForge) {
manifest.attributes += mapOf(
"ModSide" to "CLIENT", // We aren't developing a server-side mod
"ForceLoadAsMod" to true, // We want to load this jar as a mod, so we force Forge to do so.
"TweakOrder" to "0", // Makes sure that the OneConfig launch wrapper is loaded as soon as possible.
"MixinConfigs" to "mixins.${mod_id}.json", // We want to use our mixin configuration, so we specify it here.
"TweakClass" to "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker" // Loads the OneConfig launch wrapper.
)
}
dependsOn(shadowJar)
archiveClassifier.set("")
enabled = false
}
}
useDevAuth("+")
useProperty("mixin.debug.export", "true", GameSide.CLIENT)
disableRunConfigs(GameSide.SERVER)
}
15 changes: 6 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# gradle.properties file -- CHANGE THE VALUES STARTING WITH `mod_*` AND REMOVE THIS COMMENT.
mod.name=Additional
mod.id=additional
mod.version=3.0.3

# Sets the name of your mod.
mod_name=Additional
# Sets the id of your mod that mod loaders use to recognize it.
mod_id=additional
# Sets the version of your mod. Make sure to update this when you make changes according to semver.
mod_version=3.0.2
# Sets the name of the jar file that you put in your 'mods' folder.
mod_archives_name=Additional
minecraft.version=1.8.9
loom.platform=forge
java.version=8

# Gradle Configuration -- DO NOT TOUCH THESE VALUES.
polyfrost.defaults.loom=3
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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-8.14.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions root.gradle.kts

This file was deleted.

38 changes: 16 additions & 22 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
@file:Suppress("PropertyName")

import groovy.lang.MissingPropertyException

pluginManagement {
repositories {
maven("https://maven.deftu.dev/releases")
maven("https://maven.fabricmc.net")
maven("https://maven.architectury.dev/")
maven("https://maven.minecraftforge.net")
maven("https://repo.essential.gg/repository/maven-public")
maven("https://server.bbkr.space/artifactory/libs-release/")
maven("https://jitpack.io/")

maven("https://maven.deftu.dev/snapshots")
mavenLocal()

gradlePluginPortal()
mavenCentral()
maven("https://repo.polyfrost.org/releases") // Adds the Polyfrost maven repository to get Polyfrost Gradle Toolkit
}
plugins {
val pgtVersion = "0.6.5" // Sets the default versions for Polyfrost Gradle Toolkit
id("org.polyfrost.multi-version.root") version pgtVersion
}
}

val mod_name: String by settings

// Configures the root project Gradle name based on the value in `gradle.properties`
rootProject.name = mod_name
rootProject.buildFileName = "root.gradle.kts"

// Adds all of our build target versions to the classpath if we need to add version-specific code.
listOf(
"1.8.9-forge", // Update this if you want to remove/add a version, along with `build.gradle.kts` and `root.gradle.kts`.
//"1.12.2-forge" // uncomment if you want 1.12.2 support in your mod
).forEach { version ->
include(":$version")
project(":$version").apply {
projectDir = file("versions/$version")
buildFileName = "../../build.gradle.kts"
}
}
val projectName: String = extra["mod.name"]?.toString() ?: throw MissingPropertyException("mod.name has not been set.")
rootProject.name = projectName
rootProject.buildFileName = "build.gradle.kts"
7 changes: 4 additions & 3 deletions src/main/java/me/waffles/additional/Additional.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
@Mod(modid = Additional.MODID, name = Additional.NAME, version = Additional.VERSION)
public class Additional {

public static final String MODID = "@ID@";
public static final String NAME = "@NAME@";
public static final String VERSION = "@VER@";
public static final String MODID = "@MOD_ID@";
public static final String NAME = "@MOD_NAME@";
public static final String VERSION = "@MOD_VERSION@";

public static ModConfig config;
public static EldestRemovalMap<String, Duels> duelsStatsList;
public static EldestRemovalMap<String, Bedwars> bedwarsStatsList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ private void fetchAndPrintStats(String Username, String uuid) {
// fetch stats here
if(!Additional.bedwarsStatsList.containsKey(Username.toLowerCase())) {
try {
Additional.bedwarsStatsList.put(Username.toLowerCase(), fetchPlayerBedwarsStats(uuid));
Additional.playerProfileList.put(Username.toLowerCase(), fetchPlayerProfileData(uuid));
Additional.bedwarsStatsList.put(Username.toLowerCase(), fetchPlayerBedwarsStats(uuid));
} catch (IOException e) {
UChat.chat("Something broke while fetching stats!");
e.printStackTrace();
throw new RuntimeException(e);
}
}
Expand All @@ -63,7 +64,10 @@ private void fetchAndPrintStats(String Username, String uuid) {
private void printStats(String Username) {
PlayerProfile profile = Additional.playerProfileList.get(Username.toLowerCase());

if(profile.getDisplayName() == null) {
if(profile == null) {
UChat.chat("Invalid player");
return;
} else if(profile.getDisplayName() == null) {
UChat.chat(Username + " has no Hypixel stats.");
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
import me.waffles.additional.util.PlayerProfile;
import net.minecraft.client.Minecraft;

import java.io.IOException;
import java.util.NavigableMap;
import java.util.TreeMap;

// debugging
//import java.io.IOException;

@Command(value = "d")
public class DuelsStatsCommand {

Expand Down Expand Up @@ -49,8 +51,8 @@ private void fetchAndPrintStats(String Username, String uuid) {
// fetch stats here
if(!Additional.duelsStatsList.containsKey(Username.toLowerCase())) {
try {
Additional.duelsStatsList.put(Username.toLowerCase(), fetchPlayerDuelsStats(uuid));
Additional.playerProfileList.put(Username.toLowerCase(), fetchPlayerProfileData(uuid));
Additional.duelsStatsList.put(Username.toLowerCase(), fetchPlayerDuelsStats(uuid));
} catch (Exception e) {
UChat.chat("Something broke while fetching stats!");
e.printStackTrace();
Expand All @@ -64,7 +66,10 @@ private void fetchAndPrintStats(String Username, String uuid) {
private void printStats(String Username) {
PlayerProfile profile = Additional.playerProfileList.get(Username.toLowerCase());

if(profile.getDisplayName() == null) {
if(profile == null) {
UChat.chat("Invalid player");
return;
} else if(profile.getDisplayName() == null) {
UChat.chat(Username + " has no Hypixel stats.");
return;
}
Expand Down Expand Up @@ -115,8 +120,7 @@ public String fetchPlayerGuildData(String uuid) {
);
}

public PlayerProfile fetchPlayerProfileData(String uuid)
throws IOException {
public PlayerProfile fetchPlayerProfileData(String uuid) {
String stjson = fetchPlayerData(uuid);
String guild = fetchPlayerGuildData(uuid);
if (stjson == null || stjson.isEmpty() || guild == null || guild.isEmpty()) {
Expand Down
Loading