Skip to content

Commit

Permalink
euhhh backend yk
Browse files Browse the repository at this point in the history
kotlinify build scripts
add modrinth publishing
make commands work
add minecraft experience cape
  • Loading branch information
not-coded committed Dec 6, 2024
1 parent 7ede4b0 commit 9e6bb36
Show file tree
Hide file tree
Showing 13 changed files with 145 additions and 200 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changes:
- multiple backend changes
- replace "-" (\uFF0D) with [hidden]
- /namehistory, /getcape and /getskin now work on 1.21.2+
100 changes: 0 additions & 100 deletions build.gradle

This file was deleted.

86 changes: 86 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
plugins {
id("fabric-loom") version "1.9.2"
id("com.modrinth.minotaur") version "2.+"
}

val modName = property("mod.name").toString()
version = "${property("mod.version")}" + "+" + "${property("mod.version_name")}"
group = property("mod.maven_group").toString()


base {
archivesName.set(modName)
}

dependencies {
minecraft("com.mojang:minecraft:${property("deps.minecraft")}")
mappings("net.fabricmc:yarn:${property("deps.yarn_mappings")}:v2")
modImplementation("net.fabricmc:fabric-loader:${property("deps.fabric_loader")}")

modImplementation("net.fabricmc.fabric-api:fabric-api:${property("deps.fabric_api")}")
}

loom {
decompilers {
get("vineflower").apply { // Adds names to lambdas - useful for mixins
options.put("mark-corresponding-synthetics", "1")
}
}

runConfigs.all {
ideConfigGenerated(true)
vmArgs("-Dmixin.debug.export=true")
runDir = "../../run"
}
}

val target = ">=${property("mod.min_target")}- <=${property("mod.max_target")}"

tasks.processResources {
val expandProps = mapOf(
"version" to project.version,
"minecraftVersion" to target,
"javaVersion" to project.property("deps.java")
)

filesMatching("fabric.mod.json") {
expand(expandProps)
}

inputs.properties(expandProps)
}

java {
withSourcesJar()

val javaVersion = if (project.property("deps.java") == "8") JavaVersion.VERSION_1_8 else JavaVersion.VERSION_17

sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}

tasks.register<Copy>("buildAndCollect") {
group = "build"
from(tasks.remapJar.get().archiveFile)
into(rootProject.layout.buildDirectory.file("libs"))
dependsOn("build")
}


modrinth {
token.set(System.getenv("MODRINTH_TOKEN"))
projectId.set("namefabric")
versionNumber.set(version.toString())
versionName.set("v$version")
versionType.set("release")
uploadFile.set(tasks.remapJar)
gameVersions.addAll(property("publishing.supported_versions").toString().split(","))
loaders.addAll("fabric", "quilt")
//featured = true

dependencies {
optional.project("fabric-api")
}

changelog = rootProject.file("CHANGES.md").readText()
}
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ mod.version_name=[VERSIONED]
mod.min_target=[VERSIONED]
mod.max_target=[VERSIONED]

publishing.supported_versions=[VERSIONED]

# Dependencies
# https://fabricmc.net/develop
deps.yarn=[VERSIONED]
Expand Down
24 changes: 0 additions & 24 deletions settings.gradle

This file was deleted.

26 changes: 26 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
pluginManagement {
repositories {
maven("https://maven.fabricmc.net/")

gradlePluginPortal()
maven("https://maven.kikugie.dev/snapshots")
}
}

plugins {
id("dev.kikugie.stonecutter") version "0.5-beta.3"
}

stonecutter {
kotlinController = true
centralScript = "build.gradle.kts"

shared {
versions("1.16.5", "1.20.6")
vcsVersion = "1.20.6"
}

create(rootProject)
}

rootProject.name = "NameFabric"
23 changes: 3 additions & 20 deletions src/main/java/net/notcoded/namefabric/command/GetCapeCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;

import net.notcoded.namefabric.utils.HttpAPI;
import net.notcoded.namefabric.utils.MinecraftAPI;
import org.jetbrains.annotations.NotNull;

