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
20 changes: 19 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ val sdkVersion = property("library.sdk").toString()
val okaeriConfigsVersion = property("library.okaeri_configs").toString()
val fabricApiVersion = property("deps.fabric_api").toString()
val yaclVersion = property("deps.yacl").toString()
val owoLibVersion = property("deps.owo_lib").toString()
val modMenuVersion = property("deps.modmenu").toString()
val placeholderApiVersion = if (hasProperty("deps.placeholder_api")) property("deps.placeholder_api").toString() else null

Expand Down Expand Up @@ -63,6 +64,7 @@ galaxy {

add(
"https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1",
"https://maven.wispforest.io/releases/",
GNOMECRAFT_RELEASES, NUCLEOID,
OKAERI_RELEASES, OKAERI_SNAPSHOTS,
SRNYX_RELEASES, SRNYX_SNAPSHOTS,
Expand All @@ -82,6 +84,7 @@ galaxy {
"deps_loader" to loaderVersion,
"deps_fabric_api" to fabricApiVersion,
"deps_yacl" to yaclVersion,
"deps_owo_lib" to owoLibVersion,
"deps_modmenu" to modMenuVersion))

platformPublishing {
Expand Down Expand Up @@ -178,6 +181,8 @@ dependencies {
modImplementation("dev.isxander:yet-another-config-lib:$yaclVersion")
modImplementation("com.terraformersmc:modmenu:$modMenuVersion")
placeholderApiVersion?.let { modImplementation("eu.pb4:placeholder-api:$it") }
modImplementation("io.wispforest:owo-lib:$owoLibVersion")
include("io.wispforest:owo-sentinel:$owoLibVersion")

// Dev
modRuntimeOnly("me.djtheredstoner:DevAuth-fabric:1.2.2")
Expand All @@ -200,6 +205,12 @@ stonecutter {
replace("GuiGraphics", "GuiGraphicsExtractor")
replace("net.minecraft.client.renderer.state.CameraRenderState", "net.minecraft.client.renderer.state.level.CameraRenderState")
}
replacements.string(current.parsed >= "1.21.11") {
replace("Components", "UIComponents")
replace("Containers", "UIContainers")
replace("ParentComponent", "ParentUIComponent")
replace("io.wispforest.owo.ui.core.Component", "UIComponent")
}
replacements.string(current.parsed < "1.21") {
replace("GenericMessageScreen", "GenericDirtMessageScreen")
}
Expand Down Expand Up @@ -274,6 +285,13 @@ tasks {
}
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(javaVersionProject.majorVersion)
vendor = JvmVendorSpec.JETBRAINS
}
}

loom {
fabricModJsonPath = rootProject.file("src/main/resources/fabric.mod.json") // Useful for interface injection

Expand All @@ -283,7 +301,7 @@ loom {

runConfigs.all {
preferGradleTask = true
jvmArguments.add("-Dmixin.debug.export=true") // Exports transformed classes for debugging
jvmArguments.add("-Dmixin.debug.export=true -XX:+AllowEnhancedClassRedefinition") // Exports transformed classes for debugging
runDirectory = file("../../run") // Shares the run directory between versions
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/cc/aabss/eventutils/ModMenuImpl.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cc.aabss.eventutils;

import cc.aabss.eventutils.screen.config.ConfigScreen;
import cc.aabss.eventutils.screen.MenuScreen;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import dev.kikugie.fletching_table.fabric.Entrypoint;
Expand All @@ -11,6 +11,6 @@
public class ModMenuImpl implements ModMenuApi {
@Override @NotNull
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return ConfigScreen::getConfigScreen;
return MenuScreen::new;
}
}
8 changes: 4 additions & 4 deletions src/main/java/cc/aabss/eventutils/cache/PlayerCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public PlayerCache(@NotNull EventUtils mod) {
public void addToCache(@NotNull Collection<EAPlayer> players) {
players.forEach(player -> {
final EnrichedPlayer enriched = new EnrichedPlayer(player);
if (enriched.player.minecraft != null && enriched.player.minecraft.uuid != null) {
addToCache(enriched.player.minecraft.uuid, enriched);
if (enriched.minecraft != null && enriched.minecraft.uuid != null) {
addToCache(enriched.minecraft.uuid, enriched);
}
});
}
Expand All @@ -42,8 +42,8 @@ protected EAAction<Map<UUID, EnrichedPlayer>> fetchImpl(@NotNull Collection<UUID
final Map<UUID, EnrichedPlayer> result = new HashMap<>();
for (final EAPlayer player : players) {
final EnrichedPlayer enriched = new EnrichedPlayer(player);
if (enriched.player.minecraft != null && enriched.player.minecraft.uuid != null) {
result.put(enriched.player.minecraft.uuid, enriched);
if (enriched.minecraft != null && enriched.minecraft.uuid != null) {
result.put(enriched.minecraft.uuid, enriched);
}
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class CommandRegister {
public static void register(@NotNull EventUtils mod, @NotNull CommandDispatcher<FabricClientCommandSource> dispatcher) {
// Commands
final LiteralCommandNode<FabricClientCommandSource> config = new ConfigCmd(mod).build();
final LiteralCommandNode<FabricClientCommandSource> link = new LinkCmd(mod).build();
final LiteralCommandNode<FabricClientCommandSource> post = new PostCmd(mod).build();
final LiteralCommandNode<FabricClientCommandSource> teleport = new TeleportCmd(mod).build();
final LiteralCommandNode<FabricClientCommandSource> priority = new PriorityCmd(mod).build();
final LiteralCommandNode<FabricClientCommandSource> priorityTop = new PriorityTopCmd(mod).build();
Expand All @@ -32,6 +34,8 @@ public static void register(@NotNull EventUtils mod, @NotNull CommandDispatcher<
// Build command tree
dispatcher.getRoot().addChild(main);
main.addChild(config);
main.addChild(link);
main.addChild(post);
main.addChild(teleport);
main.addChild(priority);
main.addChild(priorityTop);
Expand Down
36 changes: 36 additions & 0 deletions src/main/java/cc/aabss/eventutils/commands/LinkCmd.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package cc.aabss.eventutils.commands;

import cc.aabss.eventutils.EventUtils;
import cc.aabss.eventutils.versioning.VersionedClient;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.tree.LiteralCommandNode;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.client.Minecraft;
import org.jetbrains.annotations.NotNull;


public class LinkCmd extends EUCommand {
public LinkCmd(@NotNull EventUtils mod) {
super(mod);
}

@Override @NotNull
public LiteralCommandNode<FabricClientCommandSource> build() {
return ClientCommandManager
.literal("link")
.executes(context -> {
execute(context);
return 0;
})
.build();
}

private void execute(@NotNull CommandContext<FabricClientCommandSource> context) {
final Minecraft client = context.getSource().getClient();
client.execute(() -> {
final VersionedClient vClient = new VersionedClient(client);
mod.discordLinkManager.startLink(vClient.screen(), () -> vClient.setScreen(null));
});
}
}
32 changes: 32 additions & 0 deletions src/main/java/cc/aabss/eventutils/commands/PostCmd.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package cc.aabss.eventutils.commands;

import cc.aabss.eventutils.EventUtils;
import cc.aabss.eventutils.screen.EventBuilder;
import cc.aabss.eventutils.versioning.VersionedClient;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.tree.LiteralCommandNode;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import org.jetbrains.annotations.NotNull;


public class PostCmd extends EUCommand {
public PostCmd(@NotNull EventUtils mod) {
super(mod);
}

@Override @NotNull
public LiteralCommandNode<FabricClientCommandSource> build() {
return ClientCommandManager
.literal("post")
.executes(context -> {
execute(context);
return 0;
})
.build();
}

private static void execute(@NotNull CommandContext<FabricClientCommandSource> context) {
new EventBuilder(new VersionedClient(context.getSource().getClient()).screen()).open();
}
}
10 changes: 7 additions & 3 deletions src/main/java/cc/aabss/eventutils/discordrpc/DiscordRPC.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public class DiscordRPC {
public DiscordRPC(@NotNull EventUtils mod) {
this.mod = mod;
this.client.setListener(new CustomIPCListener(this));
this.playerUrl = mod.authManager.player != null && mod.authManager.player.player.discord != null && mod.authManager.player.player.discord.id != null
? utm("https://eventalerts.gg/players/" + mod.authManager.player.player.discord.id, "player")
this.playerUrl = mod.authManager.player != null && mod.authManager.player.discord != null && mod.authManager.player.discord.id != null
? utm("https://eventalerts.gg/players/" + mod.authManager.player.discord.id, "player")
: "https://namemc.com/profile/" + Minecraft.getInstance().getUser().getProfileId();
refreshConnection();
}
Expand Down Expand Up @@ -77,7 +77,11 @@ public void refreshConnection() {
}

public void close() {
client.close();
try {
client.close();
} catch (final IllegalStateException ignored) {
// Not connected, ignore
}
}

public void refresh() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public synchronized void startLink(@Nullable Screen browserParent, @Nullable Run
fail("eventutils.config.discord_link.toast.start");
return;
}
// It's okay for browserParent to be null
Minecraft.getInstance().execute(() -> ConfirmLinkScreen.confirmLinkNow(browserParent, url));
},
t -> {
Expand Down Expand Up @@ -185,7 +186,6 @@ private synchronized void timedOut() {
if (server == null) return;
EventUtils.LOGGER.warn("[DISCORD_LINK] Linking timed out");
cancel();
fail("eventutils.config.discord_link.toast.timeout");
}

private void fail(@NotNull String descriptionKey) {
Expand Down
16 changes: 0 additions & 16 deletions src/main/java/cc/aabss/eventutils/plustag/PlusTag.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package cc.aabss.eventutils.plustag;

import cc.aabss.eventutils.EventUtils;
import cc.aabss.eventutils.versioning.VersionedIdentifier;
import gg.eventalerts.sdk.object.EAPlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
//? if >=1.21.11 {
/*import net.minecraft.resources.Identifier;
*///?} else {
Expand Down Expand Up @@ -59,18 +57,4 @@ public enum PlusTag {
this.textureId = VersionedIdentifier.of("textures/bee/plus/" + name().toLowerCase() + ".png");
this.isUnlocked = isUnlocked;
}

@Nullable
public static PlusTag getBestUnlocked(@Nullable EAPlayer player) {
if (player == null) return null;
PlusTag bestTag = null;
for (final PlusTag tag : PlusTag.values()) {
if (tag.isUnlocked.test(player)) {
bestTag = tag;
break;
}
}
EventUtils.LOGGER.debug("[API] Fetched best tag={} uuid={}", bestTag, player.minecraft != null ? player.minecraft.uuid : "(player.minecraft=null)");
return bestTag;
}
}
Loading