Skip to content

Commit

Permalink
Fix aurora config registration (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ogg-Vorbis authored Dec 11, 2024
1 parent 3556301 commit 8d3ed55
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 46 deletions.
4 changes: 2 additions & 2 deletions src/main/java/serverutils/ServerUtilitiesCommon.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public void preInit(FMLPreInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(ServerUtilitiesUniverseData.INST);
MinecraftForge.EVENT_BUS.register(ServerUtilitiesPermissions.INST);
FMLCommonHandler.instance().bus().register(ServerUtilitiesServerEventHandler.INST);
if (AuroraConfig.enable) {
if (AuroraConfig.general.enable) {
MinecraftForge.EVENT_BUS.register(AuroraMinecraftHandler.INST);
FMLCommonHandler.instance().bus().register(AuroraMinecraftHandler.INST);
}
Expand Down Expand Up @@ -259,7 +259,7 @@ public void onServerAboutToStart(FMLServerAboutToStartEvent event) {
public void onServerStarting(FMLServerStartingEvent event) {
ServerUtilitiesCommands.registerCommands(event);

if (AuroraConfig.enable) {
if (AuroraConfig.general.enable) {
Aurora.start(event.getServer());
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/serverutils/aurora/Aurora.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ public class Aurora {
private static AuroraServer server;

public static void start(MinecraftServer s) {
if (AuroraConfig.enable) {
if (AuroraConfig.general.enable) {
if (server == null) {
server = new AuroraServer(s, AuroraConfig.port);
server = new AuroraServer(s, AuroraConfig.general.port);
server.start();
}
}
}

public static void stop() {
if (AuroraConfig.enable) {
if (AuroraConfig.general.enable) {
if (server != null) {
server.shutdown();
server = null;
Expand Down
74 changes: 43 additions & 31 deletions src/main/java/serverutils/aurora/AuroraConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,58 @@

import com.gtnewhorizon.gtnhlib.config.Config;

@Config(modid = "serverutilities", filename = "aurora", configSubDirectory = "../serverutilities/")
import serverutils.ServerUtilities;

@Config(modid = ServerUtilities.MOD_ID, category = "", filename = "aurora", configSubDirectory = "../serverutilities/")
public class AuroraConfig {

@Config.Comment("Enable the localhost server")
@Config.DefaultBoolean(false)
public static boolean enable;
public static final General general = new General();
public static final Pages pages = new Pages();

public static class General {

@Config.Comment("Enable the localhost server")
@Config.DefaultBoolean(false)
public boolean enable;

@Config.Comment("Webserver Port ID")
@Config.DefaultInt(48574)
@Config.RangeInt(min = 1024, max = 65535)
public int port;
}

@Config.Comment("Enable the modlist page")
@Config.DefaultEnum("ENABLED")
public static PageType modlist_page;
public static class Pages {

@Config.Comment("Enable the modlist page")
@Config.DefaultEnum("ENABLED")
public static PageType world_info_json;
@Config.Comment("Enable the modlist page")
@Config.DefaultEnum("ENABLED")
public PageType modlist_page;

@Config.Comment("Enable the world info page")
@Config.DefaultEnum("ENABLED")
public static PageType player_list_table;
@Config.Comment("Enable the modlist page")
@Config.DefaultEnum("ENABLED")
public PageType world_info_json;

@Config.Comment("Enable the playerlist table page")
@Config.DefaultEnum("ENABLED")
public static PageType player_list_json;
@Config.Comment("Enable the world info page")
@Config.DefaultEnum("ENABLED")
public PageType player_list_table;

@Config.Comment("Enable the playerlist json page")
@Config.DefaultEnum("REQUIRES_AUTH")
public static PageType player_rank_page;
@Config.Comment("Enable the playerlist table page")
@Config.DefaultEnum("ENABLED")
public PageType player_list_json;

@Config.Comment("Enable the player rank page from Server Utilities")
@Config.DefaultEnum("ENABLED")
public static PageType command_list_page;
@Config.Comment("Enable the playerlist json page")
@Config.DefaultEnum("REQUIRES_AUTH")
public PageType player_rank_page;

@Config.Comment("Enable the command list page from Server Utilities")
@Config.DefaultEnum("ENABLED")
public static PageType permission_list_page;
@Config.Comment("Enable the player rank page from Server Utilities")
@Config.DefaultEnum("ENABLED")
public PageType command_list_page;

@Config.Comment("Exclude mods from the modlist")
@Config.DefaultStringList({})
public static String[] modlist_excluded_mods;
@Config.Comment("Enable the command list page from Server Utilities")
@Config.DefaultEnum("ENABLED")
public PageType permission_list_page;

@Config.Comment("Webserver Port ID")
@Config.DefaultInt(48574)
public static int port;
@Config.Comment("Exclude mods from the modlist")
@Config.DefaultStringList({})
public String[] modlist_excluded_mods;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void onHomeEvent(AuroraHomePageEvent event) {
public void onPageEvent(AuroraPageEvent event) {

if (event.checkPath("modlist", "*")) {
HashSet<String> set = new HashSet<>(Arrays.asList(AuroraConfig.modlist_excluded_mods));
HashSet<String> set = new HashSet<>(Arrays.asList(AuroraConfig.pages.modlist_excluded_mods));

if (!set.contains(event.getSplitUri()[1])) {
ModContainer modContainer = Loader.instance().getIndexedModList().get(event.getSplitUri()[1]);
Expand All @@ -56,7 +56,7 @@ public void onPageEvent(AuroraPageEvent event) {
}
}
} else if (event.checkPath("modlist")) {
event.returnPage(new ModListPage(new HashSet<>(Arrays.asList(AuroraConfig.modlist_excluded_mods))));
event.returnPage(new ModListPage(new HashSet<>(Arrays.asList(AuroraConfig.pages.modlist_excluded_mods))));
} else if (event.checkPath("minecraft", "online_players")) {
event.returnPage(new PlayerListTable(event.getAuroraServer().getServer()));
} else if (event.checkPath("minecraft", "online_players.json")) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/serverutils/aurora/mc/CommandListPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public String getIcon() {

@Override
public PageType getPageType() {
return AuroraConfig.command_list_page;
return AuroraConfig.pages.command_list_page;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/serverutils/aurora/mc/ModListPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public String getDescription() {

@Override
public PageType getPageType() {
return AuroraConfig.modlist_page;
return AuroraConfig.pages.modlist_page;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/serverutils/aurora/mc/ModPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public String getDescription() {

@Override
public PageType getPageType() {
return AuroraConfig.modlist_page;
return AuroraConfig.pages.modlist_page;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public String getIcon() {

@Override
public PageType getPageType() {
return AuroraConfig.permission_list_page;
return AuroraConfig.pages.permission_list_page;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/serverutils/aurora/mc/PlayerListJson.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public PlayerListJson(MinecraftServer s) {

@Override
public PageType getPageType() {
return AuroraConfig.player_list_json;
return AuroraConfig.pages.player_list_json;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/serverutils/aurora/mc/PlayerListTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public String getDescription() {

@Override
public PageType getPageType() {
return AuroraConfig.player_list_table;
return AuroraConfig.pages.player_list_table;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/serverutils/aurora/mc/RankPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public String getIcon() {

@Override
public PageType getPageType() {
return AuroraConfig.player_rank_page;
return AuroraConfig.pages.player_rank_page;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/serverutils/aurora/mc/WorldInfoJson.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public WorldInfoJson(MinecraftServer s) {

@Override
public PageType getPageType() {
return AuroraConfig.world_info_json;
return AuroraConfig.pages.world_info_json;
}

@Override
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/serverutils/core/ServerUtilitiesCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@

import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
import serverutils.ServerUtilitiesConfig;
import serverutils.aurora.AuroraConfig;
import serverutils.mixin.Mixins;

public class ServerUtilitiesCore implements IFMLLoadingPlugin, IEarlyMixinLoader {

static {
try {
ConfigurationManager.registerConfig(ServerUtilitiesConfig.class);
ConfigurationManager.registerConfig(AuroraConfig.class);
} catch (ConfigException e) {
throw new RuntimeException(e);
}
Expand Down

0 comments on commit 8d3ed55

Please sign in to comment.