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
14 changes: 9 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,25 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Set up JDK 21
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: microsoft
java-version: 21
java-version: 25

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
uses: gradle/actions/setup-gradle@v6
with:
build-scan-publish: true
build-scan-terms-of-use-url: 'https://gradle.com/terms-of-service'
build-scan-terms-of-use-agree: 'yes'

- name: Build
run: './gradlew build'

- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v7
with:
name: Island Menu Jar
path: build/libs/*.jar
12 changes: 8 additions & 4 deletions .github/workflows/buildRelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Set up JDK 21
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: microsoft
java-version: 21
java-version: 25

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
uses: gradle/actions/setup-gradle@v6
with:
build-scan-publish: true
build-scan-terms-of-use-url: 'https://gradle.com/terms-of-service'
build-scan-terms-of-use-agree: 'yes'

- name: Build with Gradle
run: './gradlew build'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Island-Menu

Modifies the main menu to be themed around [MCC Island](https://mccisland.net/). Requires [Mod Menu](https://modrinth.com/mod/modmenu), [Cloth Config](https://modrinth.com/mod/cloth-config), and [ServerMainMenu Lib](https://github.com/MoSadie/ServerMainMenu-Lib)
Modifies the main menu to be themed around [MCC Island](https://mccisland.net/). Requires [Mod Menu](https://modrinth.com/mod/modmenu), [Cloth Config](https://modrinth.com/mod/cloth-config), and [SimpleMainMenu Lib](https://github.com/MoSadie/SimpleMainMenu-Lib)

## Features:

Expand Down
21 changes: 10 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
plugins {
id 'fabric-loom' version '1.9-SNAPSHOT'
id 'net.fabricmc.fabric-loom' version "${loom_version}"
}

version = project.mod_version
group = project.maven_group

base {
archivesName = project.archivesBaseName
archivesName = project.archive_base_name
}

loom {
Expand Down Expand Up @@ -61,19 +61,18 @@ repositories {
dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
implementation "net.fabricmc:fabric-loader:${project.loader_version}"

modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"

modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
api("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
exclude(group: "net.fabricmc.fabric-api")
}

modApi("com.terraformersmc:modmenu:${project.mod_menu_version}")
api("com.terraformersmc:modmenu:${project.mod_menu_version}")

//modApi("com.mosadie:ServerMainMenu-Lib:${project.smm_lib_version}")
modApi("maven.modrinth:smm-lib:${project.smm_lib_version}")
//api("com.mosadie:SimpleMainMenu-Lib:${project.smm_lib_version}")
api("maven.modrinth:smm-lib:${project.smm_lib_version}")
}

processResources {
Expand All @@ -85,7 +84,7 @@ processResources {
}
}

def targetJavaVersion = JavaVersion.VERSION_17
def targetJavaVersion = JavaVersion.VERSION_25


java {
Expand All @@ -102,6 +101,6 @@ java {

jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}" }
rename { "${it}_${project.archive_base_name}" }
}
}
18 changes: 9 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21.4
yarn_mappings=1.21.4+build.2
loader_version=0.16.9
minecraft_version=26.1
loader_version=0.18.5
loom_version=1.15-SNAPSHOT

#Fabric api
fabric_version=0.112.0+1.21.4
# Fabric API
fabric_api_version=0.144.3+26.1

# Mod Properties
mod_version=1.4.4
maven_group=com.mosadie
archives_base_name=island-menu
archive_base_name=island-menu

# Dependency Versions
smm_lib_version=2.0.4
cloth_config_version=17.0.144
mod_menu_version=13.0.0-beta.1
smm_lib_version=3.0.0
cloth_config_version=26.1.154
mod_menu_version=18.0.0-alpha.8
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
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.11-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew

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

2 changes: 2 additions & 0 deletions gradlew.bat

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

84 changes: 41 additions & 43 deletions src/main/java/com/mosadie/islandmenu/client/IslandMenuClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
import com.mosadie.islandmenu.mccapi.MCCApi;
import com.mosadie.islandmenu.mccapi.ParticipantsInfo;
import com.mosadie.islandmenu.mccapi.Teams;
import com.mosadie.servermainmenu.client.ServerMainMenuLibClient;
import com.mosadie.simplemainmenu.api.SplashText;
import com.mosadie.simplemainmenu.client.SimpleMainMenuLibClient;
import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.ConfigHolder;
import me.shedaniel.autoconfig.serializer.GsonConfigSerializer;
import net.fabricmc.api.ClientModInitializer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.registry.Registry;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.random.Random;
import net.minecraft.client.Minecraft;
import net.minecraft.core.Registry;
import net.minecraft.resources.Identifier;
import net.minecraft.util.RandomSource;
import net.minecraft.world.InteractionResult;
import org.apache.commons.lang3.RandomUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -62,23 +62,25 @@ public class IslandMenuClient implements ClientModInitializer {
"Support the %s!"
};

public static String getSplashText() {
String splash = splashOptions[Random.create().nextBetweenExclusive(0, splashOptions.length)];
public static SplashText getSplashText() {
String splash = splashOptions[RandomSource.create().nextInt(0, splashOptions.length)];
SplashText.Builder splashTextBuilder = SplashText.builder();

switch(splash) {
case MCC_DATE_SPLASH:
if (mccApi != null) {
EventInfo eventInfo = mccApi.getEventInfo();
if (eventInfo != null) {
if (eventInfo.getData().getDate().after(new Date())) {
String dateString = new SimpleDateFormat("MMMM dd").format(eventInfo.getData().getDate());
return String.format("Watch MCC %s on %s!", eventInfo.getData().getEvent(), dateString);
String dateString = new SimpleDateFormat("MMMM dd 'at' h:mm a z").format(eventInfo.getData().getDate());
splashTextBuilder.addLine(String.format("Watch MCC %s on", eventInfo.getData().getEvent()));
splashTextBuilder.addLine(String.format("%s!", dateString));
} else {
return String.format("What did you think of MCC %s?", eventInfo.getData().getEvent());
splashTextBuilder.addLine(String.format("What did you think of MCC %s?", eventInfo.getData().getEvent()));
}
}
}
return splashOptions[0];
return splashTextBuilder.build();

case MCC_PLAYER_SPLASH:
if (mccApi != null) {
Expand All @@ -87,7 +89,7 @@ public static String getSplashText() {
if (participantsInfo != null) {
ParticipantsInfo.ParticipantsData.Participant player = null;

ParticipantsInfo.ParticipantsData.Participant selfPlayer = participantsInfo.getPlayer(MinecraftClient.getInstance().getSession().getUuidOrNull());
ParticipantsInfo.ParticipantsData.Participant selfPlayer = participantsInfo.getPlayer(Minecraft.getInstance().getGameProfile().id());
if (selfPlayer != null) {
LOGGER.debug("MCC Player found! Picking them always for splash text.");
player = selfPlayer;
Expand All @@ -109,23 +111,30 @@ public static String getSplashText() {
}
}

if (player == null)
return splashOptions[0];
if (player == null) {
splashTextBuilder.addLine(splashOptions[0]);
return splashTextBuilder.build();
}
}

if (player == null || player.getUsername() == null) {
splashTextBuilder.addLine(splashOptions[0]);
return splashTextBuilder.build();
}

if (player == null || player.getUsername() == null)
return splashOptions[0];
splashTextBuilder.addLine(String.format("Check out %s", player.getUsername()));

EventInfo eventInfo = mccApi.getEventInfo();
String eventString = "";
if (eventInfo != null && eventInfo.getData().getDate().after(new Date())) {
eventString = " in MCC " + eventInfo.getData().getEvent();
splashTextBuilder.addLine(String.format("in MCC %s!", eventInfo.getData().getEvent()));
}
return String.format("Check out %s!", player.getUsername() + eventString);

return splashTextBuilder.build();
}
}

return splashOptions[0];
splashTextBuilder.addLine(splashOptions[0]);
return splashTextBuilder.build();

case MCC_TEAM_SPLASH:
Teams team = null;
Expand All @@ -135,8 +144,8 @@ public static String getSplashText() {
}

// If player is in the next/most recent MCC, pick their team.
if ((team == null || team.equals(Teams.NONE)) && mccApi != null && mccApi.getParticipantsInfo() != null && MinecraftClient.getInstance().getSession().getUuidOrNull() != null) {
Teams selfTeam = mccApi.getParticipantsInfo().getPlayerTeam(MinecraftClient.getInstance().getSession().getUuidOrNull());
if ((team == null || team.equals(Teams.NONE)) && mccApi != null && mccApi.getParticipantsInfo() != null && Minecraft.getInstance().getGameProfile().id() != null) {
Teams selfTeam = mccApi.getParticipantsInfo().getPlayerTeam(Minecraft.getInstance().getGameProfile().id());
if (!selfTeam.equals(Teams.NONE)) {
LOGGER.debug("MCC Player team found!");
team = selfTeam;
Expand All @@ -149,36 +158,25 @@ public static String getSplashText() {

String teamString = teamSplashOptions[RandomUtils.nextInt(0, teamSplashOptions.length)];

return String.format(teamString, team.getName());
splashTextBuilder.addLine(String.format(teamString, team.getName()));
return splashTextBuilder.build();

default:
return splash;
return splashTextBuilder.addLine(splash).build();
}
}

private static IslandMenuConfig config;

public static Text getButtonText() {
return Text.translatable("island-menu.menu.join");
}

public static String getButtonServerName() {
return "MCC Island";
}

public static String getButtonServerAddress() {
return "play.mccisland.net";
}

@Override
public void onInitializeClient() {
LOGGER.info("Initializing Island Menu...");

LOGGER.info("Registering Theme...");

Registry.register(ServerMainMenuLibClient.registry, Identifier.of(IslandMenuClient.MOD_ID, "normal"), normalTheme);
Registry.register(ServerMainMenuLibClient.registry, Identifier.of(IslandMenuClient.MOD_ID, "halloween"), halloweenTheme);
Registry.register(ServerMainMenuLibClient.registry, Identifier.of(IslandMenuClient.MOD_ID, "winter"), winterTheme);
Registry.register(SimpleMainMenuLibClient.registry, Identifier.fromNamespaceAndPath(IslandMenuClient.MOD_ID, "normal"), normalTheme);
Registry.register(SimpleMainMenuLibClient.registry, Identifier.fromNamespaceAndPath(IslandMenuClient.MOD_ID, "halloween"), halloweenTheme);
Registry.register(SimpleMainMenuLibClient.registry, Identifier.fromNamespaceAndPath(IslandMenuClient.MOD_ID, "winter"), winterTheme);

LOGGER.info("Configuring Config...");

Expand All @@ -200,14 +198,14 @@ public void onInitializeClient() {
LOGGER.info("Island Menu Initialized!");
}

private static ActionResult onConfigSave(ConfigHolder<IslandMenuConfig> islandMenuConfigConfigHolder, IslandMenuConfig islandMenuConfig) {
private static InteractionResult onConfigSave(ConfigHolder<IslandMenuConfig> islandMenuConfigConfigHolder, IslandMenuConfig islandMenuConfig) {
LOGGER.info("Updating config!");

// config = islandMenuConfig;

if (mccApi == null || !mccApi.getBaseUrl().equalsIgnoreCase(config.devOptions.apiUrl))
mccApi = new MCCApi(config.devOptions.apiUrl);

return ActionResult.PASS;
return InteractionResult.PASS;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.mosadie.islandmenu.client;

import com.mosadie.islandmenu.client.IslandMenuClient;
import com.mosadie.islandmenu.mccapi.Teams;
import me.shedaniel.autoconfig.ConfigData;
import me.shedaniel.autoconfig.annotation.Config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.AutoConfigClient;

public class IslandMenuModMenuIntegration implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return parent -> AutoConfig.getConfigScreen(IslandMenuConfig.class, parent).get();
return parent -> AutoConfigClient.getConfigScreen(IslandMenuConfig.class, parent).get();
}
}
Loading