Rename class

This commit is contained in:
filoghost 2020-08-14 17:54:27 +02:00
parent e4d6c8aed5
commit de5dd3b3ef
25 changed files with 92 additions and 92 deletions

View File

@ -21,7 +21,7 @@ import me.filoghost.chestcommands.listener.CommandListener;
import me.filoghost.chestcommands.listener.InventoryListener;
import me.filoghost.chestcommands.listener.JoinListener;
import me.filoghost.chestcommands.listener.SignListener;
import me.filoghost.chestcommands.logging.ErrorMessages;
import me.filoghost.chestcommands.logging.Errors;
import me.filoghost.chestcommands.logging.PrintableErrorCollector;
import me.filoghost.chestcommands.menu.MenuManager;
import me.filoghost.chestcommands.parsing.menu.LoadedMenu;
@ -156,7 +156,7 @@ public class ChestCommands extends BaseJavaPlugin {
try {
Files.createDirectories(configManager.getRootDataFolder());
} catch (IOException e) {
errorCollector.add(e, ErrorMessages.Config.createDataFolderIOException);
errorCollector.add(e, Errors.Config.createDataFolderIOException);
return errorCollector;
}
@ -165,11 +165,11 @@ public class ChestCommands extends BaseJavaPlugin {
try {
boolean allUpgradesSuccessful = upgradeExecutor.run(isFreshInstall, errorCollector);
if (!allUpgradesSuccessful) {
errorCollector.add(ErrorMessages.Upgrade.failedSomeUpgrades);
errorCollector.add(Errors.Upgrade.failedSomeUpgrades);
}
} catch (UpgradeExecutorException e) {
errorCollector.add(e, ErrorMessages.Upgrade.genericExecutorError);
errorCollector.add(ErrorMessages.Upgrade.failedSomeUpgrades);
errorCollector.add(e, Errors.Upgrade.genericExecutorError);
errorCollector.add(Errors.Upgrade.failedSomeUpgrades);
}
settings = configManager.tryLoadSettings(errorCollector);

View File

@ -6,7 +6,7 @@
package me.filoghost.chestcommands.action;
import me.filoghost.chestcommands.hook.BarAPIHook;
import me.filoghost.chestcommands.logging.ErrorMessages;
import me.filoghost.chestcommands.logging.Errors;
import me.filoghost.chestcommands.parsing.NumberParser;
import me.filoghost.chestcommands.parsing.ParseException;
import me.filoghost.chestcommands.placeholder.PlaceholderString;
@ -28,7 +28,7 @@ public class DragonBarAction implements Action {
seconds = NumberParser.getStrictlyPositiveInteger(split[0]);
message = split[1];
} catch (ParseException e) {
throw new ParseException(ErrorMessages.Parsing.invalidBossBarTime(split[0]), e);
throw new ParseException(Errors.Parsing.invalidBossBarTime(split[0]), e);
}
} else {
seconds = 1;
@ -43,7 +43,7 @@ public class DragonBarAction implements Action {
if (BarAPIHook.INSTANCE.isEnabled()) {
BarAPIHook.setMessage(player, message.getValue(player), seconds);
} else {
player.sendMessage(ErrorMessages.User.configurationError("BarAPI plugin not found"));
player.sendMessage(Errors.User.configurationError("BarAPI plugin not found"));
}
}

View File

@ -6,7 +6,7 @@
package me.filoghost.chestcommands.action;
import me.filoghost.chestcommands.hook.VaultEconomyHook;
import me.filoghost.chestcommands.logging.ErrorMessages;
import me.filoghost.chestcommands.logging.Errors;
import me.filoghost.chestcommands.parsing.NumberParser;
import me.filoghost.chestcommands.parsing.ParseException;
import org.bukkit.entity.Player;
@ -24,7 +24,7 @@ public class GiveMoneyAction implements Action {
if (VaultEconomyHook.INSTANCE.isEnabled()) {
VaultEconomyHook.giveMoney(player, moneyToGive);
} else {
player.sendMessage(ErrorMessages.User.configurationError("Vault with a compatible economy plugin not found"));
player.sendMessage(Errors.User.configurationError("Vault with a compatible economy plugin not found"));
}
}

View File

@ -6,7 +6,7 @@
package me.filoghost.chestcommands.action;
import me.filoghost.chestcommands.ChestCommands;
import me.filoghost.chestcommands.logging.ErrorMessages;
import me.filoghost.chestcommands.logging.Errors;
import me.filoghost.chestcommands.menu.InternalIconMenu;
import me.filoghost.chestcommands.placeholder.PlaceholderString;
import org.bukkit.Bukkit;
@ -35,7 +35,7 @@ public class OpenMenuAction implements Action {
});
} else {
player.sendMessage(ErrorMessages.User.configurationError("couldn't find the menu \"" + menuName + "\""));
player.sendMessage(Errors.User.configurationError("couldn't find the menu \"" + menuName + "\""));
}
}

