Updates KnarLib
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good
This commit is contained in:
@@ -6,12 +6,12 @@ import net.knarcraft.blacksmith.BlacksmithPlugin;
|
||||
import net.knarcraft.blacksmith.config.Setting;
|
||||
import net.knarcraft.blacksmith.config.SettingValueType;
|
||||
import net.knarcraft.blacksmith.config.Settings;
|
||||
import net.knarcraft.blacksmith.formatting.BlacksmithTranslatableMessage;
|
||||
import net.knarcraft.blacksmith.formatting.Translatable;
|
||||
import net.knarcraft.blacksmith.trait.CustomTrait;
|
||||
import net.knarcraft.blacksmith.util.ConfigCommandHelper;
|
||||
import net.knarcraft.blacksmith.util.InputParsingHelper;
|
||||
import net.knarcraft.blacksmith.util.TypeValidationHelper;
|
||||
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||
import net.knarcraft.knarlib.formatting.FormatBuilder;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -21,9 +21,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static net.knarcraft.blacksmith.formatting.BlacksmithTranslatableMessage.getCurrentValueMessage;
|
||||
import static net.knarcraft.blacksmith.formatting.BlacksmithTranslatableMessage.getDefaultValueMessage;
|
||||
import static net.knarcraft.blacksmith.formatting.BlacksmithTranslatableMessage.getValueChangedMessage;
|
||||
import static net.knarcraft.blacksmith.formatting.Translatable.getCurrentValueMessage;
|
||||
import static net.knarcraft.blacksmith.formatting.Translatable.getDefaultValueMessage;
|
||||
import static net.knarcraft.blacksmith.formatting.Translatable.getValueChangedMessage;
|
||||
|
||||
/**
|
||||
* A generic implementation of the edit command
|
||||
@@ -64,8 +64,7 @@ public abstract class EditCommand<K extends CustomTrait<L>, L extends Setting> i
|
||||
@NotNull String[] args) {
|
||||
NPC npc = CitizensAPI.getDefaultNPCSelector().getSelected(sender);
|
||||
if (npc == null || !npc.hasTrait(traitClass)) {
|
||||
BlacksmithPlugin.getStringFormatter().displayErrorMessage(sender,
|
||||
BlacksmithTranslatableMessage.NO_NPC_SELECTED);
|
||||
new FormatBuilder(Translatable.NO_NPC_SELECTED).error(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -130,8 +129,7 @@ public abstract class EditCommand<K extends CustomTrait<L>, L extends Setting> i
|
||||
return false;
|
||||
}
|
||||
settings.changeValue(setting, newValue);
|
||||
BlacksmithPlugin.getStringFormatter().displaySuccessMessage(sender,
|
||||
getValueChangedMessage(setting.getCommandName(), String.valueOf(newValue)));
|
||||
getValueChangedMessage(setting.getCommandName(), String.valueOf(newValue)).success(sender);
|
||||
//Save the changes immediately to prevent data loss on server crash
|
||||
CitizensAPI.getNPCRegistry().saveToStore();
|
||||
}
|
||||
@@ -156,21 +154,19 @@ public abstract class EditCommand<K extends CustomTrait<L>, L extends Setting> i
|
||||
return;
|
||||
}
|
||||
|
||||
StringFormatter formatter = BlacksmithPlugin.getStringFormatter();
|
||||
|
||||
//Find the value of the specified setting
|
||||
String commandName = setting.getCommandName();
|
||||
String currentValue = String.valueOf(settings.getRawValue(setting));
|
||||
String defaultValue = String.valueOf(setting.getDefaultValue());
|
||||
String marker = formatter.getUnFormattedMessage(BlacksmithTranslatableMessage.SETTING_OVERRIDDEN_MARKER);
|
||||
String marker = new FormatBuilder(Translatable.SETTING_OVERRIDDEN_MARKER).toString();
|
||||
boolean isMessage = setting.isMessage();
|
||||
boolean isSet = !InputParsingHelper.isEmpty(currentValue);
|
||||
|
||||
// Display the description for how this setting is used
|
||||
formatter.displaySuccessMessage(sender, setting.getDescription());
|
||||
new FormatBuilder(setting.getDescription()).success(sender);
|
||||
|
||||
// Display the default value
|
||||
formatter.displayNeutralMessage(sender, getDefaultValueMessage(commandName, defaultValue));
|
||||
getDefaultValueMessage(commandName, defaultValue).neutral(sender);
|
||||
if (isMessage) {
|
||||
ConfigCommandHelper.displayRaw(sender, defaultValue);
|
||||
}
|
||||
@@ -181,7 +177,7 @@ public abstract class EditCommand<K extends CustomTrait<L>, L extends Setting> i
|
||||
}
|
||||
|
||||
// Display the value with a marker if it's customized
|
||||
formatter.displayNeutralMessage(sender, getCurrentValueMessage(commandName, currentValue) + (isSet ? marker : ""));
|
||||
new FormatBuilder(getCurrentValueMessage(commandName, currentValue) + (isSet ? marker : "")).neutral(sender);
|
||||
|
||||
if (isMessage) {
|
||||
ConfigCommandHelper.displayRaw(sender, currentValue);
|
||||
|
Reference in New Issue
Block a user