Expand All @@ -17,21 +18,12 @@
//? if >=1.19 {
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import java.time.Duration;
//?} elif <1.19 {
/*import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
import net.notcoded.namefabric.utils.HttpAPI;
*///?}

public class GetCapeCommand {
//? if >=1.19 {
private static final HttpClient httpClient = HttpClient.newHttpClient();
//?}
private static String playerName;
private static boolean isUsingPlayerName = false;

Expand Down Expand Up @@ -89,17 +81,7 @@ private static int getCapesUUID(@NotNull FabricClientCommandSource source, @NotN
if((uuid.length() == 32 || uuid.length() == 36) || isUsingPlayerName){
String url = "https://sessionserver.mojang.com/session/minecraft/profile/" + uuid;

//? if >=1.19 {
HttpRequest request = HttpRequest.newBuilder(URI.create(url))
.timeout(Duration.ofSeconds(5))
.GET()
.build();
httpClient.sendAsync(request, HttpResponse.BodyHandlers.ofString())
.thenApply(HttpResponse::body)
.thenAccept(response -> source.getClient().send(() -> handleResponse(source, response)));
//?} elif <1.19 {
/*handleResponse(source, HttpAPI.get(url)); *///?}

handleResponse(source, HttpAPI.get(url));
} else {
sendError(source, "command.all.invalid.uuid");
}
Expand Down Expand Up @@ -153,5 +135,6 @@ public static int getCapesPlayer(FabricClientCommandSource source, @NotNull Stri
capes.put("Valentine Texture", "Valentine");
capes.put("Test Texture", "Test");
capes.put("http://textures.minecraft.net/texture/56c35628fe1c4d59dd52561a3d03bfa4e1a76d397c8b9c476c2f77cb6aebb1df", "MCC 15th Year");
capes.put("http://textures.minecraft.net/texture/7658c5025c77cfac7574aab3af94a46a8886e3b7722a895255fbf22ab8652434", "Minecraft Experience");
}
}
23 changes: 2 additions & 21 deletions src/main/java/net/notcoded/namefabric/command/GetSkinCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;

import net.notcoded.namefabric.utils.HttpAPI;
import net.notcoded.namefabric.utils.MinecraftAPI;
import java.util.Base64;
import static com.mojang.brigadier.arguments.StringArgumentType.getString;
Expand All @@ -14,25 +15,16 @@
//? if >=1.19 {
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import java.time.Duration;
//?} elif <1.19 {
/*import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
import net.notcoded.namefabric.utils.HttpAPI;
*///?}

public class GetSkinCommand {

private static String playerName;
private static boolean isUsingPlayerName = false;

//? if >=1.19 {
private static final HttpClient httpClient = HttpClient.newHttpClient();
//?}
public static void register(CommandDispatcher<FabricClientCommandSource> dispatcher) {
dispatcher.register(ClientCommandManager.literal("getskin")
.then(ClientCommandManager.argument("player/uuid", string())
Expand Down Expand Up @@ -82,18 +74,7 @@ private static void handleResponse(FabricClientCommandSource source, String resp
private static int getSkinsUUID(FabricClientCommandSource source, String uuid) {
if((uuid.length() == 32 || uuid.length() == 36) || isUsingPlayerName) {
String url = "https://sessionserver.mojang.com/session/minecraft/profile/" + uuid;

//? if >=1.19 {
HttpRequest request = HttpRequest.newBuilder(URI.create(url))
.timeout(Duration.ofSeconds(5))
.GET()
.build();
httpClient.sendAsync(request, HttpResponse.BodyHandlers.ofString())
.thenApply(HttpResponse::body)
.thenAccept(response -> source.getClient().send(() -> handleResponse(source, response)));
//?} elif <1.19 {
/*handleResponse(source, HttpAPI.get(url)); *///?}

handleResponse(source, HttpAPI.get(url));
} else {
sendError(source, "command.all.invalid.uuid");
}
Expand Down
Loading

0 comments on commit 9e6bb36

Please sign in to comment.