View File

@ -5,7 +5,7 @@
*/
package me.filoghost.chestcommands.action;
import me.filoghost.chestcommands.logging.ErrorMessages;
import me.filoghost.chestcommands.logging.Errors;
import me.filoghost.chestcommands.parsing.NumberParser;
import me.filoghost.chestcommands.parsing.ParseException;
import me.filoghost.commons.Strings;
@ -28,7 +28,7 @@ public class PlaySoundAction implements Action {
Optional<Sound> sound = SOUNDS_REGISTRY.find(split[0]);
if (!sound.isPresent()) {
throw new ParseException(ErrorMessages.Parsing.unknownSound(split[0]));
throw new ParseException(Errors.Parsing.unknownSound(split[0]));
}
this.sound = sound.get();
@ -36,7 +36,7 @@ public class PlaySoundAction implements Action {
try {
pitch = NumberParser.getFloat(split[1]);
} catch (ParseException e) {
throw new ParseException(ErrorMessages.Parsing.invalidSoundPitch(split[1]), e);
throw new ParseException(Errors.Parsing.invalidSoundPitch(split[1]), e);
}
} else {
pitch = 1.0f;
@ -46,7 +46,7 @@ public class PlaySoundAction implements Action {
try {
volume = NumberParser.getFloat(split[2]);
} catch (ParseException e) {
throw new ParseException(ErrorMessages.Parsing.invalidSoundVolume(split[2]), e);
throw new ParseException(Errors.Parsing.invalidSoundVolume(split[2]), e);
}
} else {
volume = 1.0f;

View File

@ -8,7 +8,7 @@ package me.filoghost.chestcommands.attribute;
import me.filoghost.chestcommands.action.Action;
import me.filoghost.chestcommands.action.DisabledAction;
import me.filoghost.chestcommands.icon.InternalConfigurableIcon;
import me.filoghost.chestcommands.logging.ErrorMessages;
import me.filoghost.chestcommands.logging.Errors;
import me.filoghost.chestcommands.parsing.ActionParser;
import me.filoghost.chestcommands.parsing.ParseException;
@ -30,7 +30,7 @@ public class ActionsAttribute implements IconAttribute {
try {
actions.add(ActionParser.parse(serializedAction));
} catch (ParseException e) {
actions.add(new DisabledAction(ErrorMessages.User.configurationError(
actions.add(new DisabledAction(Errors.User.configurationError(
"an action linked to clicking this icon was not executed because it was not valid")));
errorHandler.onListElementError(serializedAction, e);
}

View File

@ -6,7 +6,7 @@
package me.filoghost.chestcommands.attribute;
import me.filoghost.chestcommands.icon.InternalConfigurableIcon;
import me.filoghost.chestcommands.logging.ErrorMessages;
import me.filoghost.chestcommands.logging.Errors;
import me.filoghost.chestcommands.parsing.ParseException;
public class AmountAttribute implements IconAttribute {
@ -15,7 +15,7 @@ public class AmountAttribute implements IconAttribute {
public AmountAttribute(int amount, AttributeErrorHandler errorHandler) throws ParseException {
if (amount < 0) {
throw new ParseException(ErrorMessages.Parsing.zeroOrPositive);
throw new ParseException(Errors.Parsing.zeroOrPositive);
}
this.amount = amount;
}

View File

@ -6,7 +6,7 @@
package me.filoghost.chestcommands.attribute;
import me.filoghost.chestcommands.icon.InternalConfigurableIcon;
import me.filoghost.chestcommands.logging.ErrorMessages;
import me.filoghost.chestcommands.logging.Errors;
import me.filoghost.chestcommands.parsing.ParseException;
public class ExpLevelsAttribute implements IconAttribute {
@ -15,7 +15,7 @@ public class ExpLevelsAttribute implements IconAttribute {
public ExpLevelsAttribute(int expLevels, AttributeErrorHandler errorHandler) throws ParseException {
if (expLevels < 0) {
throw new ParseException(ErrorMessages.Parsing.zeroOrPositive);
throw new ParseException(Errors.Parsing.zeroOrPositive);
}
this.expLevels = expLevels;
}

View File

@ -6,7 +6,7 @@
package me.filoghost.chestcommands.attribute;
import me.filoghost.chestcommands.icon.InternalConfigurableIcon;
import me.filoghost.chestcommands.logging.ErrorMessages;
import me.filoghost.chestcommands.logging.Errors;
import me.filoghost.chestcommands.parsing.ParseException;
public class PriceAttribute implements IconAttribute {
@ -15,7 +15,7 @@ public class PriceAttribute implements IconAttribute {
public PriceAttribute(double price, AttributeErrorHandler errorHandler) throws ParseException {
if (price < 0) {
throw new ParseException(ErrorMessages.Parsing.zeroOrPositive);
throw new ParseException(Errors.Parsing.zeroOrPositive);
}
this.price = price;
}

View File

@ -5,7 +5,7 @@
*/
package me.filoghost.chestcommands.config;
import me.filoghost.chestcommands.logging.ErrorMessages;
import me.filoghost.chestcommands.logging.Errors;
import me.filoghost.chestcommands.parsing.menu.LoadedMenu;
import me.filoghost.chestcommands.parsing.menu.MenuParser;
import me.filoghost.commons.Preconditions;
@ -92,7 +92,7 @@ public class ConfigManager extends BaseConfigManager {
}
private void logConfigInitException(ErrorCollector errorCollector, Path file, ConfigException e) {
errorCollector.add(e, ErrorMessages.Config.initException(file));
errorCollector.add(e, Errors.Config.initException(file));
}
public List<LoadedMenu> tryLoadMenus(ErrorCollector errorCollector) {
@ -102,7 +102,7 @@ public class ConfigManager extends BaseConfigManager {
try {
menuFiles = getMenuFiles();
} catch (IOException e) {
errorCollector.add(e, ErrorMessages.Config.menuListIOException(getMenusFolder()));
errorCollector.add(e, Errors.Config.menuListIOException(getMenusFolder()));
return Collections.emptyList();
}

View File

@ -5,7 +5,7 @@
*/
package me.filoghost.chestcommands.config;
import me.filoghost.chestcommands.logging.ErrorMessages;
import me.filoghost.chestcommands.logging.Errors;
import me.filoghost.chestcommands.placeholder.StaticPlaceholder;
import me.filoghost.commons.Colors;
import me.filoghost.commons.config.Config;
@ -34,12 +34,12 @@ public class CustomPlaceholders {
}
if (placeholder.length() == 0) {
errorCollector.add(ErrorMessages.Config.emptyPlaceholder(config.getSourceFile()));
errorCollector.add(Errors.Config.emptyPlaceholder(config.getSourceFile()));
continue;
}
if (placeholder.length() > 100) {
errorCollector.add(ErrorMessages.Config.tooLongPlaceholder(config.getSourceFile(), placeholder));
errorCollector.add(Errors.Config.tooLongPlaceholder(config.getSourceFile(), placeholder));
continue;
}

View File

@ -5,7 +5,7 @@
*/
package me.filoghost.chestcommands.config;
import me.filoghost.chestcommands.logging.ErrorMessages;
import me.filoghost.chestcommands.logging.Errors;
import me.filoghost.commons.config.mapped.MappedConfig;
import me.filoghost.commons.config.mapped.modifier.ChatColors;
@ -17,7 +17,7 @@ public class Lang extends MappedConfig {
public String no_required_item = "&cYou must have &e{amount}x {material} &c(durability: {durability}) for this.";
public String no_money = "&cYou need {money}$ for this.";
public String no_exp = "&cYou need {levels} XP levels for this.";
public String menu_not_found = "&cMenu not found! " + ErrorMessages.User.notifyStaffRequest;
public String menu_not_found = "&cMenu not found! " + Errors.User.notifyStaffRequest;
public String open_menu = "&aOpening the menu \"{menu}\".";
public String open_menu_others = "&aOpening the menu \"{menu}\" to {player}.";
public String any = "any"; // Used in no_required_item when durability is not restrictive

View File

@ -8,7 +8,7 @@ package me.filoghost.chestcommands.icon.requirement;
import com.google.common.base.Preconditions;
import me.filoghost.chestcommands.ChestCommands;
import me.filoghost.chestcommands.hook.VaultEconomyHook;
import me.filoghost.chestcommands.logging.ErrorMessages;
import me.filoghost.chestcommands.logging.Errors;
import org.bukkit.entity.Player;
public class RequiredMoney implements Requirement {
@ -23,7 +23,7 @@ public class RequiredMoney implements Requirement {
@Override
public boolean hasCost(Player player) {
if (!VaultEconomyHook.INSTANCE.isEnabled()) {
player.sendMessage(ErrorMessages.User.configurationError(
player.sendMessage(Errors.User.configurationError(
"the item has a price, but Vault with a compatible economy plugin was not found. "
+ "For security, the action has been blocked"));
return false;
@ -42,7 +42,7 @@ public class RequiredMoney implements Requirement {
boolean success = VaultEconomyHook.takeMoney(player, moneyAmount);
if (!success) {
player.sendMessage(ErrorMessages.User.configurationError("a money transaction couldn't be executed"));
player.sendMessage(Errors.User.configurationError("a money transaction couldn't be executed"));
}
return success;

View File

@ -15,7 +15,7 @@ import me.filoghost.chestcommands.legacy.v4_0.v4_0_MenuNodeExpandUpgradeTask;
import me.filoghost.chestcommands.legacy.v4_0.v4_0_MenuNodeRenameUpgradeTask;
import me.filoghost.chestcommands.legacy.v4_0.v4_0_PlaceholdersFileUpgradeTask;
import me.filoghost.chestcommands.legacy.v4_0.v4_0_SettingsUpgradeTask;
import me.filoghost.chestcommands.logging.ErrorMessages;
import me.filoghost.chestcommands.logging.Errors;
import me.filoghost.commons.collection.CollectionUtils;
import me.filoghost.commons.config.ConfigLoader;
import me.filoghost.commons.logging.Log;
@ -68,7 +68,7 @@ public class UpgradeList {
try {
return configManager.getMenuFiles();
} catch (IOException e) {
throw new UpgradeTaskException(ErrorMessages.Upgrade.menuListIOException, e);
throw new UpgradeTaskException(Errors.Upgrade.menuListIOException, e);
}
}

View File

@ -9,7 +9,7 @@ import me.filoghost.chestcommands.config.ConfigManager;
import me.filoghost.chestcommands.legacy.upgrade.Upgrade;
import me.filoghost.chestcommands.legacy.upgrade.UpgradeTask;
import me.filoghost.chestcommands.legacy.upgrade.UpgradeTaskException;
import me.filoghost.chestcommands.logging.ErrorMessages;
import me.filoghost.chestcommands.logging.Errors;
import me.filoghost.commons.logging.ErrorCollector;
import me.filoghost.commons.logging.Log;
@ -35,7 +35,7 @@ public class UpgradesExecutor {
upgradesDoneRegistry = new UpgradesDoneRegistry(upgradesDoneFile);
} catch (IOException e) {
// Upgrades can't proceed if metadata file is not read correctly
throw new UpgradeExecutorException(ErrorMessages.Upgrade.metadataReadError(upgradesDoneFile), e);
throw new UpgradeExecutorException(Errors.Upgrade.metadataReadError(upgradesDoneFile), e);
}
if (isFreshInstall) {
@ -51,7 +51,7 @@ public class UpgradesExecutor {
upgradesDoneRegistry.save();
} catch (IOException e) {
// Upgrades can't proceed if metadata file is not saved correctly
throw new UpgradeExecutorException(ErrorMessages.Upgrade.metadataSaveError(upgradesDoneFile), e);
throw new UpgradeExecutorException(Errors.Upgrade.metadataSaveError(upgradesDoneFile), e);
}
return allUpgradesSuccessful;
@ -81,7 +81,7 @@ public class UpgradesExecutor {
try {
upgradeTasks = upgrade.createUpgradeTasks(configManager);
} catch (UpgradeTaskException e) {
errorCollector.add(e, ErrorMessages.Upgrade.failedToPrepareUpgradeTasks);
errorCollector.add(e, Errors.Upgrade.failedToPrepareUpgradeTasks);
return false;
}
@ -94,7 +94,7 @@ public class UpgradesExecutor {
}
} catch (UpgradeTaskException e) {
allTasksSuccessful = false;
errorCollector.add(e, ErrorMessages.Upgrade.failedSingleUpgrade(upgradeTask.getOriginalFile()));
errorCollector.add(e, Errors.Upgrade.failedSingleUpgrade(upgradeTask.getOriginalFile()));
}
}

View File

@ -6,7 +6,7 @@
package me.filoghost.chestcommands.legacy.upgrade;
import me.filoghost.chestcommands.legacy.Backup;
import me.filoghost.chestcommands.logging.ErrorMessages;
import me.filoghost.chestcommands.logging.Errors;
import me.filoghost.commons.Preconditions;
import me.filoghost.commons.config.exception.ConfigLoadException;
import me.filoghost.commons.config.exception.ConfigSaveException;
@ -30,20 +30,20 @@ public abstract class UpgradeTask {
try {
computeChanges();
} catch (ConfigLoadException e) {
throw new UpgradeTaskException(ErrorMessages.Upgrade.loadError(getOriginalFile()), e);
throw new UpgradeTaskException(Errors.Upgrade.loadError(getOriginalFile()), e);
}
if (saveRequired) {
try {
backup.addFile(getOriginalFile());
} catch (IOException e) {
throw new UpgradeTaskException(ErrorMessages.Upgrade.backupError(getOriginalFile()), e);
throw new UpgradeTaskException(Errors.Upgrade.backupError(getOriginalFile()), e);
}
try {
saveChanges();
} catch (ConfigSaveException e) {
throw new UpgradeTaskException(ErrorMessages.Upgrade.saveError(getUpgradedFile()), e);
throw new UpgradeTaskException(Errors.Upgrade.saveError(getUpgradedFile()), e);
}
return true;

View File

@ -12,7 +12,7 @@ import org.bukkit.ChatColor;
import java.nio.file.Path;
public class ErrorMessages {
public class Errors {
public static class Config {
@ -207,7 +207,7 @@ public class ErrorMessages {
public static String notifyStaffRequest = "Please inform the staff.";
public static String configurationError(String errorMessage) {
return ChatColor.RED + "Error: " + errorMessage + ". " + ErrorMessages.User.notifyStaffRequest;
return ChatColor.RED + "Error: " + errorMessage + ". " + Errors.User.notifyStaffRequest;
}
}

View File

@ -7,7 +7,7 @@ package me.filoghost.chestcommands.menu;
import me.filoghost.chestcommands.inventory.DefaultMenuInventory;
import me.filoghost.chestcommands.inventory.MenuInventoryHolder;
import me.filoghost.chestcommands.logging.ErrorMessages;
import me.filoghost.chestcommands.logging.Errors;
import me.filoghost.chestcommands.parsing.menu.LoadedMenu;
import me.filoghost.chestcommands.parsing.menu.MenuOpenItem;
import me.filoghost.commons.collection.CaseInsensitiveMap;
@ -51,7 +51,7 @@ public class MenuManager {
String fileName = loadedMenu.getSourceFile().getFileName().toString();
InternalIconMenu sameNameMenu = menusByFile.get(fileName);
if (sameNameMenu != null) {
errorCollector.add(ErrorMessages.Menu.duplicateMenuName(sameNameMenu.getSourceFile(), loadedMenu.getSourceFile()));
errorCollector.add(Errors.Menu.duplicateMenuName(sameNameMenu.getSourceFile(), loadedMenu.getSourceFile()));
}
menusByFile.put(fileName, menu);
@ -60,7 +60,7 @@ public class MenuManager {
if (!openCommand.isEmpty()) {
InternalIconMenu sameCommandMenu = menusByOpenCommand.get(openCommand);
if (sameCommandMenu != null) {
errorCollector.add(ErrorMessages.Menu.duplicateMenuCommand(sameCommandMenu.getSourceFile(), loadedMenu.getSourceFile(), openCommand));
errorCollector.add(Errors.Menu.duplicateMenuCommand(sameCommandMenu.getSourceFile(), loadedMenu.getSourceFile(), openCommand));
}
menusByOpenCommand.put(openCommand, menu);
}

View File

@ -5,7 +5,7 @@
*/
package me.filoghost.chestcommands.parsing;
import me.filoghost.chestcommands.logging.ErrorMessages;
import me.filoghost.chestcommands.logging.Errors;
import me.filoghost.commons.Strings;
import me.filoghost.commons.collection.Registry;
import org.bukkit.enchantments.Enchantment;
@ -55,7 +55,7 @@ public class EnchantmentParser {
try {
level = NumberParser.getStrictlyPositiveInteger(levelSplit[1]);
} catch (ParseException e) {
throw new ParseException(ErrorMessages.Parsing.invalidEnchantmentLevel(levelSplit[1]), e);
throw new ParseException(Errors.Parsing.invalidEnchantmentLevel(levelSplit[1]), e);
}
input = levelSplit[0];
}
@ -65,7 +65,7 @@ public class EnchantmentParser {
if (enchantment.isPresent()) {
return new EnchantmentDetails(enchantment.get(), level);
} else {
throw new ParseException(ErrorMessages.Parsing.unknownEnchantmentType(input));
throw new ParseException(Errors.Parsing.unknownEnchantmentType(input));
}
}

View File

@ -5,7 +5,7 @@
*/
package me.filoghost.chestcommands.parsing;
import me.filoghost.chestcommands.logging.ErrorMessages;
import me.filoghost.chestcommands.logging.Errors;
import me.filoghost.commons.Strings;
import me.filoghost.commons.collection.Registry;
import org.bukkit.Color;
@ -25,7 +25,7 @@ public final class ItemMetaParser {
String[] split = Strings.trimmedSplit(input, ",");
if (split.length != 3) {
throw new ParseException(ErrorMessages.Parsing.invalidColorFormat);
throw new ParseException(Errors.Parsing.invalidColorFormat);
}
int red = parseColor(split[0], "red");
@ -41,11 +41,11 @@ public final class ItemMetaParser {
try {
value = NumberParser.getInteger(valueString);
} catch (ParseException e) {
throw new ParseException(ErrorMessages.Parsing.invalidColorNumber(valueString, colorName), e);
throw new ParseException(Errors.Parsing.invalidColorNumber(valueString, colorName), e);
}
if (value < 0 || value > 255) {
throw new ParseException(ErrorMessages.Parsing.invalidColorRange(valueString, colorName));
throw new ParseException(Errors.Parsing.invalidColorRange(valueString, colorName));
}
return value;
@ -53,17 +53,17 @@ public final class ItemMetaParser {
public static DyeColor parseDyeColor(String input) throws ParseException {
return DYE_COLORS_REGISTRY.find(input)
.orElseThrow(() -> new ParseException(ErrorMessages.Parsing.unknownDyeColor(input)));
.orElseThrow(() -> new ParseException(Errors.Parsing.unknownDyeColor(input)));
}
public static Pattern parseBannerPattern(String input) throws ParseException {
String[] split = Strings.trimmedSplit(input, ":");
if (split.length != 2) {
throw new ParseException(ErrorMessages.Parsing.invalidPatternFormat);
throw new ParseException(Errors.Parsing.invalidPatternFormat);
}
PatternType patternType = PATTERN_TYPES_REGISTRY.find(split[0])
.orElseThrow(() -> new ParseException(ErrorMessages.Parsing.unknownPatternType(split[0])));
.orElseThrow(() -> new ParseException(Errors.Parsing.unknownPatternType(split[0])));
DyeColor patternColor = parseDyeColor(split[1]);
return new Pattern(patternColor, patternType);

View File

@ -5,7 +5,7 @@
*/
package me.filoghost.chestcommands.parsing;
import me.filoghost.chestcommands.logging.ErrorMessages;
import me.filoghost.chestcommands.logging.Errors;
import me.filoghost.commons.MaterialsHelper;
import me.filoghost.commons.Preconditions;
import me.filoghost.commons.Strings;
@ -33,7 +33,7 @@ public class ItemStackParser {
try {
this.amount = NumberParser.getStrictlyPositiveInteger(splitAmount[1]);
} catch (ParseException e) {
throw new ParseException(ErrorMessages.Parsing.invalidAmount(splitAmount[1]), e);
throw new ParseException(Errors.Parsing.invalidAmount(splitAmount[1]), e);
}
// Only keep the first part as input
@ -49,7 +49,7 @@ public class ItemStackParser {
try {
this.durability = NumberParser.getPositiveShort(splitByColons[1]);
} catch (ParseException e) {
throw new ParseException(ErrorMessages.Parsing.invalidDurability(splitByColons[1]), e);
throw new ParseException(Errors.Parsing.invalidDurability(splitByColons[1]), e);
}
this.hasExplicitDurability = true;
@ -63,7 +63,7 @@ public class ItemStackParser {
public void checkNotAir() throws ParseException {
if (MaterialsHelper.isAir(material)) {
throw new ParseException(ErrorMessages.Parsing.materialCannotBeAir);
throw new ParseException(Errors.Parsing.materialCannotBeAir);
}
}

View File

@ -1,6 +1,6 @@
package me.filoghost.chestcommands.parsing;
import me.filoghost.chestcommands.logging.ErrorMessages;
import me.filoghost.chestcommands.logging.Errors;
import me.filoghost.commons.MaterialsHelper;
import org.bukkit.Material;
@ -8,7 +8,7 @@ public class MaterialParser {
public static Material parseMaterial(String materialName) throws ParseException {
return MaterialsHelper.matchMaterial(materialName)
.orElseThrow(() -> new ParseException(ErrorMessages.Parsing.unknownMaterial(materialName)));
.orElseThrow(() -> new ParseException(Errors.Parsing.unknownMaterial(materialName)));
}
}

View File

@ -5,13 +5,13 @@
*/
package me.filoghost.chestcommands.parsing;
import me.filoghost.chestcommands.logging.ErrorMessages;
import me.filoghost.chestcommands.logging.Errors;
public class NumberParser {
public static double getStrictlyPositiveDouble(String input) throws ParseException {
double value = getDouble(input);
check(value > 0.0, ErrorMessages.Parsing.strictlyPositive);
check(value > 0.0, Errors.Parsing.strictlyPositive);
return value;
}
@ -19,7 +19,7 @@ public class NumberParser {
try {
return Double.parseDouble(input);
} catch (NumberFormatException ex) {
throw new ParseException(ErrorMessages.Parsing.invalidDecimal);
throw new ParseException(Errors.Parsing.invalidDecimal);
}
}
@ -27,13 +27,13 @@ public class NumberParser {
try {
return Float.parseFloat(input);
} catch (NumberFormatException ex) {
throw new ParseException(ErrorMessages.Parsing.invalidDecimal);
throw new ParseException(Errors.Parsing.invalidDecimal);
}
}
public static short getPositiveShort(String input) throws ParseException {
short value = getShort(input);
check(value >= 0, ErrorMessages.Parsing.zeroOrPositive);
check(value >= 0, Errors.Parsing.zeroOrPositive);
return value;
}
@ -41,13 +41,13 @@ public class NumberParser {
try {
return Short.parseShort(input);
} catch (NumberFormatException ex) {
throw new ParseException(ErrorMessages.Parsing.invalidShort);
throw new ParseException(Errors.Parsing.invalidShort);
}
}
public static int getStrictlyPositiveInteger(String input) throws ParseException {
int value = getInteger(input);
check(value > 0, ErrorMessages.Parsing.strictlyPositive);
check(value > 0, Errors.Parsing.strictlyPositive);
return value;
}
@ -55,7 +55,7 @@ public class NumberParser {
try {
return Integer.parseInt(input);
} catch (NumberFormatException ex) {
throw new ParseException(ErrorMessages.Parsing.invalidInteger);
throw new ParseException(Errors.Parsing.invalidInteger);
}
}

View File

@ -8,7 +8,7 @@ package me.filoghost.chestcommands.parsing.icon;
import me.filoghost.chestcommands.attribute.AttributeErrorHandler;
import me.filoghost.chestcommands.attribute.IconAttribute;
import me.filoghost.chestcommands.icon.InternalConfigurableIcon;
import me.filoghost.chestcommands.logging.ErrorMessages;
import me.filoghost.chestcommands.logging.Errors;
import me.filoghost.chestcommands.parsing.ParseException;
import me.filoghost.commons.config.ConfigSection;
import me.filoghost.commons.config.ConfigValue;
@ -51,11 +51,11 @@ public class IconSettings {
try {
AttributeType attributeType = AttributeType.fromAttributeName(attributeName);
if (attributeType == null) {
throw new ParseException(ErrorMessages.Parsing.unknownAttribute);
throw new ParseException(Errors.Parsing.unknownAttribute);
}
AttributeErrorHandler errorHandler = (String listElement, ParseException e) -> {
errorCollector.add(e, ErrorMessages.Menu.invalidAttributeListElement(this, attributeName, listElement));
errorCollector.add(e, Errors.Menu.invalidAttributeListElement(this, attributeName, listElement));
};
ConfigValue configValue = config.get(attributeName);
@ -63,7 +63,7 @@ public class IconSettings {
attributes.put(attributeType, iconAttribute);
} catch (ParseException | ConfigValueException e) {
errorCollector.add(e, ErrorMessages.Menu.invalidAttribute(this, attributeName));
errorCollector.add(e, Errors.Menu.invalidAttribute(this, attributeName));
}
}
}

View File

@ -8,7 +8,7 @@ package me.filoghost.chestcommands.parsing.menu;
import me.filoghost.chestcommands.action.Action;
import me.filoghost.chestcommands.action.DisabledAction;
import me.filoghost.chestcommands.attribute.PositionAttribute;
import me.filoghost.chestcommands.logging.ErrorMessages;
import me.filoghost.chestcommands.logging.Errors;
import me.filoghost.chestcommands.menu.InternalIconMenu;
import me.filoghost.chestcommands.parsing.ActionParser;
import me.filoghost.chestcommands.parsing.ItemStackParser;
@ -52,12 +52,12 @@ public class MenuParser {
PositionAttribute positionY = (PositionAttribute) iconSettings.getAttributeValue(AttributeType.POSITION_Y);
if (positionX == null) {
errorCollector.add(ErrorMessages.Menu.missingAttribute(iconSettings, AttributeType.POSITION_X));
errorCollector.add(Errors.Menu.missingAttribute(iconSettings, AttributeType.POSITION_X));
return;
}
if (positionY == null) {
errorCollector.add(ErrorMessages.Menu.missingAttribute(iconSettings, AttributeType.POSITION_Y));
errorCollector.add(Errors.Menu.missingAttribute(iconSettings, AttributeType.POSITION_Y));
return;
}
@ -66,23 +66,23 @@ public class MenuParser {
if (row < 0 || row >= iconMenu.getRowCount()) {
errorCollector.add(
ErrorMessages.Menu.invalidAttribute(iconSettings, AttributeType.POSITION_Y),
Errors.Menu.invalidAttribute(iconSettings, AttributeType.POSITION_Y),
"it must be between 1 and " + iconMenu.getRowCount());
return;
}
if (column < 0 || column >= iconMenu.getColumnCount()) {
errorCollector.add(
ErrorMessages.Menu.invalidAttribute(iconSettings, AttributeType.POSITION_X),
Errors.Menu.invalidAttribute(iconSettings, AttributeType.POSITION_X),
"it must be between 1 and " + iconMenu.getColumnCount());
return;
}
if (iconMenu.getIcon(row, column) != null) {
errorCollector.add(ErrorMessages.Menu.iconOverridesAnother(iconSettings));
errorCollector.add(Errors.Menu.iconOverridesAnother(iconSettings));
}
if (iconSettings.getAttributeValue(AttributeType.MATERIAL) == null) {
errorCollector.add(ErrorMessages.Menu.missingAttribute(iconSettings, AttributeType.MATERIAL));
errorCollector.add(Errors.Menu.missingAttribute(iconSettings, AttributeType.MATERIAL));
}
iconMenu.setIcon(row, column, iconSettings.createIcon());
@ -92,7 +92,7 @@ public class MenuParser {
private static MenuSettings loadMenuSettings(Config config, ErrorCollector errorCollector) {
ConfigSection settingsSection = config.getConfigSection(MenuSettingsNode.ROOT_SECTION);
if (settingsSection == null) {
errorCollector.add(ErrorMessages.Menu.missingSettingsSection(config.getSourceFile()));
errorCollector.add(Errors.Menu.missingSettingsSection(config.getSourceFile()));
settingsSection = new EmptyConfigSection();
}
@ -133,9 +133,9 @@ public class MenuParser {
try {
openActions.add(ActionParser.parse(serializedAction));
} catch (ParseException e) {
errorCollector.add(e, ErrorMessages.Menu.invalidSettingListElement(
errorCollector.add(e, Errors.Menu.invalidSettingListElement(
config.getSourceFile(), MenuSettingsNode.OPEN_ACTIONS, serializedAction));
openActions.add(new DisabledAction(ErrorMessages.User.configurationError(
openActions.add(new DisabledAction(Errors.User.configurationError(
"an action linked to opening this menu was not executed because it was not valid")));
}
}
@ -164,7 +164,7 @@ public class MenuParser {
menuSettings.setOpenItem(openItem);
} catch (ParseException e) {
errorCollector.add(e, ErrorMessages.Menu.invalidSetting(config.getSourceFile(), MenuSettingsNode.OPEN_ITEM_MATERIAL));
errorCollector.add(e, Errors.Menu.invalidSetting(config.getSourceFile(), MenuSettingsNode.OPEN_ITEM_MATERIAL));
}
}
}
@ -182,9 +182,9 @@ public class MenuParser {
private static void addMenuSettingError(ErrorCollector errorCollector, Config config, String missingSetting, ConfigValueException e) {
if (e instanceof MissingConfigValueException) {
errorCollector.add(ErrorMessages.Menu.missingSetting(config.getSourceFile(), missingSetting));
errorCollector.add(Errors.Menu.missingSetting(config.getSourceFile(), missingSetting));
} else {
errorCollector.add(e, ErrorMessages.Menu.invalidSetting(config.getSourceFile(), missingSetting));
errorCollector.add(e, Errors.Menu.invalidSetting(config.getSourceFile(), missingSetting));
}
}