From 8326da54252ad7138b50ee8386319b5ffe1c4413 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Tue, 18 Oct 2022 11:56:54 +0200 Subject: [PATCH] Removes nodeName and uses commandName instead --- .../command/BlackSmithConfigCommand.java | 5 +++-- .../command/BlackSmithEditCommand.java | 2 +- .../knarcraft/blacksmith/config/NPCSetting.java | 16 ---------------- 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/main/java/net/knarcraft/blacksmith/command/BlackSmithConfigCommand.java b/src/main/java/net/knarcraft/blacksmith/command/BlackSmithConfigCommand.java index b9572e7..b2e32d0 100644 --- a/src/main/java/net/knarcraft/blacksmith/command/BlackSmithConfigCommand.java +++ b/src/main/java/net/knarcraft/blacksmith/command/BlackSmithConfigCommand.java @@ -22,6 +22,7 @@ import java.util.Arrays; import static net.knarcraft.blacksmith.formatting.StringFormatter.displayErrorMessage; import static net.knarcraft.blacksmith.formatting.StringFormatter.displaySuccessMessage; +import static net.knarcraft.blacksmith.formatting.TranslatableMessage.getValueChangedMessage; /** * The command used for changing global configuration options @@ -98,7 +99,7 @@ public class BlackSmithConfigCommand implements CommandExecutor { String newValue = args[1]; if (detectedGlobalSetting != null) { settings.changeValue(detectedGlobalSetting, newValue); - displaySuccessMessage(sender, TranslatableMessage.getValueChangedMessage(detectedGlobalSetting.getCommandName(), newValue)); + displaySuccessMessage(sender, getValueChangedMessage(detectedGlobalSetting.getCommandName(), newValue)); return true; } else if (detectedNPCSetting != null) { //This makes sure all arguments are treated as a sentence @@ -106,7 +107,7 @@ public class BlackSmithConfigCommand implements CommandExecutor { newValue = String.join(" ", Arrays.asList(args).subList(1, args.length)); } settings.changeValue(detectedNPCSetting, newValue); - displaySuccessMessage(sender, TranslatableMessage.getValueChangedMessage(detectedNPCSetting.getNodeName(), newValue)); + displaySuccessMessage(sender, getValueChangedMessage(detectedNPCSetting.getCommandName(), newValue)); return true; } else { return false; diff --git a/src/main/java/net/knarcraft/blacksmith/command/BlackSmithEditCommand.java b/src/main/java/net/knarcraft/blacksmith/command/BlackSmithEditCommand.java index 85b9db8..02eff55 100644 --- a/src/main/java/net/knarcraft/blacksmith/command/BlackSmithEditCommand.java +++ b/src/main/java/net/knarcraft/blacksmith/command/BlackSmithEditCommand.java @@ -85,7 +85,7 @@ public class BlackSmithEditCommand implements CommandExecutor { //Change the setting blacksmithTrait.getSettings().changeSetting(npcSetting, newValue); - displaySuccessMessage(sender, getValueChangedMessage(npcSetting.getNodeName(), String.valueOf(newValue))); + displaySuccessMessage(sender, getValueChangedMessage(npcSetting.getCommandName(), String.valueOf(newValue))); //Save the changes immediately to prevent data loss on server crash CitizensAPI.getNPCRegistry().saveToStore(); } diff --git a/src/main/java/net/knarcraft/blacksmith/config/NPCSetting.java b/src/main/java/net/knarcraft/blacksmith/config/NPCSetting.java index cb4f2f8..d6f4aa7 100644 --- a/src/main/java/net/knarcraft/blacksmith/config/NPCSetting.java +++ b/src/main/java/net/knarcraft/blacksmith/config/NPCSetting.java @@ -131,7 +131,6 @@ public enum NPCSetting { private final String childPath; private final Object value; private final String commandName; - private final String nodeName; private final SettingValueType valueType; /** @@ -146,14 +145,8 @@ public enum NPCSetting { this.path = "defaults." + path; this.value = value; this.valueType = valueType; - String[] pathParts = path.split("\\."); this.childPath = path; this.commandName = commandName; - if (pathParts.length > 0) { - this.nodeName = pathParts[pathParts.length - 1]; - } else { - this.nodeName = ""; - } } /** @@ -192,15 +185,6 @@ public enum NPCSetting { return commandName; } - /** - * Gets the name of this configuration node - * - * @return

The name of this configuration node

- */ - public String getNodeName() { - return nodeName; - } - /** * Gets the value type for this setting *