aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/cowtipper/cowlection/config
diff options
context:
space:
mode:
authorCow <cow@volloeko.de>2020-12-20 15:12:34 +0100
committerCow <cow@volloeko.de>2020-12-20 15:12:34 +0100
commit609758ab51a46e4ccac2cd37f449f3682bc15770 (patch)
tree65c8bb2728b2356348129fd96478b630fcb10ba3 /src/main/java/de/cowtipper/cowlection/config
parent61b01b39496dd56e8bdce8b9c25d591af116dfec (diff)
downloadCowlection-609758ab51a46e4ccac2cd37f449f3682bc15770.tar.gz
Cowlection-609758ab51a46e4ccac2cd37f449f3682bc15770.tar.bz2
Cowlection-609758ab51a46e4ccac2cd37f449f3682bc15770.zip
Added config options to enable/disable some features
Diffstat (limited to 'src/main/java/de/cowtipper/cowlection/config')
-rw-r--r--src/main/java/de/cowtipper/cowlection/config/MooConfig.java49
-rw-r--r--src/main/java/de/cowtipper/cowlection/config/gui/MooConfigCategoryScrolling.java7
2 files changed, 56 insertions, 0 deletions
diff --git a/src/main/java/de/cowtipper/cowlection/config/MooConfig.java b/src/main/java/de/cowtipper/cowlection/config/MooConfig.java
index b89f4de..a522dce 100644
--- a/src/main/java/de/cowtipper/cowlection/config/MooConfig.java
+++ b/src/main/java/de/cowtipper/cowlection/config/MooConfig.java
@@ -1,6 +1,7 @@
package de.cowtipper.cowlection.config;
import de.cowtipper.cowlection.Cowlection;
+import de.cowtipper.cowlection.command.MooCommand;
import de.cowtipper.cowlection.command.TabCompletableCommand;
import de.cowtipper.cowlection.config.gui.MooConfigGui;
import de.cowtipper.cowlection.config.gui.MooConfigPreview;
@@ -46,6 +47,9 @@ import java.util.regex.Pattern;
public class MooConfig {
// Category: General
private static String configGuiExplanations;
+ public static String mooCmdAlias;
+ public static boolean fixReplyCmd;
+ public static boolean enableCopyInventory;
public static String[] tabCompletableNamesCommands;
private static final String CATEGORY_LOGS_SEARCH = "logssearch";
public static String[] logsDirs;
@@ -84,6 +88,7 @@ public class MooConfig {
private static Configuration cfg = null;
private static final List<MooConfigCategory> configCategories = new ArrayList<>();
private final Cowlection main;
+ private Property propMooCmdAlias;
private Property propTabCompletableNamesCommands;
private List<Property> logSearchProperties;
@@ -196,6 +201,17 @@ public class MooConfig {
"The API key is stored " + EnumChatFormatting.ITALIC + "locally " + EnumChatFormatting.ITALIC + "on your computer.");
subCat.addConfigEntry(main.getMoo().getPropIsMooValid());
+ // Sub-Category: Command settings
+ subCat = configCat.addSubCategory("Command settings");
+
+ propMooCmdAlias = subCat.addConfigEntry(cfg.get(configCat.getConfigName(),
+ "mooCmdAlias", "m", "Alias for /moo command")
+ .setValidationPattern(Pattern.compile("^[A-Za-z]*$")));
+ Property propFixReplyCmd = subCat.addConfigEntry(cfg.get(configCat.getConfigName(),
+ "fixReplyCmd", true, "Auto-replace /r?"));
+ Property propEnableCopyInventory = subCat.addConfigEntry(cfg.get(configCat.getConfigName(),
+ "enableCopyInventory", false, "Enable copy inventory with CTRL + C?"));
+
// Sub-Category: Tab-completable names in commands
subCat = configCat.addSubCategory("Tab-completable usernames");
subCat.addExplanations("For certain commands you can use " + EnumChatFormatting.YELLOW + "TAB " + EnumChatFormatting.RESET + "to autocomplete player names",
@@ -410,11 +426,16 @@ public class MooConfig {
Property propDungPartyFinderPlayerLookup = subCat.addConfigEntry(cfg.get(configCat.getConfigName(),
"dungPartyFinderPlayerLookup", "as a tooltip", "Show armor + dungeons stats of player joining via party finder as a tooltip or in chat?", new String[]{"as a tooltip", "in chat", "disabled"}));
+ boolean modifiedMooCmdAlias = false;
+ String mooCmdAliasPreChange = mooCmdAlias;
boolean modifiedTabCompletableCommandsList = false;
String[] tabCompletableCommandsPreChange = tabCompletableNamesCommands != null ? tabCompletableNamesCommands.clone() : null;
if (readFieldsFromConfig) {
// Category: General
configGuiExplanations = propConfigGuiExplanations.getString();
+ mooCmdAlias = propMooCmdAlias.getString();
+ fixReplyCmd = propFixReplyCmd.getBoolean();
+ enableCopyInventory = propEnableCopyInventory.getBoolean();
tabCompletableNamesCommands = propTabCompletableNamesCommands.getStringList();
logsDirs = propLogsDirs.getStringList();
defaultStartDate = propDefaultStartDate.getString().trim();
@@ -450,6 +471,9 @@ public class MooConfig {
dungPartyFinderPlayerLookup = propDungPartyFinderPlayerLookup.getString();
+ if (!StringUtils.equals(mooCmdAliasPreChange, mooCmdAlias)) {
+ modifiedMooCmdAlias = true;
+ }
if (!Arrays.equals(tabCompletableCommandsPreChange, tabCompletableNamesCommands)) {
modifiedTabCompletableCommandsList = true;
}
@@ -457,6 +481,9 @@ public class MooConfig {
// Category: General
propConfigGuiExplanations.set(configGuiExplanations);
+ propMooCmdAlias.set(mooCmdAlias);
+ propFixReplyCmd.set(fixReplyCmd);
+ propEnableCopyInventory.set(enableCopyInventory);
propTabCompletableNamesCommands.set(tabCompletableNamesCommands);
propLogsDirs.set(logsDirs);
propDefaultStartDate.set(defaultStartDate);
@@ -493,6 +520,24 @@ public class MooConfig {
if (saveToFile && cfg.hasChanged()) {
boolean isPlayerIngame = Minecraft.getMinecraft().thePlayer != null;
+ if (modifiedMooCmdAlias) {
+ Map<String, ICommand> clientCommandsMap = ClientCommandHandler.instance.getCommands();
+ ICommand possibleClientCommand = clientCommandsMap.get(mooCmdAlias);
+ if (possibleClientCommand != null && !(possibleClientCommand instanceof MooCommand)) {
+ // tried to use a command name which is already used by another client side command; however, this would overwrite the original command
+ if (isPlayerIngame) {
+ main.getChatHelper().sendMessage(EnumChatFormatting.GOLD, " ⚠ " + EnumChatFormatting.GOLD + "Client-side commands from other mods cannot be used as a command alias. " + EnumChatFormatting.RED + "This would overwrite the other command! Therefore the alias for " + EnumChatFormatting.DARK_RED + "/moo" + EnumChatFormatting.RED + " was not changed to " + EnumChatFormatting.DARK_RED + "/" + mooCmdAlias);
+ }
+ mooCmdAlias = mooCmdAliasPreChange;
+ propMooCmdAlias.set(mooCmdAlias);
+ } else if (isPlayerIngame) {
+ if (StringUtils.isEmpty(mooCmdAlias)) {
+ main.getChatHelper().sendMessage(EnumChatFormatting.RED, "Removed command alias for " + EnumChatFormatting.DARK_RED + "/moo " + EnumChatFormatting.RED + "which takes effect after a game restart.");
+ } else {
+ main.getChatHelper().sendMessage(EnumChatFormatting.RED, "Changed command alias for " + EnumChatFormatting.DARK_RED + "/moo " + EnumChatFormatting.RED + "to " + EnumChatFormatting.DARK_RED + "/" + mooCmdAlias + EnumChatFormatting.RED + " which takes effect after a game restart.");
+ }
+ }
+ }
if (modifiedTabCompletableCommandsList) {
if (isPlayerIngame) {
main.getChatHelper().sendMessage(EnumChatFormatting.RED, "Added or removed commands with tab-completable usernames take effect after a game restart! If player names cannot be tab-completed for a command after a game restart, check the capitalization of the command name.");
@@ -649,6 +694,10 @@ public class MooConfig {
return configCategories;
}
+ public Property getMooCmdAliasProperty() {
+ return propMooCmdAlias;
+ }
+
public Property getTabCompletableNamesCommandsProperty() {
return propTabCompletableNamesCommands;
}
diff --git a/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigCategoryScrolling.java b/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigCategoryScrolling.java
index c73e27e..4ffa9f0 100644
--- a/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigCategoryScrolling.java
+++ b/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigCategoryScrolling.java
@@ -126,6 +126,13 @@ public class MooConfigCategoryScrolling extends GuiListExtended {
// special case: moo!
this.listEntries.add(new BooleanConfigEntry(configEntry));
continue;
+ } else if (configEntry.equals(Cowlection.getInstance().getConfig().getMooCmdAliasProperty())) {
+ this.listEntries.add(new GuiSwitchEntry("mooCmdAlias", "➡ modify", () ->
+ mc.displayGuiScreen(new GuiConfig(MooConfigCategoryScrolling.this.parent,
+ Lists.newArrayList(new ConfigElement(Cowlection.getInstance().getConfig().getMooCmdAliasProperty())),
+ Cowlection.MODID, "cowlectionMooCmdAlias", false, false,
+ EnumChatFormatting.GOLD + "Press Done to save changes. " + EnumChatFormatting.RED + "Requires a game restart to take effect!"))));
+ continue;
} else if (configEntry.getValidValues() != null && configEntry.getValidValues().length > 0) {
this.listEntries.add(new CycleConfigEntry(configEntry));
continue;