From 9ffd788e291cf338c1bce47ae131114b9db5afb0 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Mon, 3 Oct 2022 12:15:18 +0200 Subject: [PATCH] Restricts raw value output to messages --- .../blacksmith/command/BlackSmithConfigCommand.java | 8 +++++++- .../blacksmith/command/BlackSmithEditCommand.java | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/knarcraft/blacksmith/command/BlackSmithConfigCommand.java b/src/main/java/net/knarcraft/blacksmith/command/BlackSmithConfigCommand.java index d679ee6..f160767 100644 --- a/src/main/java/net/knarcraft/blacksmith/command/BlackSmithConfigCommand.java +++ b/src/main/java/net/knarcraft/blacksmith/command/BlackSmithConfigCommand.java @@ -69,17 +69,23 @@ public class BlackSmithConfigCommand implements CommandExecutor { //TODO: See if there's a way to remove this duplication String rawValue; String correctCommandName; + boolean printRawValue = false; if (detectedGlobalSetting != null) { rawValue = String.valueOf(settings.getRawValue(detectedGlobalSetting)); correctCommandName = detectedGlobalSetting.getCommandName(); } else if (detectedNPCSetting != null) { rawValue = String.valueOf(settings.getRawValue(detectedNPCSetting)); correctCommandName = detectedNPCSetting.getCommandName(); + if (detectedNPCSetting.getPath().startsWith("defaults.messages")) { + printRawValue = true; + } } else { return false; } displaySuccessMessage(sender, Message.getCurrentValueMessage(correctCommandName, rawValue)); - sender.sendMessage("Raw value: " + rawValue.replace(ChatColor.COLOR_CHAR, '&')); + if (printRawValue) { + sender.sendMessage("Raw value: " + rawValue.replace(ChatColor.COLOR_CHAR, '&')); + } return true; } else if (args.length == 2 && isSpecialCase(commandName)) { if (displaySpecialCaseValue(args[1], sender, detectedGlobalSetting, settings)) { diff --git a/src/main/java/net/knarcraft/blacksmith/command/BlackSmithEditCommand.java b/src/main/java/net/knarcraft/blacksmith/command/BlackSmithEditCommand.java index 82f1483..5e1d169 100644 --- a/src/main/java/net/knarcraft/blacksmith/command/BlackSmithEditCommand.java +++ b/src/main/java/net/knarcraft/blacksmith/command/BlackSmithEditCommand.java @@ -60,7 +60,9 @@ public class BlackSmithEditCommand implements CommandExecutor { //Display the current value of the setting String rawValue = String.valueOf(blacksmithTrait.getSettings().getRawValue(npcSetting)); displaySuccessMessage(sender, Message.getCurrentValueMessage(npcSetting.getCommandName(), rawValue)); - sender.sendMessage("Raw value: " + rawValue.replace(ChatColor.COLOR_CHAR, '&')); + if (npcSetting.getPath().startsWith("defaults.messages")) { + sender.sendMessage("Raw value: " + rawValue.replace(ChatColor.COLOR_CHAR, '&')); + } return true; } else { boolean isValidType = TypeValidationHelper.isValid(npcSetting.getValueType(), newValue, sender);