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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ jobs:

- uses: actions/upload-artifact@v4
with:
name: ServerMainMenu-Lib Jar
name: SimpleMainMenu-Lib Jar
path: build/libs/*.jar
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# ServerMainMenu-Lib
# SimpleMainMenu-Lib

Provides an easy-to-use system for customizing the main menu around a server.
Provides an easy-to-use system for customizing the main menu around a server or other simple menu theme.

To get started using the library, check out the [Getting Started Guide](https://github.com/MoSadie/ServerMainMenu-Lib/wiki/Getting-Started)!
To get started using the library, check out the [Getting Started Guide](https://github.com/MoSadie/SimpleMainMenu-Lib/wiki/Getting-Started)!

## Features:

Expand All @@ -16,7 +16,7 @@ Supports adding one or more panoramas to the main menu. There are pre-made optio

### Quick-join button

One-click button to automatically connect to a specified server.
One-click button to automatically connect to a specified server. (Or world, or whatever you want to code! There's easy pre-made options for most uses!)

### Client Configuration

Expand All @@ -25,4 +25,4 @@ Multiple options on the client side to customize the main menu and override them

## Known Mod Compatibility:
- [Replay Mod](https://replaymod.com/)'s button appears correctly.
- If you encounter an issue or have any suggestions, [please let me know](https://github.com/MoSadie/ServerMainMenu-Lib/issues)!
- If you encounter an issue or have any suggestions, [please let me know](https://github.com/MoSadie/SimpleMainMenu-Lib/issues)!
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@ java {
if (System.getenv("CI") == null) {
withSourcesJar()
}
//withJavadocJar()
}

jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}" }
rename { "${it}_${project.archiveBaseName}" }
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fabric_api_version=0.141.2+1.21.11
# Mod Properties
mod_version=2.1.0
maven_group=com.mosadie
archivesBaseName=servermainmenu-lib
archiveBaseName=simplemainmenu-lib

# Dependency Versions (easy to check on https://linkie.shedaniel.dev/dependencies)
cloth_config_version=21.11.153
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// 1.21.11 -999999999-01-01T00:00:00 SimpleMainMenu Lib/Language (en_us)
4fa352432b2444e1b823fef66df46fe8b1994bf1 assets/smm-lib/lang/en_us.json

This file was deleted.

10 changes: 5 additions & 5 deletions src/main/generated/assets/smm-lib/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"text.autoconfig.smm-lib.option.quickJoinButtonOptions": "Quick Join Button Settings",
"text.autoconfig.smm-lib.option.quickJoinButtonOptions.buttonDestinationOverride": "Quick Join Button Server Address / World Folder",
"text.autoconfig.smm-lib.option.quickJoinButtonOptions.buttonNameOverride": "Quick Join Button Server Name",
"text.autoconfig.smm-lib.option.quickJoinButtonOptions.buttonDestinationOverride": "Server Address / World Folder",
"text.autoconfig.smm-lib.option.quickJoinButtonOptions.buttonNameOverride": "Button Server Name",
"text.autoconfig.smm-lib.option.quickJoinButtonOptions.buttonNameOverride.@Tooltip": "Mainly used by mods such as ReplayMod to track what server you were on. Unused in World mode.",
"text.autoconfig.smm-lib.option.quickJoinButtonOptions.buttonTextOverride": "Quick Join Button Text",
"text.autoconfig.smm-lib.option.quickJoinButtonOptions.buttonType": "Quick Join Button Destination Type",
"text.autoconfig.smm-lib.option.quickJoinButtonOptions.buttonTextOverride": "Button Text",
"text.autoconfig.smm-lib.option.quickJoinButtonOptions.buttonType": "Destination Type",
"text.autoconfig.smm-lib.option.quickJoinButtonOptions.overrideQuickJoinButton": "Override Quick Join Button?",
"text.autoconfig.smm-lib.option.splashOptions": "Splash Message Settings",
"text.autoconfig.smm-lib.option.splashOptions.overrideSplash": "Override Splash Text?",
Expand All @@ -19,7 +19,7 @@
"text.autoconfig.smm-lib.option.visibilityOptions.multiplayer": "Show Multiplayer Button",
"text.autoconfig.smm-lib.option.visibilityOptions.quickJoin": "Show Quick Join Button",
"text.autoconfig.smm-lib.option.visibilityOptions.singleplayer": "Show Singleplayer Button",
"text.autoconfig.smm-lib.title": "ServerMainMenu Lib Settings",
"text.autoconfig.smm-lib.title": "SimpleMainMenu Lib Settings",
"text.smm-lib.error.worldnotfound.body": "World %s not found! Make sure it has been created first.",
"text.smm-lib.error.worldnotfound.title": "World not found!",
"text.smmlib.normaltheme.joinserver": "Join the server!"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
package com.mosadie.servermainmenu.api;
package com.mosadie.simplemainmenu.api;

import net.minecraft.client.network.ServerInfo;
import net.minecraft.resource.Resource;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

public interface MenuTheme {
String getId();
Identifier getPanorama();
@Deprecated
default String getSplashText() {
return null;
}
Text getSplashAsText();

boolean rollOdds();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.mosadie.servermainmenu.api;
package com.mosadie.simplemainmenu.api;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ServerInfo;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

Expand All @@ -21,7 +19,7 @@ public Identifier getPanorama() {

@Override
public Text getSplashAsText() {
return Text.literal("Just a normal menu...");
return Text.literal("Just a normal menu...").setStyle(Util.SPLASH_TEXT_STYLE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.mosadie.servermainmenu.api;
package com.mosadie.simplemainmenu.api;

import com.mosadie.servermainmenu.client.ServerMainMenuLibClient;
import com.mosadie.simplemainmenu.client.SimpleMainMenuLibClient;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.MessageScreen;
import net.minecraft.client.gui.screen.NoticeScreen;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.gui.screen.multiplayer.ConnectScreen;
Expand Down Expand Up @@ -100,7 +99,7 @@ public static void joinServer(ServerInfo server) {
MinecraftClient.getInstance().send(() -> {
leaveIfNeeded();

ServerMainMenuLibClient.LOGGER.info("Connecting to " + server.address);
SimpleMainMenuLibClient.LOGGER.info("Connecting to " + server.address);

// Connect to server

Expand All @@ -113,13 +112,13 @@ public static void loadWorld(String worldName) {
if (MinecraftClient.getInstance().getLevelStorage().levelExists(worldName)) {
leaveIfNeeded();

ServerMainMenuLibClient.LOGGER.info("Loading world...");
SimpleMainMenuLibClient.LOGGER.info("Loading world...");
MinecraftClient.getInstance().createIntegratedServerLoader().start(worldName, () -> {
ServerMainMenuLibClient.LOGGER.info("World load cancelled.");
SimpleMainMenuLibClient.LOGGER.info("World load cancelled.");
MinecraftClient.getInstance().setScreen(new TitleScreen());
});
} else {
ServerMainMenuLibClient.LOGGER.warn("World " + worldName + " does not exist!");
SimpleMainMenuLibClient.LOGGER.warn("World " + worldName + " does not exist!");
if (MinecraftClient.getInstance().world == null)
MinecraftClient.getInstance().setScreen(new NoticeScreen(() -> MinecraftClient.getInstance().setScreen(new TitleScreen()), Text.translatable("text.smm-lib.error.worldnotfound.title"), Text.translatable("text.smm-lib.error.worldnotfound.body", worldName), ScreenTexts.TO_TITLE, true));
}
Expand All @@ -131,7 +130,7 @@ public static void loadWorld(String worldName) {
*/
private static void leaveIfNeeded() {
if (MinecraftClient.getInstance().world != null) {
ServerMainMenuLibClient.LOGGER.info("Disconnecting from world...");
SimpleMainMenuLibClient.LOGGER.info("Disconnecting from world...");

MinecraftClient.getInstance().world.disconnect(Text.translatable("menu.disconnect"));
MinecraftClient.getInstance().disconnectWithProgressScreen();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.mosadie.servermainmenu.client;
package com.mosadie.simplemainmenu.client;

import com.mosadie.servermainmenu.api.MenuTheme;
import com.mosadie.servermainmenu.api.NormalTheme;
import com.mosadie.servermainmenu.api.Util;
import com.mosadie.simplemainmenu.api.MenuTheme;
import com.mosadie.simplemainmenu.api.NormalTheme;
import com.mosadie.simplemainmenu.api.Util;
import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.ConfigHolder;
import me.shedaniel.autoconfig.serializer.GsonConfigSerializer;
Expand All @@ -17,7 +17,7 @@
import org.slf4j.LoggerFactory;

@net.fabricmc.api.Environment(net.fabricmc.api.EnvType.CLIENT)
public class ServerMainMenuLibClient implements ClientModInitializer {
public class SimpleMainMenuLibClient implements ClientModInitializer {

public static final String MOD_ID = "smm-lib";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
Expand Down Expand Up @@ -76,16 +76,14 @@ public static MenuTheme getTheme() {
return menuTheme;
}

private static ServerMainMenuLibConfig config;
private static SimpleMainMenuLibConfig config;

@SuppressWarnings("deprecation")
public static Text getSplashText() {
if (config != null && config.splashOptions.overrideSplash) {
return Text.of(config.splashOptions.overrideSplashText);
}

// Should still work with old mods that don't implement the asText method I hope...
if (getTheme().getSplashText() != null) return Text.literal(getTheme().getSplashText()).setStyle(Util.SPLASH_TEXT_STYLE);

return getTheme().getSplashAsText();
}

Expand All @@ -110,32 +108,32 @@ public static void onQuickJoinClick() {
}

public static boolean isSingleplayerVisible() {
if (config != null && config.visibilityOptions.singleplayer != ServerMainMenuLibConfig.VisibilityOptions.VisibilityState.DEFAULT) {
return config.visibilityOptions.singleplayer == ServerMainMenuLibConfig.VisibilityOptions.VisibilityState.SHOW;
if (config != null && config.visibilityOptions.singleplayer != SimpleMainMenuLibConfig.VisibilityOptions.VisibilityState.DEFAULT) {
return config.visibilityOptions.singleplayer == SimpleMainMenuLibConfig.VisibilityOptions.VisibilityState.SHOW;
}

return getTheme().isSingleplayerVisible();
}

public static boolean isMultiplayerVisible() {
if (config != null && config.visibilityOptions.multiplayer != ServerMainMenuLibConfig.VisibilityOptions.VisibilityState.DEFAULT) {
return config.visibilityOptions.multiplayer == ServerMainMenuLibConfig.VisibilityOptions.VisibilityState.SHOW;
if (config != null && config.visibilityOptions.multiplayer != SimpleMainMenuLibConfig.VisibilityOptions.VisibilityState.DEFAULT) {
return config.visibilityOptions.multiplayer == SimpleMainMenuLibConfig.VisibilityOptions.VisibilityState.SHOW;
}

return getTheme().isMultiplayerVisible();
}

public static boolean isModsVisible() {
if (config != null && config.visibilityOptions.mods != ServerMainMenuLibConfig.VisibilityOptions.VisibilityState.DEFAULT) {
return config.visibilityOptions.mods == ServerMainMenuLibConfig.VisibilityOptions.VisibilityState.SHOW;
if (config != null && config.visibilityOptions.mods != SimpleMainMenuLibConfig.VisibilityOptions.VisibilityState.DEFAULT) {
return config.visibilityOptions.mods == SimpleMainMenuLibConfig.VisibilityOptions.VisibilityState.SHOW;
}

return getTheme().isModsVisible();
}

public static boolean isQuickJoinVisible() {
if (config != null && config.visibilityOptions.quickJoin != ServerMainMenuLibConfig.VisibilityOptions.VisibilityState.DEFAULT) {
return config.visibilityOptions.quickJoin == ServerMainMenuLibConfig.VisibilityOptions.VisibilityState.SHOW;
if (config != null && config.visibilityOptions.quickJoin != SimpleMainMenuLibConfig.VisibilityOptions.VisibilityState.DEFAULT) {
return config.visibilityOptions.quickJoin == SimpleMainMenuLibConfig.VisibilityOptions.VisibilityState.SHOW;
}

return getTheme().isQuickJoinVisible();
Expand All @@ -147,19 +145,19 @@ public void onInitializeClient() {

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

AutoConfig.register(ServerMainMenuLibConfig.class, GsonConfigSerializer::new);
AutoConfig.register(SimpleMainMenuLibConfig.class, GsonConfigSerializer::new);

AutoConfig.getConfigHolder(ServerMainMenuLibConfig.class).registerSaveListener(ServerMainMenuLibClient::onConfigSave);
AutoConfig.getConfigHolder(SimpleMainMenuLibConfig.class).registerSaveListener(SimpleMainMenuLibClient::onConfigSave);

config = AutoConfig.getConfigHolder(ServerMainMenuLibConfig.class).getConfig();
config = AutoConfig.getConfigHolder(SimpleMainMenuLibConfig.class).getConfig();

LOGGER.info("SimpleServerMenu-Lib Initialized!");
}

private static ActionResult onConfigSave(ConfigHolder<ServerMainMenuLibConfig> islandMenuConfigConfigHolder, ServerMainMenuLibConfig serverMainMenuLibConfig) {
private static ActionResult onConfigSave(ConfigHolder<SimpleMainMenuLibConfig> simpleMainMenuLibConfigConfigHolder, SimpleMainMenuLibConfig simpleMainMenuLibConfig) {
LOGGER.info("Updating config!");

config = serverMainMenuLibConfig;
config = simpleMainMenuLibConfig;

menuTheme = selectTheme();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.mosadie.servermainmenu.client;
package com.mosadie.simplemainmenu.client;

import me.shedaniel.autoconfig.ConfigData;
import me.shedaniel.autoconfig.annotation.Config;
import me.shedaniel.autoconfig.annotation.ConfigEntry;

@Config(name = ServerMainMenuLibClient.MOD_ID)
public class ServerMainMenuLibConfig implements ConfigData {
@Config(name = SimpleMainMenuLibClient.MOD_ID)
public class SimpleMainMenuLibConfig implements ConfigData {

@ConfigEntry.Gui.CollapsibleObject
QuickJoinButtonOptions quickJoinButtonOptions = new QuickJoinButtonOptions();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.mosadie.servermainmenu.client;
package com.mosadie.simplemainmenu.client;

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

public class ServerMainMenuLibModMenuIntegration implements ModMenuApi {
public class SimpleMainMenuLibModMenuIntegration implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return parent -> AutoConfigClient.getConfigScreen(ServerMainMenuLibConfig.class, parent).get();
return parent -> AutoConfigClient.getConfigScreen(SimpleMainMenuLibConfig.class, parent).get();
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.mosadie.servermainmenu.client.data;
package com.mosadie.simplemainmenu.client.data;

import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;

public class ServerMainMenuLibDataGen implements DataGeneratorEntrypoint {
public class SimpleMainMenuLibDataGen implements DataGeneratorEntrypoint {
@Override
public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
FabricDataGenerator.Pack pack = fabricDataGenerator.createPack();
pack.addProvider(ServerMainMenuLibEnLangProvider::new);
pack.addProvider(SimpleMainMenuLibEnLangProvider::new);
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package com.mosadie.servermainmenu.client.data;
package com.mosadie.simplemainmenu.client.data;

import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricLanguageProvider;
import net.minecraft.registry.RegistryWrapper;

import java.util.concurrent.CompletableFuture;

public class ServerMainMenuLibEnLangProvider extends FabricLanguageProvider {
protected ServerMainMenuLibEnLangProvider(FabricDataOutput dataOutput, CompletableFuture<RegistryWrapper.WrapperLookup> registryLookup) {
public class SimpleMainMenuLibEnLangProvider extends FabricLanguageProvider {
protected SimpleMainMenuLibEnLangProvider(FabricDataOutput dataOutput, CompletableFuture<RegistryWrapper.WrapperLookup> registryLookup) {
super(dataOutput, "en_us", registryLookup);
}

@Override
public void generateTranslations(RegistryWrapper.WrapperLookup wrapperLookup, TranslationBuilder translationBuilder) {
translationBuilder.add("text.smmlib.normaltheme.joinserver", "Join the server!");

translationBuilder.add("text.autoconfig.smm-lib.title", "ServerMainMenu Lib Settings");
translationBuilder.add("text.autoconfig.smm-lib.title", "SimpleMainMenu Lib Settings");

translationBuilder.add("text.autoconfig.smm-lib.option.quickJoinButtonOptions", "Quick Join Button Settings");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.mosadie.servermainmenu.mixin;
package com.mosadie.simplemainmenu.mixin;

import com.mosadie.servermainmenu.client.ServerMainMenuLibClient;
import com.mosadie.simplemainmenu.client.SimpleMainMenuLibClient;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
Expand All @@ -17,7 +17,7 @@ public class IdentifierMixin {
public static Identifier ofVanilla(String path) {
// If we are getting the background panorama texture, we want to return the custom panorama texture from the selected theme instead.
if (path != null && path.equals("textures/gui/title/background/panorama")) {
return ServerMainMenuLibClient.getTheme().getPanorama();
return SimpleMainMenuLibClient.getTheme().getPanorama();
}

return Identifier.of("minecraft", path);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mosadie.servermainmenu.mixin;
package com.mosadie.simplemainmenu.mixin;

import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.text.Text;
Expand Down
Loading