work in progress
This commit is contained in:
parent
81a4370297
commit
8843ee8a53
9 changed files with 106 additions and 81 deletions
|
|
@ -14,6 +14,10 @@ repositories {
|
||||||
includeGroup "maven.modrinth"
|
includeGroup "maven.modrinth"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maven {
|
||||||
|
url "https://maven.enjarai.nl/releases"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
@ -27,4 +31,5 @@ dependencies {
|
||||||
modImplementation "maven.modrinth:sodium-extra:mc1.21-0.5.7" // Sodium Extra
|
modImplementation "maven.modrinth:sodium-extra:mc1.21-0.5.7" // Sodium Extra
|
||||||
modImplementation "maven.modrinth:embeddium:1.0.2+mc1.21" // Embeddium
|
modImplementation "maven.modrinth:embeddium:1.0.2+mc1.21" // Embeddium
|
||||||
modImplementation "maven.modrinth:distanthorizons:2.1.2-a-1.21" // Distant Horizons
|
modImplementation "maven.modrinth:distanthorizons:2.1.2-a-1.21" // Distant Horizons
|
||||||
|
modImplementation "nl.enjarai:shared-resources-api:1.8.3" // Shared Resources
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,51 +1,14 @@
|
||||||
package com.axolotlmaid.optionsprofiles;
|
package com.axolotlmaid.optionsprofiles;
|
||||||
|
|
||||||
import com.axolotlmaid.optionsprofiles.gui.ProfilesList;
|
|
||||||
import com.axolotlmaid.optionsprofiles.profiles.ProfileConfiguration;
|
|
||||||
import com.axolotlmaid.optionsprofiles.profiles.Profiles;
|
import com.axolotlmaid.optionsprofiles.profiles.Profiles;
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.DirectoryStream;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class OptionsProfilesMod {
|
public class OptionsProfilesMod {
|
||||||
public static final String MOD_ID = "optionsprofiles";
|
public static final String MOD_ID = "optionsprofiles";
|
||||||
public static final Logger LOGGER = LogManager.getLogger("Options Profiles");
|
public static final Logger LOGGER = LogManager.getLogger("Options Profiles");
|
||||||
|
|
||||||
public static void init() {
|
public static final Profiles PROFILES_INSTANCE = new Profiles();
|
||||||
Path profilesDirectory = Paths.get("options-profiles");
|
|
||||||
|
|
||||||
if (Files.notExists(profilesDirectory)) {
|
public static void init() {}
|
||||||
try {
|
|
||||||
Files.createDirectory(profilesDirectory);
|
|
||||||
} catch (IOException e) {
|
|
||||||
LOGGER.error("An error occurred when creating the 'options-profiles' directory.", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add configuration for existing profiles that were made before v1.3
|
|
||||||
Profiles.updateProfiles();
|
|
||||||
|
|
||||||
// Loading profiles on startup
|
|
||||||
try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(Profiles.PROFILES_DIRECTORY)) {
|
|
||||||
for (Path profile : directoryStream) {
|
|
||||||
String profileName = profile.getFileName().toString();
|
|
||||||
ProfileConfiguration profileConfiguration = ProfileConfiguration.get(profileName);
|
|
||||||
|
|
||||||
if (profileConfiguration.isLoadOnStartup()) {
|
|
||||||
Profiles.loadProfile(profileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
OptionsProfilesMod.LOGGER.error("An error occurred when loading startup profiles", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.axolotlmaid.optionsprofiles.gui;
|
package com.axolotlmaid.optionsprofiles.gui;
|
||||||
|
|
||||||
|
import com.axolotlmaid.optionsprofiles.OptionsProfilesMod;
|
||||||
import com.axolotlmaid.optionsprofiles.profiles.ProfileConfiguration;
|
import com.axolotlmaid.optionsprofiles.profiles.ProfileConfiguration;
|
||||||
import com.axolotlmaid.optionsprofiles.profiles.Profiles;
|
import com.axolotlmaid.optionsprofiles.profiles.Profiles;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
|
|
@ -47,7 +48,7 @@ public class EditProfileScreen extends Screen {
|
||||||
Button.builder(
|
Button.builder(
|
||||||
Component.translatable("gui.optionsprofiles.overwrite-options"),
|
Component.translatable("gui.optionsprofiles.overwrite-options"),
|
||||||
(button) -> {
|
(button) -> {
|
||||||
Profiles.writeProfile(profileName.getString(), true);
|
OptionsProfilesMod.PROFILES_INSTANCE.writeProfile(profileName.getString(), true);
|
||||||
this.onClose();
|
this.onClose();
|
||||||
})
|
})
|
||||||
.size(150, 20)
|
.size(150, 20)
|
||||||
|
|
@ -59,7 +60,7 @@ public class EditProfileScreen extends Screen {
|
||||||
Button.builder(
|
Button.builder(
|
||||||
Component.translatable("gui.optionsprofiles.rename-profile"),
|
Component.translatable("gui.optionsprofiles.rename-profile"),
|
||||||
(button) -> {
|
(button) -> {
|
||||||
Profiles.renameProfile(profileName.getString(), this.profileNameEdit.getValue());
|
OptionsProfilesMod.PROFILES_INSTANCE.renameProfile(profileName.getString(), this.profileNameEdit.getValue());
|
||||||
this.minecraft.setScreen(new EditProfileScreen(profilesScreen, Component.literal(this.profileNameEdit.getValue())));
|
this.minecraft.setScreen(new EditProfileScreen(profilesScreen, Component.literal(this.profileNameEdit.getValue())));
|
||||||
})
|
})
|
||||||
.size(150, 20)
|
.size(150, 20)
|
||||||
|
|
@ -98,7 +99,7 @@ public class EditProfileScreen extends Screen {
|
||||||
Component.translatable("gui.optionsprofiles.delete-profile")
|
Component.translatable("gui.optionsprofiles.delete-profile")
|
||||||
.withStyle(ChatFormatting.RED),
|
.withStyle(ChatFormatting.RED),
|
||||||
(button) -> {
|
(button) -> {
|
||||||
Profiles.deleteProfile(profileName.getString());
|
OptionsProfilesMod.PROFILES_INSTANCE.deleteProfile(profileName.getString());
|
||||||
this.onClose();
|
this.onClose();
|
||||||
})
|
})
|
||||||
.width(50)
|
.width(50)
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ public class ProfilesList extends ContainerObjectSelectionList<ProfilesList.Prof
|
||||||
this.loadButton = Button.builder(
|
this.loadButton = Button.builder(
|
||||||
Component.translatable("gui.optionsprofiles.load-profile"),
|
Component.translatable("gui.optionsprofiles.load-profile"),
|
||||||
(button) -> {
|
(button) -> {
|
||||||
Profiles.loadProfile(profileName.getString());
|
OptionsProfilesMod.PROFILES_INSTANCE.loadProfile(profileName.getString());
|
||||||
|
|
||||||
minecraft.options.load();
|
minecraft.options.load();
|
||||||
|
|
||||||
|
|
@ -124,7 +124,7 @@ public class ProfilesList extends ContainerObjectSelectionList<ProfilesList.Prof
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkLoaded() {
|
protected void checkLoaded() {
|
||||||
this.loadButton.active = !Profiles.isProfileLoaded(profileName.getString());
|
this.loadButton.active = !OptionsProfilesMod.PROFILES_INSTANCE.isProfileLoaded(profileName.getString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.axolotlmaid.optionsprofiles.gui;
|
package com.axolotlmaid.optionsprofiles.gui;
|
||||||
|
|
||||||
|
import com.axolotlmaid.optionsprofiles.OptionsProfilesMod;
|
||||||
import com.axolotlmaid.optionsprofiles.profiles.Profiles;
|
import com.axolotlmaid.optionsprofiles.profiles.Profiles;
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.client.gui.layouts.LinearLayout;
|
import net.minecraft.client.gui.layouts.LinearLayout;
|
||||||
|
|
@ -10,7 +11,7 @@ import net.minecraft.network.chat.CommonComponents;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
|
||||||
public class ProfilesScreen extends OptionsSubScreen {
|
public class ProfilesScreen extends OptionsSubScreen {
|
||||||
private Screen optionsLastScreen;
|
private final Screen optionsLastScreen;
|
||||||
public ProfilesList profilesList;
|
public ProfilesList profilesList;
|
||||||
|
|
||||||
public ProfilesScreen(Screen lastScreen, Screen optionsLastScreen) {
|
public ProfilesScreen(Screen lastScreen, Screen optionsLastScreen) {
|
||||||
|
|
@ -31,7 +32,7 @@ public class ProfilesScreen extends OptionsSubScreen {
|
||||||
Button.builder(
|
Button.builder(
|
||||||
Component.translatable("gui.optionsprofiles.save-current-options"),
|
Component.translatable("gui.optionsprofiles.save-current-options"),
|
||||||
(button -> {
|
(button -> {
|
||||||
Profiles.createProfile();
|
OptionsProfilesMod.PROFILES_INSTANCE.createProfile();
|
||||||
this.profilesList.refreshEntries();
|
this.profilesList.refreshEntries();
|
||||||
}))
|
}))
|
||||||
.build()
|
.build()
|
||||||
|
|
|
||||||
|
|
@ -5,28 +5,46 @@ import com.axolotlmaid.optionsprofiles.profiles.loaders.DistantHorizonsLoader;
|
||||||
import com.axolotlmaid.optionsprofiles.profiles.loaders.EmbeddiumLoader;
|
import com.axolotlmaid.optionsprofiles.profiles.loaders.EmbeddiumLoader;
|
||||||
import com.axolotlmaid.optionsprofiles.profiles.loaders.SodiumExtraLoader;
|
import com.axolotlmaid.optionsprofiles.profiles.loaders.SodiumExtraLoader;
|
||||||
import com.axolotlmaid.optionsprofiles.profiles.loaders.SodiumLoader;
|
import com.axolotlmaid.optionsprofiles.profiles.loaders.SodiumLoader;
|
||||||
|
import nl.enjarai.shared_resources.api.GameResourceHelper;
|
||||||
|
import nl.enjarai.shared_resources.util.GameResourceConfig;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.*;
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.nio.file.StandardCopyOption;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class Profiles {
|
public class Profiles {
|
||||||
public static final Path PROFILES_DIRECTORY = Paths.get("options-profiles/");
|
public static Path PROFILES_DIRECTORY = Paths.get("options-profiles/");
|
||||||
public static final Path OPTIONS_FILE = Paths.get("options.txt");
|
public static Path OPTIONS_FILE = Paths.get("options.txt");
|
||||||
public static final Path OPTIFINE_OPTIONS_FILE = Paths.get("optionsof.txt");
|
public static final Path OPTIFINE_OPTIONS_FILE = Paths.get("optionsof.txt");
|
||||||
public static final Path SODIUM_OPTIONS_FILE = Paths.get("config/sodium-options.json");
|
public static final Path SODIUM_OPTIONS_FILE = Paths.get("config/sodium-options.json");
|
||||||
public static final Path SODIUM_EXTRA_OPTIONS_FILE = Paths.get("config/sodium-extra-options.json");
|
public static final Path SODIUM_EXTRA_OPTIONS_FILE = Paths.get("config/sodium-extra-options.json");
|
||||||
public static final Path EMBEDDIUM_OPTIONS_FILE = Paths.get("config/embeddium-options.json");
|
public static final Path EMBEDDIUM_OPTIONS_FILE = Paths.get("config/embeddium-options.json");
|
||||||
public static final Path DISTANT_HORIZONS_OPTIONS_FILE = Paths.get("config/DistantHorizons.toml");
|
public static final Path DISTANT_HORIZONS_OPTIONS_FILE = Paths.get("config/DistantHorizons.toml");
|
||||||
|
|
||||||
// This function goes through every profile and updates / adds the configuration file if it doesn't exist
|
public Profiles() {
|
||||||
public static void updateProfiles() {
|
// Create profiles directory
|
||||||
|
PROFILES_DIRECTORY = Paths.get("options-profiles/");
|
||||||
|
|
||||||
|
if (Files.notExists(PROFILES_DIRECTORY)) {
|
||||||
|
try {
|
||||||
|
Files.createDirectory(PROFILES_DIRECTORY);
|
||||||
|
} catch (IOException e) {
|
||||||
|
OptionsProfilesMod.LOGGER.error("An error occurred when creating the 'options-profiles' directory.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set profiles directory if Shared Resources mod is installed
|
||||||
|
Path sharedResourcesPath = GameResourceHelper.getPathFor(SharedResourcesProfiles.SHARED_RESOURCES_PROFILES_DIRECTORY);
|
||||||
|
|
||||||
|
if (sharedResourcesPath != null) {
|
||||||
|
PROFILES_DIRECTORY = sharedResourcesPath;
|
||||||
|
OPTIONS_FILE = sharedResourcesPath.getParent().resolve("options.txt");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Goes through every profile and adds the configuration file if it doesn't exist
|
||||||
try (Stream<Path> paths = Files.list(PROFILES_DIRECTORY)) {
|
try (Stream<Path> paths = Files.list(PROFILES_DIRECTORY)) {
|
||||||
paths.filter(Files::isDirectory)
|
paths.filter(Files::isDirectory)
|
||||||
.forEach(path -> {
|
.forEach(path -> {
|
||||||
|
|
@ -34,36 +52,47 @@ public class Profiles {
|
||||||
|
|
||||||
// This gets the configuration but also creates the configuration file if it is not there
|
// This gets the configuration but also creates the configuration file if it is not there
|
||||||
ProfileConfiguration profileConfiguration = ProfileConfiguration.get(profileName);
|
ProfileConfiguration profileConfiguration = ProfileConfiguration.get(profileName);
|
||||||
List<String> optionsToLoad = profileConfiguration.getOptionsToLoad();
|
Path profile = PROFILES_DIRECTORY.resolve(profileName);
|
||||||
|
Path profileOptions = profile.resolve(OPTIONS_FILE.getFileName());
|
||||||
|
|
||||||
// Checks for updates to the configuration
|
// Add every option value to configuration
|
||||||
if (profileConfiguration.getVersion() != ProfileConfiguration.configurationVersion) {
|
try (Stream<String> lines = Files.lines(profileOptions)) {
|
||||||
Path configurationFile = path.resolve("configuration.json");
|
List<String> optionsToLoad = profileConfiguration.getOptionsToLoad();
|
||||||
|
|
||||||
try {
|
lines.forEach((line) -> {
|
||||||
Files.delete(configurationFile);
|
String[] option = line.split(":");
|
||||||
} catch (IOException e) {
|
optionsToLoad.add(option[0]);
|
||||||
OptionsProfilesMod.LOGGER.error("[Profile '{}']: Error deleting configuration file", profileName, e);
|
});
|
||||||
}
|
|
||||||
|
|
||||||
// Create the configuration.json again thus updating it
|
|
||||||
profileConfiguration = ProfileConfiguration.get(profileName);
|
|
||||||
|
|
||||||
// Add player's old configuration
|
|
||||||
profileConfiguration.setOptionsToLoad(optionsToLoad);
|
|
||||||
|
|
||||||
// Save configuration
|
|
||||||
profileConfiguration.save();
|
profileConfiguration.save();
|
||||||
|
} catch (IOException e) {
|
||||||
|
OptionsProfilesMod.LOGGER.error("[Profile '{}']: An error occurred when adding options to the configuration file", profileName, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
OptionsProfilesMod.LOGGER.warn("[Profile '{}']: Profile configuration updated / added", profileName);
|
OptionsProfilesMod.LOGGER.warn("[Profile '{}']: Profile configuration added", profileName);
|
||||||
});
|
});
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
OptionsProfilesMod.LOGGER.error("An error occurred when updating profiles", e);
|
OptionsProfilesMod.LOGGER.error("An error occurred when updating profiles", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Loading profiles on startup
|
||||||
|
try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(Profiles.PROFILES_DIRECTORY)) {
|
||||||
|
for (Path profile : directoryStream) {
|
||||||
|
String profileName = profile.getFileName().toString();
|
||||||
|
ProfileConfiguration profileConfiguration = ProfileConfiguration.get(profileName);
|
||||||
|
|
||||||
|
if (profileConfiguration.isLoadOnStartup()) {
|
||||||
|
OptionsProfilesMod.PROFILES_INSTANCE.loadProfile(profileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
OptionsProfilesMod.LOGGER.error("An error occurred when loading startup profiles", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void createProfile() {
|
public void createProfile() {
|
||||||
String profileName = "Profile 1";
|
String profileName = "Profile 1";
|
||||||
Path profile = PROFILES_DIRECTORY.resolve(profileName);
|
Path profile = PROFILES_DIRECTORY.resolve(profileName);
|
||||||
|
|
||||||
|
|
@ -87,7 +116,7 @@ public class Profiles {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void copyOptionFile(Path profile, Path options) {
|
private void copyOptionFile(Path profile, Path options) {
|
||||||
if (Files.exists(options)) {
|
if (Files.exists(options)) {
|
||||||
Path profileOptions = profile.resolve(options.getFileName());
|
Path profileOptions = profile.resolve(options.getFileName());
|
||||||
|
|
||||||
|
|
@ -100,7 +129,7 @@ public class Profiles {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeProfile(String profileName, boolean overwriting) {
|
public void writeProfile(String profileName, boolean overwriting) {
|
||||||
Path profile = PROFILES_DIRECTORY.resolve(profileName);
|
Path profile = PROFILES_DIRECTORY.resolve(profileName);
|
||||||
Path profileOptions = profile.resolve("options.txt");
|
Path profileOptions = profile.resolve("options.txt");
|
||||||
|
|
||||||
|
|
@ -146,13 +175,13 @@ public class Profiles {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isProfileLoaded(String profileName) {
|
public boolean isProfileLoaded(String profileName) {
|
||||||
Path profile = PROFILES_DIRECTORY.resolve(profileName);
|
Path profile = PROFILES_DIRECTORY.resolve(profileName);
|
||||||
|
|
||||||
List<Path> optionFiles = new ArrayList<>();
|
List<Path> optionFiles = new ArrayList<>();
|
||||||
optionFiles.add(OPTIONS_FILE);
|
optionFiles.add(OPTIONS_FILE);
|
||||||
|
|
||||||
// The next few lines check if the specified file exists. If so, it adds it to the optionFiles ArrayList.
|
// These lines check if the specified file exists. If so, it adds it to the optionFiles ArrayList.
|
||||||
Optional.of(OPTIFINE_OPTIONS_FILE).filter(Files::exists).ifPresent(optionFiles::add);
|
Optional.of(OPTIFINE_OPTIONS_FILE).filter(Files::exists).ifPresent(optionFiles::add);
|
||||||
Optional.of(SODIUM_OPTIONS_FILE).filter(Files::exists).ifPresent(optionFiles::add);
|
Optional.of(SODIUM_OPTIONS_FILE).filter(Files::exists).ifPresent(optionFiles::add);
|
||||||
Optional.of(SODIUM_EXTRA_OPTIONS_FILE).filter(Files::exists).ifPresent(optionFiles::add);
|
Optional.of(SODIUM_EXTRA_OPTIONS_FILE).filter(Files::exists).ifPresent(optionFiles::add);
|
||||||
|
|
@ -175,7 +204,7 @@ public class Profiles {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadOptionFile(String profileName, Path options) {
|
private void loadOptionFile(String profileName, Path options) {
|
||||||
ProfileConfiguration profileConfiguration = ProfileConfiguration.get(profileName);
|
ProfileConfiguration profileConfiguration = ProfileConfiguration.get(profileName);
|
||||||
|
|
||||||
Path profile = PROFILES_DIRECTORY.resolve(profileName);
|
Path profile = PROFILES_DIRECTORY.resolve(profileName);
|
||||||
|
|
@ -244,7 +273,7 @@ public class Profiles {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadOptionFile(String profileName, Path options, Consumer<Path> loader) {
|
private void loadOptionFile(String profileName, Path options, Consumer<Path> loader) {
|
||||||
Path profile = PROFILES_DIRECTORY.resolve(profileName);
|
Path profile = PROFILES_DIRECTORY.resolve(profileName);
|
||||||
Path profileOptions = profile.resolve(options.getFileName());
|
Path profileOptions = profile.resolve(options.getFileName());
|
||||||
|
|
||||||
|
|
@ -254,7 +283,7 @@ public class Profiles {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadProfile(String profileName) {
|
public void loadProfile(String profileName) {
|
||||||
loadOptionFile(profileName, OPTIONS_FILE);
|
loadOptionFile(profileName, OPTIONS_FILE);
|
||||||
loadOptionFile(profileName, OPTIFINE_OPTIONS_FILE);
|
loadOptionFile(profileName, OPTIFINE_OPTIONS_FILE);
|
||||||
loadOptionFile(profileName, SODIUM_OPTIONS_FILE, SodiumLoader::load);
|
loadOptionFile(profileName, SODIUM_OPTIONS_FILE, SodiumLoader::load);
|
||||||
|
|
@ -265,7 +294,7 @@ public class Profiles {
|
||||||
loadOptionFile(profileName, DISTANT_HORIZONS_OPTIONS_FILE, DistantHorizonsLoader::load); // Tell Distant Horizons mod to reload configuration
|
loadOptionFile(profileName, DISTANT_HORIZONS_OPTIONS_FILE, DistantHorizonsLoader::load); // Tell Distant Horizons mod to reload configuration
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void renameProfile(String profileName, String newProfileName) {
|
public void renameProfile(String profileName, String newProfileName) {
|
||||||
Path profile = PROFILES_DIRECTORY.resolve(profileName);
|
Path profile = PROFILES_DIRECTORY.resolve(profileName);
|
||||||
Path newProfile = PROFILES_DIRECTORY.resolve(newProfileName);
|
Path newProfile = PROFILES_DIRECTORY.resolve(newProfileName);
|
||||||
|
|
||||||
|
|
@ -282,7 +311,7 @@ public class Profiles {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteProfile(String profileName) {
|
public void deleteProfile(String profileName) {
|
||||||
Path profile = PROFILES_DIRECTORY.resolve(profileName);
|
Path profile = PROFILES_DIRECTORY.resolve(profileName);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.axolotlmaid.optionsprofiles.profiles;
|
||||||
|
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import nl.enjarai.shared_resources.api.GameResourceRegistry;
|
||||||
|
import nl.enjarai.shared_resources.api.ResourceDirectory;
|
||||||
|
import nl.enjarai.shared_resources.api.ResourceDirectoryBuilder;
|
||||||
|
import nl.enjarai.shared_resources.api.SharedResourcesEntrypoint;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
|
public class SharedResourcesProfiles implements SharedResourcesEntrypoint {
|
||||||
|
public static final ResourceDirectory SHARED_RESOURCES_PROFILES_DIRECTORY = new ResourceDirectoryBuilder("options-profiles")
|
||||||
|
.setDisplayName(Component.translatable("gui.optionsprofiles"))
|
||||||
|
.defaultEnabled(true)
|
||||||
|
.isExperimental()
|
||||||
|
.build();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerResources(GameResourceRegistry registry) {
|
||||||
|
registry.register(ResourceLocation.fromNamespaceAndPath("optionsprofiles", "profiles_directory"), SHARED_RESOURCES_PROFILES_DIRECTORY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
{
|
{
|
||||||
|
"gui.optionsprofiles": "Options Profiles",
|
||||||
|
|
||||||
"gui.optionsprofiles.profiles-menu": "Profiles",
|
"gui.optionsprofiles.profiles-menu": "Profiles",
|
||||||
"gui.optionsprofiles.save-current-options": "Save Current Options",
|
"gui.optionsprofiles.save-current-options": "Save Current Options",
|
||||||
"gui.optionsprofiles.load-profile": "✔ (Load)",
|
"gui.optionsprofiles.load-profile": "✔ (Load)",
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,9 @@
|
||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
"main": [
|
"main": [
|
||||||
"com.axolotlmaid.optionsprofiles.fabric.OptionsProfilesModFabric"
|
"com.axolotlmaid.optionsprofiles.fabric.OptionsProfilesModFabric"
|
||||||
|
],
|
||||||
|
"shared-resources": [
|
||||||
|
"com.axolotlmaid.optionsprofiles.profiles.SharedResourcesProfiles"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue