Add Multiplayer config API

This commit is contained in:
James Seibel
2022-07-02 21:52:09 -05:00
parent d92b1f1032
commit 6386cc5d88
5 changed files with 127 additions and 14 deletions
@@ -0,0 +1,72 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2022 Tom Lee (TomTheFurry)
* Copyright (C) 2020-2022 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.lod.core.api.external.apiObjects.enums;
/**
* AUTO, <br>
* NAME_ONLY, <br>
* NAME_IP, <br>
* NAME_IP_PORT, <br> <br>
*
* Determines how the multiplayer folders should be named.
*
* @author James Seibel
* @version 2022-7-1
*/
public enum EDhApiServerFolderNameMode
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
/**
* NAME_IP for LAN connections <Br>
* NAME_IP_PORT for all others
*/
AUTO,
/** Only use the server name */
NAME_ONLY,
/**
* {SERVER_NAME} IP {IP} <br>
* Example: Minecraft Server IP 192.168.1.40
*/
NAME_IP,
/**
* {SERVER_NAME} IP {IP}:{PORT} <br>
* Example: Minecraft Server IP 192.168.1.40:25565
*/
NAME_IP_PORT,
/**
* {SERVER_NAME} IP {IP} <br>
* Example: Minecraft Server IP 192.168.1.40:25565 GameVersion 1.16.5 <Br> <br>
*
* Not normally recommended, since the game version can change if the
* server installs paper or some other jar. <br>
* This is just here to provide backwards compatibility.
*/
NAME_IP_PORT_MC_VERSION;
}
@@ -0,0 +1,36 @@
package com.seibel.lod.core.api.external.config.client;
import com.seibel.lod.core.api.external.apiObjects.enums.EDhApiDistanceGenerationMode;
import com.seibel.lod.core.api.external.apiObjects.enums.EDhApiServerFolderNameMode;
import com.seibel.lod.core.api.external.apiObjects.wrapperInterfaces.IDhApiConfig;
import com.seibel.lod.core.api.implementation.objects.GenericEnumConverter;
import com.seibel.lod.core.api.implementation.wrappers.DhApiConfig;
import com.seibel.lod.core.config.Config.Client.Multiplayer;
import com.seibel.lod.core.enums.config.EServerFolderNameMode;
/**
* Multiplayer settings.
*
* @author James Seibel
* @version 2022-7-2
*/
public class DhApiMultiplayer
{
/**
* Returns the config related to how Distant Horizons
* names multiplayer server folders.
*/
public static IDhApiConfig<EDhApiServerFolderNameMode> getFolderSavingModeConfig()
{ return new DhApiConfig<>(Multiplayer.serverFolderNameMode, new GenericEnumConverter<>(EServerFolderNameMode.class, EDhApiServerFolderNameMode.class)); }
/**
* Returns the config related to how Distant Horizons' determines
* what level a specific dimension belongs too. <br>
* This is specifically to support serverside mods like Multiverse.
*/
public static IDhApiConfig<EDhApiDistanceGenerationMode> getDistantGeneratorModeConfig()
{ return new DhApiConfig<>(Multiplayer.multiDimensionRequiredSimilarity); }
}
@@ -630,7 +630,8 @@ public class Config
+ " " + EServerFolderNameMode.AUTO + ": " + EServerFolderNameMode.NAME_IP + " for LAN connections, " + EServerFolderNameMode.NAME_IP_PORT + " for all others. \n"
+ " " + EServerFolderNameMode.NAME_ONLY + ": Example: \"Minecraft Server\" \n"
+ " " + EServerFolderNameMode.NAME_IP + ": Example: \"Minecraft Server IP 192.168.1.40\" \n"
+ " " + EServerFolderNameMode.NAME_IP_PORT + ": Example: \"Minecraft Server IP 192.168.1.40:25565\"")
+ " " + EServerFolderNameMode.NAME_IP_PORT + ": Example: \"Minecraft Server IP 192.168.1.40:25565\""
+ " " + EServerFolderNameMode.NAME_IP_PORT_MC_VERSION + ": Example: \"Minecraft Server IP 192.168.1.40:25565 GameVersion 1.16.5\"")
.build();
public static ConfigEntry<Double> multiDimensionRequiredSimilarity = new ConfigEntry.Builder<Double>()
@@ -21,18 +21,23 @@
package com.seibel.lod.core.enums.config;
/**
* AUTO <br>
* NAME_ONLY <br>
* NAME_IP <br>
* NAME_IP_PORT <br>
* <br>
* AUTO, <br>
* NAME_ONLY, <br>
* NAME_IP, <br>
* NAME_IP_PORT, <br> <br>
*
* Determines how the multiplayer folders should be named.
*
* @author James Seibel
* @version 3-7-2022
* @version 2022-7-1
*/
public enum EServerFolderNameMode
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
/**
* NAME_IP for LAN connections <Br>
* NAME_IP_PORT for all others
@@ -44,25 +49,23 @@ public enum EServerFolderNameMode
/**
* {SERVER_NAME} IP {IP} <br>
* Minecraft Server IP 192.168.1.40
* Example: Minecraft Server IP 192.168.1.40
*/
NAME_IP,
/**
* {SERVER_NAME} IP {IP} <br>
* Minecraft Server IP 192.168.1.40:25565
/**
* {SERVER_NAME} IP {IP}:{PORT} <br>
* Example: Minecraft Server IP 192.168.1.40:25565
*/
NAME_IP_PORT,
/**
* {SERVER_NAME} IP {IP} <br>
* Minecraft Server IP 192.168.1.40:25565 GameVersion 1.16.5 <Br> <br>
* Example: Minecraft Server IP 192.168.1.40:25565 GameVersion 1.16.5 <Br> <br>
*
* Not normally recommended, since the game version can change if the
* server installs paper or some other jar. <br>
* This is just here to provide backwards compatibility.
*
* TODO add this to config desc
*/
NAME_IP_PORT_MC_VERSION;
@@ -32,6 +32,7 @@ public enum ERendererType
// when adding items up the API minor version
// when removing items up the API major version
DEFAULT,
DEBUG,
DISABLED;