Separated messages from the config.

* We always generate an 'en-default' language file. This file acts as a
template for custom language files. It is not meant to be modified and
is replaced with an up-to-date version on every plugin startup.
* Config: Changed the default language from 'en' to 'en-default'.
Existing configs get automatically migrated.
* Fixed: Text#parse can now also parse alternative color codes starting
with '&'. This has an effect when some messages of the specified
language file cannot be loaded and the plugin then uses the default
messages instead. This is part of Text#parse now (instead of requiring a
separate color conversion) for convenience reasons.
* Added warning output when the language file misses messages, or
contains unexpected messages.
* All message keys were changed to no longer start with the 'msg'
prefix.
master
blablubbabc 2020-11-21 18:51:18 +01:00
parent a92a6e7d7d
commit 4080de2387
91 changed files with 1277 additions and 1108 deletions

View File

@ -1,15 +1,23 @@
# Changelog
Date format: (YYYY-MM-DD)
## v2.12.1 (TBA)
## v2.13.0 (TBA)
### Supported MC versions: 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.15.2, 1.14.4
* Messages have been separated from the config.
* We always generate an 'en-default' language file. This file acts as a template for custom language files. It is not meant to be modified and is replaced with an up-to-date version on every plugin startup.
* Config: Changed the default language from 'en' to 'en-default'. Existing configs get automatically migrated.
* Fixed: Text#parse can now also parse alternative color codes starting with '&'. This has an effect when some messages of the specified language file cannot be loaded and the plugin then uses the default messages instead.
* Added warning output when the language file misses messages, or contains unexpected messages.
Migration notes:
* The folder structure has changed:
* The save file and trading logs (if enabled) are stored inside a new 'data' folder now.
* If no save file exists at the new location and a previous save file is found at the old location, it is automatically moved.
* Custom language files need to be located inside a new 'lang' folder now.
* Existing custom language files need to be manually moved!
* Language files are located inside a new 'lang' folder now. Existing custom language files need to be manually moved!
Messages:
* All message keys were changed to no longer start with the 'msg' prefix. You will have to manually update your custom language files to adapt for this change.
## v2.12.0 (2020-11-04)
### Supported MC versions: 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.15.2, 1.14.4

View File

@ -0,0 +1,399 @@
package com.nisovin.shopkeepers;
import static com.nisovin.shopkeepers.config.ConfigHelper.loadConfigValue;
import static com.nisovin.shopkeepers.config.ConfigHelper.toConfigKey;
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.file.YamlConfiguration;
import com.nisovin.shopkeepers.config.ConfigLoadException;
import com.nisovin.shopkeepers.text.Text;
import com.nisovin.shopkeepers.util.Log;
public class Messages {
// TODO Replace all with Text? Will require converting back to String, especially for texts used by items.
public static String shopTypeAdminRegular = "Admin shop";
public static String shopTypeSelling = "Selling shop";
public static String shopTypeBuying = "Buying shop";
public static String shopTypeTrading = "Trading shop";
public static String shopTypeBook = "Book shop";
public static String shopTypeDescAdminRegular = "has unlimited stock";
public static String shopTypeDescSelling = "sells items to players";
public static String shopTypeDescBuying = "buys items from players";
public static String shopTypeDescTrading = "trades items with players";
public static String shopTypeDescBook = "sells book copies";
public static String shopObjectTypeLiving = "{type}";
public static String shopObjectTypeSign = "sign";
public static String shopObjectTypeNpc = "npc";
public static Text selectedShopType = Text.parse("&aSelected shop type: &6{type} &7({description})");
public static Text selectedShopObjectType = Text.parse("&aSelected object type: &6{type}");
public static Text creationItemSelected = Text.parse("&aShop creation:\n"
+ "&e Left/Right-click to select the shop type.\n"
+ "&e Sneak + left/right-click to select the object type.\n"
+ "&e Right-click a container to select it.\n"
+ "&e Then right-click a block to place the shopkeeper.");
public static String buttonPreviousPage = "&6<- Previous page ({prev_page} of {max_page})";
public static List<String> buttonPreviousPageLore = Arrays.asList();
public static String buttonNextPage = "&6Next page ({next_page} of {max_page}) ->";
public static List<String> buttonNextPageLore = Arrays.asList();
public static String buttonCurrentPage = "&6Page {page} of {max_page}";
public static List<String> buttonCurrentPageLore = Arrays.asList();
public static String buttonName = "&aSet shop name";
public static List<String> buttonNameLore = Arrays.asList("Lets you rename", "your shopkeeper");
public static String buttonContainer = "&aView shop inventory";
public static List<String> buttonContainerLore = Arrays.asList("Lets you view the inventory", " your shopkeeper is using");
public static String buttonDelete = "&4Delete";
public static List<String> buttonDeleteLore = Arrays.asList("Closes and removes", "this shopkeeper");
public static String buttonHire = "&aHire";
public static List<String> buttonHireLore = Arrays.asList("Buy this shop");
public static String buttonSignVariant = "&aChoose sign variant";
public static List<String> buttonSignVariantLore = Arrays.asList("Changes the sign's", "wood type");
public static String buttonBaby = "&aToggle baby variant";
public static List<String> buttonBabyLore = Arrays.asList("Toggles between the mob's", "baby and adult variant");
public static String buttonSitting = "&aToggle sitting pose";
public static List<String> buttonSittingLore = Arrays.asList("Toggles the mob's", "sitting pose");
public static String buttonCatVariant = "&aChoose cat variant";
public static List<String> buttonCatVariantLore = Arrays.asList("Changes the cat's look");
public static String buttonRabbitVariant = "&aChoose rabbit variant";
public static List<String> buttonRabbitVariantLore = Arrays.asList("Changes the rabbit's look");
public static String buttonCollarColor = "&aChoose collar color";
public static List<String> buttonCollarColorLore = Arrays.asList("Changes the mob's", "collar color");
public static String buttonWolfAngry = "&aToggle angry wolf";
public static List<String> buttonWolfAngryLore = Arrays.asList("Toggles the wolf's", "angry state");
public static String buttonCarryingChest = "&aToggle carrying chest";
public static List<String> buttonCarryingChestLore = Arrays.asList("Toggles whether the mob", "is carrying a chest");
public static String buttonHorseColor = "&aChoose horse color";
public static List<String> buttonHorseColorLore = Arrays.asList("Changes the color", "of the horse");
public static String buttonHorseStyle = "&aChoose horse style";
public static List<String> buttonHorseStyleLore = Arrays.asList("Changes the coat pattern", "of the horse");
public static String buttonHorseArmor = "&aChoose horse armor";
public static List<String> buttonHorseArmorLore = Arrays.asList("Changes the armor", "of the horse");
public static String buttonLlamaVariant = "&aChoose llama variant";
public static List<String> buttonLlamaVariantLore = Arrays.asList("Changes the llama's look");
public static String buttonLlamaCarpetColor = "&aLlama carpet color";
public static List<String> buttonLlamaCarpetColorLore = Arrays.asList("Changes the llama's", "carpet color");
public static String buttonCreeperCharged = "&aToggle charged creeper";
public static List<String> buttonCreeperChargedLore = Arrays.asList("Toggles the creeper's", "charged state");
public static String buttonFoxVariant = "&aChoose fox variant";
public static List<String> buttonFoxVariantLore = Arrays.asList("Changes the fox's look");
public static String buttonFoxCrouching = "&aToggle crouching pose";
public static List<String> buttonFoxCrouchingLore = Arrays.asList("Toggles the fox's", "crouching pose");
public static String buttonFoxSleeping = "&aToggle sleeping pose";
public static List<String> buttonFoxSleepingLore = Arrays.asList("Toggles the fox's", "sleeping pose");
public static String buttonMooshroomVariant = "&aChoose mooshroom variant";
public static List<String> buttonMooshroomVariantLore = Arrays.asList("Changes the look", "of the mooshroom");
public static String buttonPandaVariant = "&aChoose panda variant";
public static List<String> buttonPandaVariantLore = Arrays.asList("Changes the panda's look");
public static String buttonParrotVariant = "&aChoose parrot variant";
public static List<String> buttonParrotVariantLore = Arrays.asList("Changes the parrot's look");
public static String buttonPigSaddle = "&aToggle pig saddle";
public static List<String> buttonPigSaddleLore = Arrays.asList("Toggles the pig's saddle");
public static String buttonSheepColor = "&aChoose sheep color";
public static List<String> buttonSheepColorLore = Arrays.asList("Changes the sheep's", "wool color");
public static String buttonSheepSheared = "&aToggle sheared sheep";
public static List<String> buttonSheepShearedLore = Arrays.asList("Toggles the sheep's", "sheared state");
public static String buttonVillagerProfession = "&aChoose villager profession";
public static List<String> buttonVillagerProfessionLore = Arrays.asList("Changes the profession", "of the villager");
public static String buttonVillagerVariant = "&aChoose villager variant";
public static List<String> buttonVillagerVariantLore = Arrays.asList("Changes the look", "of the villager");
public static String buttonVillagerLevel = "&aChoose villager badge color";
public static List<String> buttonVillagerLevelLore = Arrays.asList("Changes the badge color", "of the villager");
public static String buttonZombieVillagerProfession = "&aChoose villager profession";
public static List<String> buttonZombieVillagerProfessionLore = Arrays.asList("Changes the profession", "of the zombie villager");
public static String buttonSlimeSize = "&aChoose slime size";
public static List<String> buttonSlimeSizeLore = Arrays.asList("Cycles the slime's size.", "Current size: &e{size}");
public static String buttonMagmaCubeSize = "&aChoose magma cube size";
public static List<String> buttonMagmaCubeSizeLore = Arrays.asList("Cycles the magma cube's size.", "Current size: &e{size}");
public static String tradingTitlePrefix = "&2";
public static String tradingTitleDefault = "Shopkeeper";
public static Text containerSelected = Text.parse("&aContainer selected! Right-click a block to place your shopkeeper.");
public static Text unsupportedContainer = Text.parse("&7This type of container cannot be used for shops.");
public static Text mustSelectContainer = Text.parse("&7You must right-click a container before placing your shopkeeper.");
public static Text invalidContainer = Text.parse("&7The selected block is not a valid container!");
public static Text containerTooFarAway = Text.parse("&7The shopkeeper's container is too far away!");
public static Text containerNotPlaced = Text.parse("&7You must select a container you have recently placed!");
public static Text containerAlreadyInUse = Text.parse("&7Another shopkeeper is already using the selected container!");
public static Text noContainerAccess = Text.parse("&7You cannot access the selected container!");
public static Text tooManyShops = Text.parse("&7You have too many shops!");
public static Text noAdminShopTypeSelected = Text.parse("&7You have to select an admin shop type!");
public static Text noPlayerShopTypeSelected = Text.parse("&7You have to select a player shop type!");
public static Text shopCreateFail = Text.parse("&7You cannot create a shopkeeper there.");
public static Text typeNewName = Text.parse("&aPlease type the shop's name into the chat.\n"
+ " &aType a dash (-) to remove the name.");
public static Text nameSet = Text.parse("&aThe shop's name has been set!");
public static Text nameHasNotChanged = Text.parse("&aThe shop's name has not changed.");
public static Text nameInvalid = Text.parse("&aThat name is not valid!");
public static Text shopTypeDisabled = Text.parse("&7The shop type '&6{type}&7' is disabled.");
public static Text shopObjectTypeDisabled = Text.parse("&7The shop object type '&6{type}&7' is disabled.");
public static Text mustTargetShop = Text.parse("&7You have to target a shopkeeper.");
public static Text mustTargetAdminShop = Text.parse("&7You have to target an admin shopkeeper.");
public static Text mustTargetPlayerShop = Text.parse("&7You have to target a player shopkeeper.");
public static Text targetEntityIsNoShop = Text.parse("&7The targeted entity is no shopkeeper.");
public static Text targetShopIsNoAdminShop = Text.parse("&7The targeted shopkeeper is no admin shopkeeper.");
public static Text targetShopIsNoPlayerShop = Text.parse("&7The targeted shopkeeper is no player shopkeeper.");
public static Text unusedContainer = Text.parse("&7No shopkeeper is using this container.");
public static Text notOwner = Text.parse("&7You are not the owner of this shopkeeper.");
// Placeholders: {owner} -> new owners name
public static Text ownerSet = Text.parse("&aNew owner was set to &e{owner}");
public static Text shopCreationItemsGiven = Text.parse("&aPlayer &e{player}&a has received &e{amount}&a shop creation item(s)!");
public static Text shopCreationItemsReceived = Text.parse("&aYou have received &e{amount}&a shop creation item(s)!");
public static Text currencyItemsGiven = Text.parse("&aPlayer &e{player}&a has received &e{amount}&a currency item(s)!");
public static Text currencyItemsReceived = Text.parse("&aYou have received &e{amount}&a currency item(s)!");
public static Text highCurrencyItemsGiven = Text.parse("&aPlayer &e{player}&a has received &e{amount}&a high currency item(s)!");
public static Text highCurrencyItemsReceived = Text.parse("&aYou have received &e{amount}&a high currency item(s)!");
public static Text highCurrencyDisabled = Text.parse("&cThe high currency is disabled!");
public static Text itemsConverted = Text.parse("&aConverted &e{count}&a item stack(s)!");
public static String unknownBookAuthor = "Unknown";
public static Text tradePermSet = Text.parse("&aThe shop's trading permission has been set to '&e{perm}&a'!");
public static Text tradePermRemoved = Text.parse("&aThe shop's trading permission '&e{perm}&a' has been removed!");
public static Text tradePermView = Text.parse("&aThe shop's current trading permission is '&e{perm}&a'.");
public static Text zombieVillagerCuringDisabled = Text.parse("&7Curing of zombie villagers is disabled.");
public static Text mustHoldHireItem = Text.parse("&7You have to hold the required hire item in your hand.");
public static Text setForHire = Text.parse("&aThe Shopkeeper was set for hire.");
public static Text hired = Text.parse("&aYou have hired this shopkeeper!");
public static Text missingHirePerm = Text.parse("&7You do not have the permission to hire shopkeepers.");
public static Text cantHire = Text.parse("&aYou cannot afford to hire this shopkeeper.");
public static Text cantHireShopType = Text.parse("&7You do not have the permission to hire this type of shopkeeper.");
// Placeholders: {costs}, {hire-item}
public static Text villagerForHire = Text.parse("&aThe villager offered his services as a shopkeeper in exchange for &6{costs}x {hire-item}&a.");
public static Text missingTradePerm = Text.parse("&7You do not have the permission to trade with this shop.");
public static Text missingCustomTradePerm = Text.parse("&7You do not have the permission to trade with this shop.");
public static Text cantTradeWithOwnShop = Text.parse("&7You cannot trade with your own shop.");
public static Text cantTradeWhileOwnerOnline = Text.parse("&7You cannot trade while the owner of this shop ('&e{owner}&7') is online.");
public static Text cantTradeWithShopMissingContainer = Text.parse("&7You cannot trade with this shop, because its container is missing.");
public static Text shopkeeperCreated = Text.parse("&aShopkeeper created: &6{type} &7({description})\n{setupDesc}");
public static String shopSetupDescSelling = "&e Add items you want to sell to your container, then\n"
+ "&e right-click the shop while sneaking to modify costs.";
public static String shopSetupDescBuying = "&e Add one of each item you want to buy to your container,\n"
+ "&e then right-click the shop while sneaking to modify costs.";
public static String shopSetupDescTrading = "&e Add items you want to sell to your container, then\n"
+ "&e right-click the shop while sneaking to modify costs.";
public static String shopSetupDescBook = "&e Add written books and blank books to your container, then\n"
+ "&e right-click the shop while sneaking to modify costs.";
public static String shopSetupDescAdminRegular = "&e Right-click the shop while sneaking to modify trades.";
public static String tradeSetupDescHeader = "&6{shopType}";
public static List<String> tradeSetupDescAdminRegular = Arrays.asList("Has unlimited stock.", "Insert items from your inventory.", "Top row: Result items", "Bottom rows: Cost items");
public static List<String> tradeSetupDescSelling = Arrays.asList("Sells items.", "Insert items to sell into the container.", "Left/Right click to adjust amounts.", "Top row: Items being sold", "Bottom rows: Cost items");
public static List<String> tradeSetupDescBuying = Arrays.asList("Buys items.", "Insert one of each item you want to", "buy and plenty of currency items", "into the container.", "Left/Right click to adjust amounts.", "Top row: Cost items", "Bottom row: Items being bought");
public static List<String> tradeSetupDescTrading = Arrays.asList("Trades items.", "Pickup an item from your inventory", "and then click a slot to place it.", "Left/Right click to adjust amounts.", "Top row: Result items", "Bottom rows: Cost items");
public static List<String> tradeSetupDescBook = Arrays.asList("Sells book copies.", "Insert written and blank books", "into the container.", "Left/Right click to adjust costs.", "Top row: Books being sold", "Bottom rows: Cost items");
public static Text missingEditVillagersPerm = Text.parse("&7You do not have the permission to edit villagers.");
public static Text missingEditWanderingTradersPerm = Text.parse("&7You do not have the permission to edit wandering traders.");
public static Text mustTargetEntity = Text.parse("&7You have to target an entity.");
public static Text mustTargetVillager = Text.parse("&7You have to target a villager.");
public static Text targetEntityIsNoVillager = Text.parse("&7The targeted entity is no regular villager.");
public static String villagerEditorTitle = "&aVillager Editor: &e{villagerName}";
public static String villagerEditorDescriptionHeader = "&6Villager Editor";
public static List<String> villagerEditorDescription = Arrays.asList(
"Top row: Result items",
"Bottom rows: Cost items",
"Edited trades have infinite",
"uses and no XP rewards."
);
public static String buttonDeleteVillager = "&4Delete";
public static List<String> buttonDeleteVillagerLore = Arrays.asList("Deletes the villager");
public static String buttonVillagerInventory = "&aView villager inventory";
public static List<String> buttonVillagerInventoryLore = Arrays.asList(
"Lets you view a copy of",
"the villager's inventory"
);
public static String buttonMobAi = "&aToggle mob AI";
public static List<String> buttonMobAiLore = Arrays.asList("Toggles the mob's AI");
public static String villagerInventoryTitle = "Villager inventory (copy)";
public static String setVillagerXp = "&aSet the villager's XP to &e{xp}";
public static String noVillagerTradesChanged = "&aNo trades have been changed.";
public static String villagerTradesChanged = "&e{changedTrades}&a trades have been changed.";
public static Text listAdminShopsHeader = Text.parse("&9There are &e{shopsCount} &9admin shops: &e(Page {page} of {maxPage})");
public static Text listAllShopsHeader = Text.parse("&9There are &e{shopsCount} &9shops in total: &e(Page {page} of {maxPage})");
public static Text listPlayerShopsHeader = Text.parse("&9Player '&e{player}&9' has &e{shopsCount} &9shops: &e(Page {page} of {maxPage})");
public static Text listShopsEntry = Text.parse(" &e{shopId}) &7{shopName}&r&8at &7({location})&8, type: &7{shopType}&8, object: &7{objectType}");
public static Text removedAdminShops = Text.parse("&e{shopsCount} &aadmin shops were removed.");
public static Text removedShopsOfPlayer = Text.parse("&e{shopsCount} &ashops of player '&e{player}&a' were removed.");
public static Text removedPlayerShops = Text.parse("&e{shopsCount} &aplayer shops were removed.");
public static Text confirmRemoveAllAdminShops = Text.parse("&cYou are about to irrevocable remove all admin shops (&6{shopsCount}&c)!");
public static Text confirmRemoveAllOwnShops = Text.parse("&cYou are about to irrevocable remove all your shops (&6{shopsCount}&c)!");
public static Text confirmRemoveAllShopsOfPlayer = Text.parse("&cYou are about to irrevocable remove all shops of player &6{player}&c (&6{shopsCount}&c)!");
public static Text confirmRemoveAllPlayerShops = Text.parse("&cYou are about to irrevocable remove all player shops of all players (&6{shopsCount}&c)!");
public static Text confirmationRequired = Text.parse("&7Please confirm this action by typing &6/shopkeepers confirm");
public static Text confirmationExpired = Text.parse("&cConfirmation expired.");
public static Text nothingToConfirm = Text.parse("&cThere is nothing to confirm currently.");
public static Text noPermission = Text.parse("&cYou don't have the permission to do that.");
public static Text commandUnknown = Text.parse("&cUnknown command '&e{command}&c'!");
public static Text commandArgumentUnexpected = Text.parse("&cUnexpected argument '&e{argument}&c'.");
public static Text commandArgumentRequiresPlayer = Text.parse("&cArgument '&e{argumentFormat}&c' requires a player to execute the command.");
public static Text commandArgumentMissing = Text.parse("&cMissing argument '&e{argumentFormat}&c'.");
public static Text commandArgumentInvalid = Text.parse("&cInvalid argument '&e{argument}&c'.");
public static Text commandPlayerArgumentMissing = Text.parse("&cNo player specified for '&e{argumentFormat}&c'.");
public static Text commandPlayerArgumentInvalid = Text.parse("&cNo player found for '&e{argument}&c'.");
public static Text commandShopTypeArgumentInvalid = Text.parse("&cUnknown shop type '&e{argument}&c'.");
public static Text commandShopObjectTypeArgumentInvalid = Text.parse("&cUnknown shop object type '&e{argument}&c'.");
public static Text commandShopkeeperArgumentInvalid = Text.parse("&cNo shopkeeper found for '&e{argument}&c'.");
public static Text commandShopkeeperArgumentNoAdminShop = Text.parse("&cShopkeeper '&e{argument}&c' is no admin shopkeeper.");
public static Text commandShopkeeperArgumentNoPlayerShop = Text.parse("&cShopkeeper '&e{argument}&c' is no player shopkeeper.");
public static Text ambiguousPlayerName = Text.parse("&cThere are multiple matches for the name '&e{name}&c'!");
public static Text ambiguousPlayerNameEntry = Text.parse("&c - '&e{name}&r&c' (&6{uuid}&c)");
public static Text ambiguousPlayerNameMore = Text.parse("&c ....");
public static Text commandHelpTitle = Text.parse("&9***** &8[&6Shopkeepers v{version}&8] &9*****");
public static Text commandHelpUsageFormat = Text.parse("&e{usage}");
public static Text commandHelpDescriptionFormat = Text.parse("&8 - &3{description}");
public static Text commandDescriptionShopkeeper = Text.parse("Creates a shopkeeper.");
public static Text commandDescriptionHelp = Text.parse("Shows this help page.");
public static Text commandDescriptionReload = Text.parse("Reloads this plugin.");
public static Text commandDescriptionDebug = Text.parse("Toggles debug mode on and off.");
public static Text commandDescriptionList = Text.parse("Lists all shops for the specified player, or all admin shops.");
public static Text commandDescriptionRemove = Text.parse("Removes all shops for the specified player, all players, or all admin shops.");
public static Text commandDescriptionGive = Text.parse("Gives shop creation item(s) to the specified player.");
public static Text commandDescriptionGiveCurrency = Text.parse("Gives currency item(s) to the specified player.");
public static Text commandDescriptionConvertItems = Text.parse("Converts the held (or all) items to conform to Spigot's data format.");
public static Text commandDescriptionRemote = Text.parse("Remotely opens a shop.");
public static Text commandDescriptionRemoteEdit = Text.parse("Remotely edits a shop.");
public static Text commandDescriptionTransfer = Text.parse("Transfers the ownership of a shop.");
public static Text commandDescriptionSettradeperm = Text.parse("Sets, removes (-) or displays (?) the trading permission.");
public static Text commandDescriptionSetforhire = Text.parse("Sets one of your shops for sale.");
public static Text commandDescriptionEditVillager = Text.parse("Opens the editor for the target villager.");
private static final String DEFAULT_LANGUAGE = "en-default";
private static String getLanguageFileName(String language) {
return "language-" + language + ".yml";
}
// Relative to the plugin's data folder:
private static String getLanguageFilePath(String language) {
return SKShopkeepersPlugin.LANG_FOLDER + "/" + getLanguageFileName(language);
}
private static File getLanguageFile(String language) {
String languageFilePath = getLanguageFilePath(language);
return new File(SKShopkeepersPlugin.getInstance().getDataFolder(), languageFilePath);
}
/**
* The default language file is freshly written on every startup and overwrites the already existing default
* language file.
*/
private static void saveDefaultLanguageFile() {
String languageFilePath = getLanguageFilePath(DEFAULT_LANGUAGE);
SKShopkeepersPlugin plugin = SKShopkeepersPlugin.getInstance();
assert plugin.getResource(languageFilePath) != null;
plugin.saveResource(languageFilePath, true);
}
public static void loadLanguageFile() {
// Create default language file:
saveDefaultLanguageFile();
SKShopkeepersPlugin plugin = SKShopkeepersPlugin.getInstance();
String language = Settings.language;
// Create language file if it is missing and there exists a default:
String languageFilePath = getLanguageFilePath(language);
File languageFile = getLanguageFile(language);
if (!languageFile.exists() && plugin.getResource(languageFilePath) != null) {
plugin.saveResource(languageFilePath, false);
}
// Load language config:
if (!languageFile.exists()) {
Log.warning("Could not find language file '" + languageFile.getName() + "'!");
} else {
Log.info("Loading language file: " + languageFile.getName());
try {
YamlConfiguration langConfig = new YamlConfiguration();
langConfig.load(languageFile);
loadLanguageConfiguration(langConfig);
} catch (Exception e) {
Log.warning("Could not load language file '" + languageFile.getName() + "'!", e);
}
}
}
private static void loadLanguageConfiguration(Configuration config) throws ConfigLoadException {
Set<String> messageKeys = new HashSet<>();
try {
Field[] fields = Messages.class.getDeclaredFields();
for (Field field : fields) {
if (field.isSynthetic()) continue;
if (!Modifier.isPublic(field.getModifiers())) {
continue;
}
Class<?> typeClass = field.getType();
Class<?> genericType = null;
if (typeClass == List.class) {
genericType = (Class<?>) ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[0];
}
String configKey = toConfigKey(field.getName());
messageKeys.add(configKey);
if (!config.isSet(configKey)) {
Log.warning(" Missing message: " + configKey);
continue; // Skip, keeps current value (default)
}
Object value = loadConfigValue(config, configKey, Collections.emptySet(), typeClass, genericType);
if (value == null) {
Log.warning(" Could not load message: " + configKey);
continue; // Skip, keeps current value (default)
}
field.set(null, value);
}
} catch (Exception e) {
throw new ConfigLoadException("Error while loading messages from language file!", e);
}
Set<String> configKeys = config.getKeys(false);
if (configKeys.size() != messageKeys.size()) {
for (String configKey : configKeys) {
if (!messageKeys.contains(configKey)) {
Log.warning(" Unknown message: " + configKey);
}
}
}
Settings.onSettingsChanged();
}
private Messages() {
}
}

View File

@ -11,7 +11,6 @@ import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
@ -85,9 +84,10 @@ import com.nisovin.shopkeepers.villagers.VillagerInteractionListener;
public class SKShopkeepersPlugin extends JavaPlugin implements ShopkeepersPlugin {
public static final String DATA_FOLDER = "data";
public static final String LANG_FOLDER = "lang";
private static final int ASYNC_TASKS_TIMEOUT_SECONDS = 10;
private static final String dataFolder = "data";
private static final String langFolder = "lang";
private static SKShopkeepersPlugin plugin;
@ -195,31 +195,6 @@ public class SKShopkeepersPlugin extends JavaPlugin implements ShopkeepersPlugin
return null; // Config loaded successfully
}
private void loadLanguageFile() {
// Load language config:
String lang = Settings.language;
String langFileName = "language-" + lang + ".yml";
File langFile = new File(this.getSKLangFolder(), langFileName);
if (!langFile.exists() && this.getResource(langFileName) != null) {
this.saveResource(langFileName, false);
}
if (!langFile.exists()) {
if (!lang.equals("en")) { // If not default // TODO Don't hardcode
Log.warning("Could not find language file '" + langFile.getPath() + "'!");
} // Else: Ignore.
} else {
Log.info("Loading language file: " + langFileName);
try {
YamlConfiguration langConfig = new YamlConfiguration();
langConfig.load(langFile);
Settings.loadLanguageConfiguration(langConfig);
} catch (Exception e) {
Log.warning("Could not load language file '" + langFile.getPath() + "'!", e);
}
}
}
private void registerDefaults() {
Log.info("Registering defaults.");
uiRegistry.registerAll(defaultUITypes.getAllUITypes());
@ -264,7 +239,7 @@ public class SKShopkeepersPlugin extends JavaPlugin implements ShopkeepersPlugin
this.createFolderStructure();
// Load language file:
this.loadLanguageFile();
Messages.loadLanguageFile();
// WorldGuard only allows registering flags before it gets enabled.
// Note: Changing the config setting has no effect until the next server restart or server reload.
@ -320,7 +295,7 @@ public class SKShopkeepersPlugin extends JavaPlugin implements ShopkeepersPlugin
// Load language file (if not already loaded during onLoad):
if (!alreadySetup) {
this.loadLanguageFile();
Messages.loadLanguageFile();
} else {
Log.debug("Language file already loaded.");
}
@ -557,11 +532,11 @@ public class SKShopkeepersPlugin extends JavaPlugin implements ShopkeepersPlugin
// FOLDER STRUCTURE
public File getSKDataFolder() {
return new File(this.getDataFolder(), dataFolder);
return new File(this.getDataFolder(), DATA_FOLDER);
}
public File getSKLangFolder() {
return new File(this.getDataFolder(), langFolder);
return new File(this.getDataFolder(), LANG_FOLDER);
}
private void createFolderStructure() {

View File

@ -1,16 +1,21 @@
package com.nisovin.shopkeepers;
import static com.nisovin.shopkeepers.config.ConfigHelper.loadConfigValue;
import static com.nisovin.shopkeepers.config.ConfigHelper.setConfigValue;
import static com.nisovin.shopkeepers.config.ConfigHelper.toConfigKey;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@ -21,14 +26,11 @@ import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.config.ConfigLoadException;
import com.nisovin.shopkeepers.config.migration.ConfigMigrations;
import com.nisovin.shopkeepers.text.Text;
import com.nisovin.shopkeepers.util.ConfigUtils;
import com.nisovin.shopkeepers.util.ItemData;
import com.nisovin.shopkeepers.util.ItemUtils;
import com.nisovin.shopkeepers.util.Log;
import com.nisovin.shopkeepers.util.PermissionUtils;
import com.nisovin.shopkeepers.util.StringUtils;
import com.nisovin.shopkeepers.util.TextUtils;
import com.nisovin.shopkeepers.util.Utils;
public class Settings {
@ -97,7 +99,7 @@ public class Settings {
/*
* General Settings
*/
public static int configVersion = 3;
public static int configVersion = 4;
public static boolean debug = false;
// See DebugOptions for all available options.
public static List<String> debugOptions = new ArrayList<>(0);
@ -305,285 +307,15 @@ public class Settings {
/*
* Messages
*/
public static String language = "en";
// TODO Replace all with Text? Will require converting back to String, especially for texts used by items.
public static String msgShopTypeAdminRegular = "Admin shop";
public static String msgShopTypeSelling = "Selling shop";
public static String msgShopTypeBuying = "Buying shop";
public static String msgShopTypeTrading = "Trading shop";
public static String msgShopTypeBook = "Book shop";
public static String msgShopTypeDescAdminRegular = "has unlimited stock";
public static String msgShopTypeDescSelling = "sells items to players";
public static String msgShopTypeDescBuying = "buys items from players";
public static String msgShopTypeDescTrading = "trades items with players";
public static String msgShopTypeDescBook = "sells book copies";
public static String msgShopObjectTypeLiving = "{type}";
public static String msgShopObjectTypeSign = "sign";
public static String msgShopObjectTypeNpc = "npc";
public static Text msgSelectedShopType = Text.parse("&aSelected shop type: &6{type} &7({description})");
public static Text msgSelectedShopObjectType = Text.parse("&aSelected object type: &6{type}");
public static Text msgCreationItemSelected = Text.parse("&aShop creation:\n"
+ "&e Left/Right-click to select the shop type.\n"
+ "&e Sneak + left/right-click to select the object type.\n"
+ "&e Right-click a container to select it.\n"
+ "&e Then right-click a block to place the shopkeeper.");
public static String msgButtonPreviousPage = "&6<- Previous page ({prev_page} of {max_page})";
public static List<String> msgButtonPreviousPageLore = Arrays.asList();
public static String msgButtonNextPage = "&6Next page ({next_page} of {max_page}) ->";
public static List<String> msgButtonNextPageLore = Arrays.asList();
public static String msgButtonCurrentPage = "&6Page {page} of {max_page}";
public static List<String> msgButtonCurrentPageLore = Arrays.asList();
public static String msgButtonName = "&aSet shop name";
public static List<String> msgButtonNameLore = Arrays.asList("Lets you rename", "your shopkeeper");
public static String msgButtonContainer = "&aView shop inventory";
public static List<String> msgButtonContainerLore = Arrays.asList("Lets you view the inventory", " your shopkeeper is using");
public static String msgButtonDelete = "&4Delete";
public static List<String> msgButtonDeleteLore = Arrays.asList("Closes and removes", "this shopkeeper");
public static String msgButtonHire = "&aHire";
public static List<String> msgButtonHireLore = Arrays.asList("Buy this shop");
public static String msgButtonSignVariant = "&aChoose sign variant";
public static List<String> msgButtonSignVariantLore = Arrays.asList("Changes the sign's", "wood type");
public static String msgButtonBaby = "&aToggle baby variant";
public static List<String> msgButtonBabyLore = Arrays.asList("Toggles between the mob's", "baby and adult variant");
public static String msgButtonSitting = "&aToggle sitting pose";
public static List<String> msgButtonSittingLore = Arrays.asList("Toggles the mob's", "sitting pose");
public static String msgButtonCatVariant = "&aChoose cat variant";
public static List<String> msgButtonCatVariantLore = Arrays.asList("Changes the cat's look");
public static String msgButtonRabbitVariant = "&aChoose rabbit variant";
public static List<String> msgButtonRabbitVariantLore = Arrays.asList("Changes the rabbit's look");
public static String msgButtonCollarColor = "&aChoose collar color";
public static List<String> msgButtonCollarColorLore = Arrays.asList("Changes the mob's", "collar color");
public static String msgButtonWolfAngry = "&aToggle angry wolf";
public static List<String> msgButtonWolfAngryLore = Arrays.asList("Toggles the wolf's", "angry state");
public static String msgButtonCarryingChest = "&aToggle carrying chest";
public static List<String> msgButtonCarryingChestLore = Arrays.asList("Toggles whether the mob", "is carrying a chest");
public static String msgButtonHorseColor = "&aChoose horse color";
public static List<String> msgButtonHorseColorLore = Arrays.asList("Changes the color", "of the horse");
public static String msgButtonHorseStyle = "&aChoose horse style";
public static List<String> msgButtonHorseStyleLore = Arrays.asList("Changes the coat pattern", "of the horse");
public static String msgButtonHorseArmor = "&aChoose horse armor";
public static List<String> msgButtonHorseArmorLore = Arrays.asList("Changes the armor", "of the horse");
public static String msgButtonLlamaVariant = "&aChoose llama variant";
public static List<String> msgButtonLlamaVariantLore = Arrays.asList("Changes the llama's look");
public static String msgButtonLlamaCarpetColor = "&aLlama carpet color";
public static List<String> msgButtonLlamaCarpetColorLore = Arrays.asList("Changes the llama's", "carpet color");
public static String msgButtonCreeperCharged = "&aToggle charged creeper";
public static List<String> msgButtonCreeperChargedLore = Arrays.asList("Toggles the creeper's", "charged state");
public static String msgButtonFoxVariant = "&aChoose fox variant";
public static List<String> msgButtonFoxVariantLore = Arrays.asList("Changes the fox's look");
public static String msgButtonFoxCrouching = "&aToggle crouching pose";
public static List<String> msgButtonFoxCrouchingLore = Arrays.asList("Toggles the fox's", "crouching pose");
public static String msgButtonFoxSleeping = "&aToggle sleeping pose";
public static List<String> msgButtonFoxSleepingLore = Arrays.asList("Toggles the fox's", "sleeping pose");
public static String msgButtonMooshroomVariant = "&aChoose mooshroom variant";
public static List<String> msgButtonMooshroomVariantLore = Arrays.asList("Changes the look", "of the mooshroom");
public static String msgButtonPandaVariant = "&aChoose panda variant";
public static List<String> msgButtonPandaVariantLore = Arrays.asList("Changes the panda's look");
public static String msgButtonParrotVariant = "&aChoose parrot variant";
public static List<String> msgButtonParrotVariantLore = Arrays.asList("Changes the parrot's look");
public static String msgButtonPigSaddle = "&aToggle pig saddle";
public static List<String> msgButtonPigSaddleLore = Arrays.asList("Toggles the pig's saddle");
public static String msgButtonSheepColor = "&aChoose sheep color";
public static List<String> msgButtonSheepColorLore = Arrays.asList("Changes the sheep's", "wool color");
public static String msgButtonSheepSheared = "&aToggle sheared sheep";
public static List<String> msgButtonSheepShearedLore = Arrays.asList("Toggles the sheep's", "sheared state");
public static String msgButtonVillagerProfession = "&aChoose villager profession";
public static List<String> msgButtonVillagerProfessionLore = Arrays.asList("Changes the profession", "of the villager");
public static String msgButtonVillagerVariant = "&aChoose villager variant";
public static List<String> msgButtonVillagerVariantLore = Arrays.asList("Changes the look", "of the villager");
public static String msgButtonVillagerLevel = "&aChoose villager badge color";
public static List<String> msgButtonVillagerLevelLore = Arrays.asList("Changes the badge color", "of the villager");
public static String msgButtonZombieVillagerProfession = "&aChoose villager profession";
public static List<String> msgButtonZombieVillagerProfessionLore = Arrays.asList("Changes the profession", "of the zombie villager");
public static String msgButtonSlimeSize = "&aChoose slime size";
public static List<String> msgButtonSlimeSizeLore = Arrays.asList("Cycles the slime's size.", "Current size: &e{size}");
public static String msgButtonMagmaCubeSize = "&aChoose magma cube size";
public static List<String> msgButtonMagmaCubeSizeLore = Arrays.asList("Cycles the magma cube's size.", "Current size: &e{size}");
public static String msgTradingTitlePrefix = "&2";
public static String msgTradingTitleDefault = "Shopkeeper";
public static Text msgContainerSelected = Text.parse("&aContainer selected! Right-click a block to place your shopkeeper.");
public static Text msgUnsupportedContainer = Text.parse("&7This type of container cannot be used for shops.");
public static Text msgMustSelectContainer = Text.parse("&7You must right-click a container before placing your shopkeeper.");
public static Text msgInvalidContainer = Text.parse("&7The selected block is not a valid container!");
public static Text msgContainerTooFarAway = Text.parse("&7The shopkeeper's container is too far away!");
public static Text msgContainerNotPlaced = Text.parse("&7You must select a container you have recently placed!");
public static Text msgContainerAlreadyInUse = Text.parse("&7Another shopkeeper is already using the selected container!");
public static Text msgNoContainerAccess = Text.parse("&7You cannot access the selected container!");
public static Text msgTooManyShops = Text.parse("&7You have too many shops!");
public static Text msgNoAdminShopTypeSelected = Text.parse("&7You have to select an admin shop type!");
public static Text msgNoPlayerShopTypeSelected = Text.parse("&7You have to select a player shop type!");
public static Text msgShopCreateFail = Text.parse("&7You cannot create a shopkeeper there.");
public static Text msgTypeNewName = Text.parse("&aPlease type the shop's name into the chat.\n"
+ " &aType a dash (-) to remove the name.");
public static Text msgNameSet = Text.parse("&aThe shop's name has been set!");
public static Text msgNameHasNotChanged = Text.parse("&aThe shop's name has not changed.");
public static Text msgNameInvalid = Text.parse("&aThat name is not valid!");
public static Text msgShopTypeDisabled = Text.parse("&7The shop type '&6{type}&7' is disabled.");
public static Text msgShopObjectTypeDisabled = Text.parse("&7The shop object type '&6{type}&7' is disabled.");
public static Text msgMustTargetShop = Text.parse("&7You have to target a shopkeeper.");
public static Text msgMustTargetAdminShop = Text.parse("&7You have to target an admin shopkeeper.");
public static Text msgMustTargetPlayerShop = Text.parse("&7You have to target a player shopkeeper.");
public static Text msgTargetEntityIsNoShop = Text.parse("&7The targeted entity is no shopkeeper.");
public static Text msgTargetShopIsNoAdminShop = Text.parse("&7The targeted shopkeeper is no admin shopkeeper.");
public static Text msgTargetShopIsNoPlayerShop = Text.parse("&7The targeted shopkeeper is no player shopkeeper.");
public static Text msgUnusedContainer = Text.parse("&7No shopkeeper is using this container.");
public static Text msgNotOwner = Text.parse("&7You are not the owner of this shopkeeper.");
// Placeholders: {owner} -> new owners name
public static Text msgOwnerSet = Text.parse("&aNew owner was set to &e{owner}");
public static Text msgShopCreationItemsGiven = Text.parse("&aPlayer &e{player}&a has received &e{amount}&a shop creation item(s)!");
public static Text msgShopCreationItemsReceived = Text.parse("&aYou have received &e{amount}&a shop creation item(s)!");
public static Text msgCurrencyItemsGiven = Text.parse("&aPlayer &e{player}&a has received &e{amount}&a currency item(s)!");
public static Text msgCurrencyItemsReceived = Text.parse("&aYou have received &e{amount}&a currency item(s)!");
public static Text msgHighCurrencyItemsGiven = Text.parse("&aPlayer &e{player}&a has received &e{amount}&a high currency item(s)!");
public static Text msgHighCurrencyItemsReceived = Text.parse("&aYou have received &e{amount}&a high currency item(s)!");
public static Text msgHighCurrencyDisabled = Text.parse("&cThe high currency is disabled!");
public static Text msgItemsConverted = Text.parse("&aConverted &e{count}&a item stack(s)!");
public static String msgUnknownBookAuthor = "Unknown";
public static Text msgTradePermSet = Text.parse("&aThe shop's trading permission has been set to '&e{perm}&a'!");
public static Text msgTradePermRemoved = Text.parse("&aThe shop's trading permission '&e{perm}&a' has been removed!");
public static Text msgTradePermView = Text.parse("&aThe shop's current trading permission is '&e{perm}&a'.");
public static Text msgZombieVillagerCuringDisabled = Text.parse("&7Curing of zombie villagers is disabled.");
public static Text msgMustHoldHireItem = Text.parse("&7You have to hold the required hire item in your hand.");
public static Text msgSetForHire = Text.parse("&aThe Shopkeeper was set for hire.");
public static Text msgHired = Text.parse("&aYou have hired this shopkeeper!");
public static Text msgMissingHirePerm = Text.parse("&7You do not have the permission to hire shopkeepers.");
public static Text msgCantHire = Text.parse("&aYou cannot afford to hire this shopkeeper.");
public static Text msgCantHireShopType = Text.parse("&7You do not have the permission to hire this type of shopkeeper.");
// Placeholders: {costs}, {hire-item}
public static Text msgVillagerForHire = Text.parse("&aThe villager offered his services as a shopkeeper in exchange for &6{costs}x {hire-item}&a.");
public static Text msgMissingTradePerm = Text.parse("&7You do not have the permission to trade with this shop.");
public static Text msgMissingCustomTradePerm = Text.parse("&7You do not have the permission to trade with this shop.");
public static Text msgCantTradeWithOwnShop = Text.parse("&7You cannot trade with your own shop.");
public static Text msgCantTradeWhileOwnerOnline = Text.parse("&7You cannot trade while the owner of this shop ('&e{owner}&7') is online.");
public static Text msgCantTradeWithShopMissingContainer = Text.parse("&7You cannot trade with this shop, because its container is missing.");
public static Text msgShopkeeperCreated = Text.parse("&aShopkeeper created: &6{type} &7({description})\n{setupDesc}");
public static String msgShopSetupDescSelling = "&e Add items you want to sell to your container, then\n"
+ "&e right-click the shop while sneaking to modify costs.";
public static String msgShopSetupDescBuying = "&e Add one of each item you want to buy to your container,\n"
+ "&e then right-click the shop while sneaking to modify costs.";
public static String msgShopSetupDescTrading = "&e Add items you want to sell to your container, then\n"
+ "&e right-click the shop while sneaking to modify costs.";
public static String msgShopSetupDescBook = "&e Add written books and blank books to your container, then\n"
+ "&e right-click the shop while sneaking to modify costs.";
public static String msgShopSetupDescAdminRegular = "&e Right-click the shop while sneaking to modify trades.";
public static String msgTradeSetupDescHeader = "&6{shopType}";
public static List<String> msgTradeSetupDescAdminRegular = Arrays.asList("Has unlimited stock.", "Insert items from your inventory.", "Top row: Result items", "Bottom rows: Cost items");
public static List<String> msgTradeSetupDescSelling = Arrays.asList("Sells items.", "Insert items to sell into the container.", "Left/Right click to adjust amounts.", "Top row: Items being sold", "Bottom rows: Cost items");
public static List<String> msgTradeSetupDescBuying = Arrays.asList("Buys items.", "Insert one of each item you want to", "buy and plenty of currency items", "into the container.", "Left/Right click to adjust amounts.", "Top row: Cost items", "Bottom row: Items being bought");
public static List<String> msgTradeSetupDescTrading = Arrays.asList("Trades items.", "Pickup an item from your inventory", "and then click a slot to place it.", "Left/Right click to adjust amounts.", "Top row: Result items", "Bottom rows: Cost items");
public static List<String> msgTradeSetupDescBook = Arrays.asList("Sells book copies.", "Insert written and blank books", "into the container.", "Left/Right click to adjust costs.", "Top row: Books being sold", "Bottom rows: Cost items");
public static Text msgMissingEditVillagersPerm = Text.parse("&7You do not have the permission to edit villagers.");
public static Text msgMissingEditWanderingTradersPerm = Text.parse("&7You do not have the permission to edit wandering traders.");
public static Text msgMustTargetEntity = Text.parse("&7You have to target an entity.");
public static Text msgMustTargetVillager = Text.parse("&7You have to target a villager.");
public static Text msgTargetEntityIsNoVillager = Text.parse("&7The targeted entity is no regular villager.");
public static String msgVillagerEditorTitle = "&aVillager Editor: &e{villagerName}";
public static String msgVillagerEditorDescriptionHeader = "&6Villager Editor";
public static List<String> msgVillagerEditorDescription = Arrays.asList(
"Top row: Result items",
"Bottom rows: Cost items",
"Edited trades have infinite",
"uses and no XP rewards."
);
public static String msgButtonDeleteVillager = "&4Delete";
public static List<String> msgButtonDeleteVillagerLore = Arrays.asList("Deletes the villager");
public static String msgButtonVillagerInventory = "&aView villager inventory";
public static List<String> msgButtonVillagerInventoryLore = Arrays.asList(
"Lets you view a copy of",
"the villager's inventory"
);
public static String msgButtonMobAi = "&aToggle mob AI";
public static List<String> msgButtonMobAiLore = Arrays.asList("Toggles the mob's AI");
public static String msgVillagerInventoryTitle = "Villager inventory (copy)";
public static String msgSetVillagerXp = "&aSet the villager's XP to &e{xp}";
public static String msgNoVillagerTradesChanged = "&aNo trades have been changed.";
public static String msgVillagerTradesChanged = "&e{changedTrades}&a trades have been changed.";
public static Text msgListAdminShopsHeader = Text.parse("&9There are &e{shopsCount} &9admin shops: &e(Page {page} of {maxPage})");
public static Text msgListAllShopsHeader = Text.parse("&9There are &e{shopsCount} &9shops in total: &e(Page {page} of {maxPage})");
public static Text msgListPlayerShopsHeader = Text.parse("&9Player '&e{player}&9' has &e{shopsCount} &9shops: &e(Page {page} of {maxPage})");
public static Text msgListShopsEntry = Text.parse(" &e{shopId}) &7{shopName}&r&8at &7({location})&8, type: &7{shopType}&8, object: &7{objectType}");
public static Text msgRemovedAdminShops = Text.parse("&e{shopsCount} &aadmin shops were removed.");
public static Text msgRemovedShopsOfPlayer = Text.parse("&e{shopsCount} &ashops of player '&e{player}&a' were removed.");
public static Text msgRemovedPlayerShops = Text.parse("&e{shopsCount} &aplayer shops were removed.");
public static Text msgConfirmRemoveAllAdminShops = Text.parse("&cYou are about to irrevocable remove all admin shops (&6{shopsCount}&c)!");
public static Text msgConfirmRemoveAllOwnShops = Text.parse("&cYou are about to irrevocable remove all your shops (&6{shopsCount}&c)!");
public static Text msgConfirmRemoveAllShopsOfPlayer = Text.parse("&cYou are about to irrevocable remove all shops of player &6{player}&c (&6{shopsCount}&c)!");
public static Text msgConfirmRemoveAllPlayerShops = Text.parse("&cYou are about to irrevocable remove all player shops of all players (&6{shopsCount}&c)!");
public static Text msgConfirmationRequired = Text.parse("&7Please confirm this action by typing &6/shopkeepers confirm");
public static Text msgConfirmationExpired = Text.parse("&cConfirmation expired.");
public static Text msgNothingToConfirm = Text.parse("&cThere is nothing to confirm currently.");
public static Text msgNoPermission = Text.parse("&cYou don't have the permission to do that.");
public static Text msgCommandUnknown = Text.parse("&cUnknown command '&e{command}&c'!");
public static Text msgCommandArgumentUnexpected = Text.parse("&cUnexpected argument '&e{argument}&c'.");
public static Text msgCommandArgumentRequiresPlayer = Text.parse("&cArgument '&e{argumentFormat}&c' requires a player to execute the command.");
public static Text msgCommandArgumentMissing = Text.parse("&cMissing argument '&e{argumentFormat}&c'.");
public static Text msgCommandArgumentInvalid = Text.parse("&cInvalid argument '&e{argument}&c'.");
public static Text msgCommandPlayerArgumentMissing = Text.parse("&cNo player specified for '&e{argumentFormat}&c'.");
public static Text msgCommandPlayerArgumentInvalid = Text.parse("&cNo player found for '&e{argument}&c'.");
public static Text msgCommandShopTypeArgumentInvalid = Text.parse("&cUnknown shop type '&e{argument}&c'.");
public static Text msgCommandShopObjectTypeArgumentInvalid = Text.parse("&cUnknown shop object type '&e{argument}&c'.");
public static Text msgCommandShopkeeperArgumentInvalid = Text.parse("&cNo shopkeeper found for '&e{argument}&c'.");
public static Text msgCommandShopkeeperArgumentNoAdminShop = Text.parse("&cShopkeeper '&e{argument}&c' is no admin shopkeeper.");
public static Text msgCommandShopkeeperArgumentNoPlayerShop = Text.parse("&cShopkeeper '&e{argument}&c' is no player shopkeeper.");
public static Text msgAmbiguousPlayerName = Text.parse("&cThere are multiple matches for the name '&e{name}&c'!");
public static Text msgAmbiguousPlayerNameEntry = Text.parse("&c - '&e{name}&r&c' (&6{uuid}&c)");
public static Text msgAmbiguousPlayerNameMore = Text.parse("&c ....");
public static Text msgCommandHelpTitle = Text.parse("&9***** &8[&6Shopkeepers v{version}&8] &9*****");
public static Text msgCommandHelpUsageFormat = Text.parse("&e{usage}");
public static Text msgCommandHelpDescriptionFormat = Text.parse("&8 - &3{description}");
public static Text msgCommandDescriptionShopkeeper = Text.parse("Creates a shopkeeper.");
public static Text msgCommandDescriptionHelp = Text.parse("Shows this help page.");
public static Text msgCommandDescriptionReload = Text.parse("Reloads this plugin.");
public static Text msgCommandDescriptionDebug = Text.parse("Toggles debug mode on and off.");
public static Text msgCommandDescriptionList = Text.parse("Lists all shops for the specified player, or all admin shops.");
public static Text msgCommandDescriptionRemove = Text.parse("Removes all shops for the specified player, all players, or all admin shops.");
public static Text msgCommandDescriptionGive = Text.parse("Gives shop creation item(s) to the specified player.");
public static Text msgCommandDescriptionGiveCurrency = Text.parse("Gives currency item(s) to the specified player.");
public static Text msgCommandDescriptionConvertItems = Text.parse("Converts the held (or all) items to conform to Spigot's data format.");
public static Text msgCommandDescriptionRemote = Text.parse("Remotely opens a shop.");
public static Text msgCommandDescriptionRemoteEdit = Text.parse("Remotely edits a shop.");
public static Text msgCommandDescriptionTransfer = Text.parse("Transfers the ownership of a shop.");
public static Text msgCommandDescriptionSettradeperm = Text.parse("Sets, removes (-) or displays (?) the trading permission.");
public static Text msgCommandDescriptionSetforhire = Text.parse("Sets one of your shops for sale.");
public static Text msgCommandDescriptionEditVillager = Text.parse("Opens the editor for the target villager.");
public static String language = "en-default";
// /////
private static String toConfigKey(String fieldName) {
return fieldName.replaceAll("([A-Z][a-z]+)", "-$1").toLowerCase(Locale.ROOT);
}
// These String / String list settings are exempt from color conversion:
private static final Set<String> noColorConversionKeys = new HashSet<>(Arrays.asList(
toConfigKey("debugOptions"), toConfigKey("fileEncoding"), toConfigKey("shopCreationItemSpawnEggEntityType"),
toConfigKey("maxShopsPermOptions"), toConfigKey("enabledLivingShops"), toConfigKey("nameRegex"),
toConfigKey("language")));
// Returns true, if the config misses values which need to be saved
public static boolean loadConfiguration(Configuration config) throws ConfigLoadException {
@ -595,15 +327,13 @@ public class Settings {
configChanged = true;
}
// Exempt a few string / string list settings from color conversion:
List<String> noColorConversionKeys = Arrays.asList(
toConfigKey("debugOptions"), toConfigKey("fileEncoding"), toConfigKey("shopCreationItemSpawnEggEntityType"),
toConfigKey("maxShopsPermOptions"), toConfigKey("enabledLivingShops"), toConfigKey("nameRegex"),
toConfigKey("language"));
try {
Field[] fields = Settings.class.getDeclaredFields();
for (Field field : fields) {
if (field.isSynthetic()) continue;
if (!Modifier.isPublic(field.getModifiers())) {
continue;
}
Class<?> typeClass = field.getType();
Class<?> genericType = null;
if (typeClass == List.class) {
@ -642,7 +372,7 @@ public class Settings {
throw new ConfigLoadException("Error while loading config values!", e);
}
// validation:
// Validation:
boolean foundInvalidEntityType = false;
boolean removePigZombie = false;
@ -714,149 +444,6 @@ public class Settings {
return configChanged;
}
private static Object loadConfigValue(Configuration config, String configKey, List<String> noColorConversionKeys, Class<?> typeClass, Class<?> genericType) {
if (typeClass == String.class || typeClass == Text.class) {
String string = config.getString(configKey);
// Colorize, if not exempted:
if (!noColorConversionKeys.contains(configKey)) {
string = TextUtils.colorize(string);
}
if (typeClass == Text.class) {
return Text.parse(string);
} else {
return string;
}
} else if (typeClass == int.class) {
return config.getInt(configKey);
} else if (typeClass == short.class) {
return (short) config.getInt(configKey);
} else if (typeClass == boolean.class) {
return config.getBoolean(configKey);
} else if (typeClass == Material.class) {
// This assumes that legacy item conversion has already been performed
Material material = ConfigUtils.loadMaterial(config, configKey);
if (material == null) {
Log.warning("Config: Unknown material for config entry '" + configKey + "': " + config.get(configKey));
Log.warning("Config: All valid material names can be found here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html");
}
return material;
} else if (typeClass == ItemData.class) {
ItemData itemData = loadItemData(config.get(configKey), configKey);
// Normalize to not null:
if (itemData == null) {
itemData = new ItemData(Material.AIR);
}
return itemData;
} else if (typeClass == List.class) {
if (genericType == String.class || genericType == Text.class) {
List<String> stringList = config.getStringList(configKey);
// Colorize, if not exempted:
if (!noColorConversionKeys.contains(configKey)) {
stringList = TextUtils.colorize(stringList);
}
if (genericType == Text.class) {
return Text.parse(stringList);
} else {
return stringList;
}
} else if (genericType == ItemData.class) {
List<?> list = config.getList(configKey, Collections.emptyList());
List<ItemData> itemDataList = new ArrayList<>(list.size());
int index = 0;
for (Object entry : list) {
index += 1;
ItemData itemData = loadItemData(entry, configKey + "[" + index + "]");
if (itemData != null) {
itemDataList.add(itemData);
}
}
return itemDataList;
} else {
throw new IllegalStateException("Unsupported config setting list type: " + genericType.getName());
}
}
throw new IllegalStateException("Unsupported config setting type: " + typeClass.getName());
}
private static ItemData loadItemData(Object dataObject, String configEntryIdentifier) {
ItemData itemData = ItemData.deserialize(dataObject, (warning) -> {
Log.warning("Config: Couldn't load item data for config entry '" + configEntryIdentifier + "': " + warning);
if (warning.contains("Unknown item type")) { // TODO this is ugly
Log.warning("Config: All valid material names can be found here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html");
}
});
return itemData;
}
private static void setConfigValue(Configuration config, String configKey, List<String> noColorConversionKeys, Class<?> typeClass, Class<?> genericType, Object value) {
if (value == null) {
// Remove value:
config.set(configKey, null);
return;
}
if (typeClass == Material.class) {
config.set(configKey, ((Material) value).name());
} else if (typeClass == String.class || typeClass == Text.class) {
String stringValue;
if (typeClass == Text.class) {
stringValue = ((Text) value).toPlainFormatText();
} else {
stringValue = (String) value;
}
// Decolorize, if not exempted:
if (!noColorConversionKeys.contains(configKey)) {
value = TextUtils.decolorize(stringValue);
}
config.set(configKey, value);
} else if (typeClass == List.class && (genericType == String.class || genericType == Text.class)) {
List<String> stringList;
if (genericType == Text.class) {
stringList = ((List<Text>) value).stream().map(Text::toPlainFormatText).collect(Collectors.toList());
} else {
stringList = (List<String>) value;
}
// Decolorize, if not exempted:
if (!noColorConversionKeys.contains(configKey)) {
value = TextUtils.decolorize(stringList);
}
config.set(configKey, value);
} else if (typeClass == ItemData.class) {
config.set(configKey, ((ItemData) value).serialize());
} else {
config.set(configKey, value);
}
}
public static void loadLanguageConfiguration(Configuration config) throws ConfigLoadException {
try {
Field[] fields = Settings.class.getDeclaredFields();
for (Field field : fields) {
if (!field.getName().startsWith("msg")) continue;
Class<?> typeClass = field.getType();
Class<?> genericType = null;
if (typeClass == List.class) {
genericType = (Class<?>) ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[0];
}
String configKey = toConfigKey(field.getName());
if (!config.isSet(configKey)) {
continue; // Skip, keeps default
}
Object value = loadConfigValue(config, configKey, Collections.emptyList(), typeClass, genericType);
if (value == null) {
continue; // Skip, keeps default
}
field.set(null, value);
}
} catch (Exception e) {
throw new ConfigLoadException("Error while loading messages from language file!", e);
}
onSettingsChanged();
}
public static void onSettingsChanged() {
// Prepare derived settings:
DerivedSettings.setup();
@ -889,14 +476,14 @@ public class Settings {
namingItemData = new ItemData(ItemUtils.setItemStackName(nameItem.createItemStack(), null));
// Button items:
nameButtonItem = new ItemData(ItemUtils.setItemStackNameAndLore(nameItem.createItemStack(), msgButtonName, msgButtonNameLore));
containerButtonItem = new ItemData(ItemUtils.setItemStackNameAndLore(containerItem.createItemStack(), msgButtonContainer, msgButtonContainerLore));
deleteButtonItem = new ItemData(ItemUtils.setItemStackNameAndLore(deleteItem.createItemStack(), msgButtonDelete, msgButtonDeleteLore));
hireButtonItem = new ItemData(ItemUtils.setItemStackNameAndLore(hireItem.createItemStack(), msgButtonHire, msgButtonHireLore));
nameButtonItem = new ItemData(ItemUtils.setItemStackNameAndLore(nameItem.createItemStack(), Messages.buttonName, Messages.buttonNameLore));
containerButtonItem = new ItemData(ItemUtils.setItemStackNameAndLore(containerItem.createItemStack(), Messages.buttonContainer, Messages.buttonContainerLore));
deleteButtonItem = new ItemData(ItemUtils.setItemStackNameAndLore(deleteItem.createItemStack(), Messages.buttonDelete, Messages.buttonDeleteLore));
hireButtonItem = new ItemData(ItemUtils.setItemStackNameAndLore(hireItem.createItemStack(), Messages.buttonHire, Messages.buttonHireLore));
// Note: These use the same item types as the corresponding shopkeeper buttons.
deleteVillagerButtonItem = new ItemData(ItemUtils.setItemStackNameAndLore(deleteItem.createItemStack(), msgButtonDeleteVillager, msgButtonDeleteVillagerLore));
villagerInventoryButtonItem = new ItemData(ItemUtils.setItemStackNameAndLore(containerItem.createItemStack(), msgButtonVillagerInventory, msgButtonVillagerInventoryLore));
deleteVillagerButtonItem = new ItemData(ItemUtils.setItemStackNameAndLore(deleteItem.createItemStack(), Messages.buttonDeleteVillager, Messages.buttonDeleteVillagerLore));
villagerInventoryButtonItem = new ItemData(ItemUtils.setItemStackNameAndLore(containerItem.createItemStack(), Messages.buttonVillagerInventory, Messages.buttonVillagerInventoryLore));
try {
shopNamePattern = Pattern.compile("^" + Settings.nameRegex + "$");
@ -1021,4 +608,7 @@ public class Settings {
return null;
}
}
private Settings() {
}
}

View File

@ -8,7 +8,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.util.TextUtils;
import com.nisovin.shopkeepers.util.Validate;
@ -75,7 +75,7 @@ public class Confirmations {
int taskId = Bukkit.getScheduler().runTaskLater(plugin, () -> {
this.endConfirmation(sender);
TextUtils.sendMessage(sender, Settings.msgConfirmationExpired);
TextUtils.sendMessage(sender, Messages.confirmationExpired);
}, timeoutTicks).getTaskId();
ConfirmEntry oldEntry = confirming.put(this.getSenderKey(sender), new ConfirmEntry(action, taskId));
@ -106,7 +106,7 @@ public class Confirmations {
// Execute confirmed action:
action.run();
} else {
TextUtils.sendMessage(sender, Settings.msgNothingToConfirm);
TextUtils.sendMessage(sender, Messages.nothingToConfirm);
}
}
}

View File

@ -5,7 +5,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Locale;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.api.shopobjects.ShopObjectType;
import com.nisovin.shopkeepers.commands.lib.ArgumentParseException;
@ -25,7 +25,7 @@ public class ShopObjectTypeArgument extends CommandArgument<ShopObjectType<?>> {
@Override
public Text getInvalidArgumentErrorMsg(String argumentInput) {
if (argumentInput == null) argumentInput = "";
Text text = Settings.msgCommandShopObjectTypeArgumentInvalid;
Text text = Messages.commandShopObjectTypeArgumentInvalid;
text.setPlaceholderArguments(this.getDefaultErrorMsgArgs());
text.setPlaceholderArguments(Collections.singletonMap("argument", argumentInput));
return text;

View File

@ -5,7 +5,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Locale;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.api.shopkeeper.ShopType;
import com.nisovin.shopkeepers.commands.lib.ArgumentParseException;
@ -25,7 +25,7 @@ public class ShopTypeArgument extends CommandArgument<ShopType<?>> {
@Override
public Text getInvalidArgumentErrorMsg(String argumentInput) {
if (argumentInput == null) argumentInput = "";
Text text = Settings.msgCommandShopTypeArgumentInvalid;
Text text = Messages.commandShopTypeArgumentInvalid;
text.setPlaceholderArguments(this.getDefaultErrorMsgArgs());
text.setPlaceholderArguments(Collections.singletonMap("argument", argumentInput));
return text;

View File

@ -2,7 +2,7 @@ package com.nisovin.shopkeepers.commands.arguments;
import java.util.Collections;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.ShopkeepersAPI;
import com.nisovin.shopkeepers.api.shopkeeper.Shopkeeper;
import com.nisovin.shopkeepers.commands.lib.ArgumentFilter;
@ -41,7 +41,7 @@ public class ShopkeeperByIdArgument extends ObjectByIdArgument<Integer, Shopkeep
@Override
public Text getInvalidArgumentErrorMsg(String argumentInput) {
if (argumentInput == null) argumentInput = "";
Text text = Settings.msgCommandShopkeeperArgumentInvalid;
Text text = Messages.commandShopkeeperArgumentInvalid;
text.setPlaceholderArguments(this.getDefaultErrorMsgArgs());
text.setPlaceholderArguments(Collections.singletonMap("argument", argumentInput));
return text;

View File

@ -4,7 +4,7 @@ import java.util.Collections;
import java.util.Optional;
import java.util.stream.Stream;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.Shopkeeper;
import com.nisovin.shopkeepers.commands.lib.ArgumentFilter;
import com.nisovin.shopkeepers.commands.lib.ArgumentParseException;
@ -47,7 +47,7 @@ public class ShopkeeperByNameArgument extends ObjectByIdArgument<String, Shopkee
@Override
public Text getInvalidArgumentErrorMsg(String argumentInput) {
if (argumentInput == null) argumentInput = "";
Text text = Settings.msgCommandShopkeeperArgumentInvalid;
Text text = Messages.commandShopkeeperArgumentInvalid;
text.setPlaceholderArguments(this.getDefaultErrorMsgArgs());
text.setPlaceholderArguments(Collections.singletonMap("argument", argumentInput));
return text;

View File

@ -3,7 +3,7 @@ package com.nisovin.shopkeepers.commands.arguments;
import java.util.Collections;
import java.util.UUID;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.ShopkeepersAPI;
import com.nisovin.shopkeepers.api.shopkeeper.Shopkeeper;
import com.nisovin.shopkeepers.commands.lib.ArgumentFilter;
@ -42,7 +42,7 @@ public class ShopkeeperByUUIDArgument extends ObjectByIdArgument<UUID, Shopkeepe
@Override
public Text getInvalidArgumentErrorMsg(String argumentInput) {
if (argumentInput == null) argumentInput = "";
Text text = Settings.msgCommandShopkeeperArgumentInvalid;
Text text = Messages.commandShopkeeperArgumentInvalid;
text.setPlaceholderArguments(this.getDefaultErrorMsgArgs());
text.setPlaceholderArguments(Collections.singletonMap("argument", argumentInput));
return text;

View File

@ -2,7 +2,7 @@ package com.nisovin.shopkeepers.commands.arguments;
import java.util.Collections;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.Shopkeeper;
import com.nisovin.shopkeepers.api.shopkeeper.admin.AdminShopkeeper;
import com.nisovin.shopkeepers.api.shopkeeper.player.PlayerShopkeeper;
@ -26,7 +26,7 @@ public final class ShopkeeperFilter {
@Override
public Text getInvalidArgumentErrorMsg(CommandArgument<Shopkeeper> argument, String argumentInput, Shopkeeper value) {
if (argumentInput == null) argumentInput = "";
Text text = Settings.msgCommandShopkeeperArgumentNoAdminShop;
Text text = Messages.commandShopkeeperArgumentNoAdminShop;
text.setPlaceholderArguments(argument.getDefaultErrorMsgArgs());
text.setPlaceholderArguments(Collections.singletonMap("argument", argumentInput));
return text;
@ -42,7 +42,7 @@ public final class ShopkeeperFilter {
@Override
public Text getInvalidArgumentErrorMsg(CommandArgument<Shopkeeper> argument, String argumentInput, Shopkeeper value) {
if (argumentInput == null) argumentInput = "";
Text text = Settings.msgCommandShopkeeperArgumentNoPlayerShop;
Text text = Messages.commandShopkeeperArgumentNoPlayerShop;
text.setPlaceholderArguments(argument.getDefaultErrorMsgArgs());
text.setPlaceholderArguments(Collections.singletonMap("argument", argumentInput));
return text;

View File

@ -12,6 +12,7 @@ import java.util.function.Supplier;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.commands.lib.arguments.FallbackArgument;
import com.nisovin.shopkeepers.text.Text;
@ -233,7 +234,7 @@ public abstract class Command {
}
protected NoPermissionException noPermissionException() {
return new NoPermissionException(Settings.msgNoPermission);
return new NoPermissionException(Messages.noPermission);
}
/**
@ -887,7 +888,7 @@ public abstract class Command {
throw firstUnparsedArgument.invalidArgumentError(firstUnparsedArg);
} else {
// Throw an 'unexpected argument' exception:
Text errorMsg = Settings.msgCommandArgumentUnexpected;
Text errorMsg = Messages.commandArgumentUnexpected;
errorMsg.setPlaceholderArguments(Collections.singletonMap("argument", firstUnparsedArg));
throw new ArgumentParseException(null, errorMsg);
}
@ -895,7 +896,7 @@ public abstract class Command {
}
protected Text getUnknownCommandMessage(String command) {
Text text = Settings.msgCommandUnknown;
Text text = Messages.commandUnknown;
text.setPlaceholderArguments(Collections.singletonMap("command", command));
return text;
}

View File

@ -7,7 +7,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.function.Supplier;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.commands.lib.arguments.OptionalArgument;
import com.nisovin.shopkeepers.text.Text;
import com.nisovin.shopkeepers.util.StringUtils;
@ -260,7 +260,7 @@ public abstract class CommandArgument<T> {
* @return the error message
*/
public Text getRequiresPlayerErrorMsg() {
Text text = Settings.msgCommandArgumentRequiresPlayer;
Text text = Messages.commandArgumentRequiresPlayer;
text.setPlaceholderArguments(this.getDefaultErrorMsgArgs());
return text;
}
@ -283,7 +283,7 @@ public abstract class CommandArgument<T> {
* @return the error message
*/
public Text getMissingArgumentErrorMsg() {
Text text = Settings.msgCommandArgumentInvalid;
Text text = Messages.commandArgumentInvalid;
text.setPlaceholderArguments(this.getDefaultErrorMsgArgs());
return text;
}
@ -309,7 +309,7 @@ public abstract class CommandArgument<T> {
*/
public Text getInvalidArgumentErrorMsg(String argumentInput) {
if (argumentInput == null) argumentInput = "";
Text text = Settings.msgCommandArgumentInvalid;
Text text = Messages.commandArgumentInvalid;
text.setPlaceholderArguments(this.getDefaultErrorMsgArgs());
text.setPlaceholderArguments(Collections.singletonMap("argument", argumentInput));
return text;

View File

@ -6,7 +6,7 @@ import java.util.stream.Stream;
import org.bukkit.entity.Player;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.commands.lib.ArgumentFilter;
import com.nisovin.shopkeepers.commands.lib.ArgumentParseException;
import com.nisovin.shopkeepers.text.Text;
@ -42,7 +42,7 @@ public class PlayerByNameArgument extends ObjectByIdArgument<String, Player> {
@Override
public Text getInvalidArgumentErrorMsg(String argumentInput) {
if (argumentInput == null) argumentInput = "";
Text text = Settings.msgCommandPlayerArgumentInvalid;
Text text = Messages.commandPlayerArgumentInvalid;
text.setPlaceholderArguments(this.getDefaultErrorMsgArgs());
text.setPlaceholderArguments(Collections.singletonMap("argument", argumentInput));
return text;

View File

@ -6,7 +6,7 @@ import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.commands.lib.ArgumentFilter;
import com.nisovin.shopkeepers.commands.lib.ArgumentParseException;
import com.nisovin.shopkeepers.text.Text;
@ -41,7 +41,7 @@ public class PlayerByUUIDArgument extends ObjectByIdArgument<UUID, Player> {
@Override
public Text getInvalidArgumentErrorMsg(String argumentInput) {
if (argumentInput == null) argumentInput = "";
Text text = Settings.msgCommandPlayerArgumentInvalid;
Text text = Messages.commandPlayerArgumentInvalid;
text.setPlaceholderArguments(this.getDefaultErrorMsgArgs());
text.setPlaceholderArguments(Collections.singletonMap("argument", argumentInput));
return text;

View File

@ -6,7 +6,7 @@ import java.util.function.Predicate;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.commands.lib.ArgumentFilter;
import com.nisovin.shopkeepers.text.Text;
import com.nisovin.shopkeepers.util.StringUtils;
@ -37,7 +37,7 @@ public class PlayerNameArgument extends ObjectNameArgument {
@Override
public Text getMissingArgumentErrorMsg() {
Text text = Settings.msgCommandPlayerArgumentMissing;
Text text = Messages.commandPlayerArgumentMissing;
text.setPlaceholderArguments(this.getDefaultErrorMsgArgs());
return text;
}

View File

@ -7,7 +7,7 @@ import java.util.function.Predicate;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.commands.lib.ArgumentFilter;
import com.nisovin.shopkeepers.text.Text;
@ -35,7 +35,7 @@ public class PlayerUUIDArgument extends ObjectUUIDArgument {
@Override
public Text getMissingArgumentErrorMsg() {
Text text = Settings.msgCommandPlayerArgumentMissing;
Text text = Messages.commandPlayerArgumentMissing;
text.setPlaceholderArguments(this.getDefaultErrorMsgArgs());
return text;
}

View File

@ -8,7 +8,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.commands.lib.ArgumentParseException;
import com.nisovin.shopkeepers.commands.lib.ArgumentsReader;
import com.nisovin.shopkeepers.commands.lib.CommandArgument;
@ -35,7 +35,7 @@ public class TargetEntityArgument extends CommandArgument<Entity> {
@Override
public Text getNoTargetErrorMsg() {
return Settings.msgMustTargetEntity;
return Messages.mustTargetEntity;
}
@Override

View File

@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.commands.lib.Command;
@ -33,7 +34,7 @@ class CommandConvertItems extends Command {
// Permission gets checked by testPermission and during execution.
// Set description:
this.setDescription(Settings.msgCommandDescriptionConvertItems);
this.setDescription(Messages.commandDescriptionConvertItems);
// Arguments:
this.addArgument(new SenderPlayerFallback(new PlayerArgument(ARGUMENT_PLAYER)));
@ -103,12 +104,12 @@ class CommandConvertItems extends Command {
}
// Inform target player:
TextUtils.sendMessage(targetPlayer, Settings.msgItemsConverted,
TextUtils.sendMessage(targetPlayer, Messages.itemsConverted,
"count", convertedStacks
);
if (!targetSelf) {
// Inform command executor:
TextUtils.sendMessage(sender, Settings.msgItemsConverted,
TextUtils.sendMessage(sender, Messages.itemsConverted,
"count", convertedStacks
);
}

View File

@ -3,6 +3,7 @@ package com.nisovin.shopkeepers.commands.shopkeepers;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.commands.lib.Command;
@ -19,7 +20,7 @@ class CommandDebug extends Command {
this.setPermission(ShopkeepersPlugin.DEBUG_PERMISSION);
// Set description:
this.setDescription(Settings.msgCommandDescriptionDebug);
this.setDescription(Messages.commandDescriptionDebug);
}
@Override

View File

@ -2,7 +2,7 @@ package com.nisovin.shopkeepers.commands.shopkeepers;
import org.bukkit.entity.Player;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.api.shopkeeper.Shopkeeper;
import com.nisovin.shopkeepers.commands.arguments.ShopkeeperArgument;
@ -24,7 +24,7 @@ class CommandEdit extends PlayerCommand {
this.setPermission(ShopkeepersPlugin.REMOTE_EDIT_PERMISSION);
// Set description:
this.setDescription(Settings.msgCommandDescriptionRemoteEdit);
this.setDescription(Messages.commandDescriptionRemoteEdit);
// Arguments:
this.addArgument(new TargetShopkeeperFallback(

View File

@ -5,8 +5,8 @@ import org.bukkit.entity.AbstractVillager;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.SKShopkeepersPlugin;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.commands.lib.CommandContextView;
import com.nisovin.shopkeepers.commands.lib.CommandException;
@ -40,12 +40,12 @@ class CommandEditVillager extends PlayerCommand {
@Override
public Text getNoTargetErrorMsg() {
return Settings.msgMustTargetVillager;
return Messages.mustTargetVillager;
}
@Override
public Text getInvalidTargetErrorMsg(Entity entity) {
return Settings.msgTargetEntityIsNoVillager;
return Messages.targetEntityIsNoVillager;
}
};
@ -57,7 +57,7 @@ class CommandEditVillager extends PlayerCommand {
// Permission gets checked by testPermission and when opening the editor.
// Set description:
this.setDescription(Settings.msgCommandDescriptionEditVillager);
this.setDescription(Messages.commandDescriptionEditVillager);
// Arguments:
this.addArgument(new TargetEntityFallback(

View File

@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.commands.lib.Command;
@ -30,7 +31,7 @@ class CommandGive extends Command {
this.setPermission(ShopkeepersPlugin.GIVE_PERMISSION);
// Set description:
this.setDescription(Settings.msgCommandDescriptionGive);
this.setDescription(Messages.commandDescriptionGive);
// Arguments:
this.addArgument(new SenderPlayerFallback(new PlayerArgument(ARGUMENT_PLAYER)));
@ -65,12 +66,12 @@ class CommandGive extends Command {
// Success:
// TODO Show shop creation item via hover text?
// Inform target player:
TextUtils.sendMessage(targetPlayer, Settings.msgShopCreationItemsReceived,
TextUtils.sendMessage(targetPlayer, Messages.shopCreationItemsReceived,
"amount", amount
);
if (!targetSelf) {
// Inform command executor:
TextUtils.sendMessage(sender, Settings.msgShopCreationItemsGiven,
TextUtils.sendMessage(sender, Messages.shopCreationItemsGiven,
"player", TextUtils.getPlayerText(targetPlayer),
"amount", amount
);

View File

@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.commands.lib.Command;
@ -37,7 +38,7 @@ class CommandGiveCurrency extends Command {
this.setPermission(ShopkeepersPlugin.GIVE_CURRENCY_PERMISSION);
// Set description:
this.setDescription(Settings.msgCommandDescriptionGiveCurrency);
this.setDescription(Messages.commandDescriptionGiveCurrency);
// Arguments:
this.addArgument(new SenderPlayerFallback(new PlayerArgument(ARGUMENT_PLAYER)));
@ -64,7 +65,7 @@ class CommandGiveCurrency extends Command {
assert ARGUMENT_CURRENCY_HIGH.equals(currencyType);
lowCurrency = false;
if (!Settings.isHighCurrencyEnabled()) {
TextUtils.sendMessage(sender, Settings.msgHighCurrencyDisabled);
TextUtils.sendMessage(sender, Messages.highCurrencyDisabled);
return;
}
}
@ -95,24 +96,24 @@ class CommandGiveCurrency extends Command {
// TODO Show currency item via hover text?
if (lowCurrency) {
// Inform target player:
TextUtils.sendMessage(targetPlayer, Settings.msgCurrencyItemsReceived,
TextUtils.sendMessage(targetPlayer, Messages.currencyItemsReceived,
"amount", amount
);
if (!targetSelf) {
// Inform command executor:
TextUtils.sendMessage(sender, Settings.msgCurrencyItemsGiven,
TextUtils.sendMessage(sender, Messages.currencyItemsGiven,
"player", TextUtils.getPlayerText(targetPlayer),
"amount", amount
);
}
} else {
// Inform target player:
TextUtils.sendMessage(targetPlayer, Settings.msgHighCurrencyItemsReceived,
TextUtils.sendMessage(targetPlayer, Messages.highCurrencyItemsReceived,
"amount", amount
);
if (!targetSelf) {
// Inform command executor:
TextUtils.sendMessage(sender, Settings.msgHighCurrencyItemsGiven,
TextUtils.sendMessage(sender, Messages.highCurrencyItemsGiven,
"player", TextUtils.getPlayerText(targetPlayer),
"amount", amount
);

View File

@ -2,7 +2,7 @@ package com.nisovin.shopkeepers.commands.shopkeepers;
import java.util.Arrays;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.commands.lib.Command;
import com.nisovin.shopkeepers.commands.lib.HelpCommand;
@ -16,6 +16,6 @@ class CommandHelp extends HelpCommand {
this.setPermission(ShopkeepersPlugin.HELP_PERMISSION);
// Set description:
this.setDescription(Settings.msgCommandDescriptionHelp);
this.setDescription(Messages.commandDescriptionHelp);
}
}

View File

@ -10,7 +10,7 @@ import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.api.shopkeeper.Shopkeeper;
import com.nisovin.shopkeepers.api.shopkeeper.ShopkeeperRegistry;
@ -54,7 +54,7 @@ class CommandList extends Command {
// Permission gets checked by testPermission and during execution.
// Set description:
this.setDescription(Settings.msgCommandDescriptionList);
this.setDescription(Messages.commandDescriptionList);
// Arguments:
this.addArgument(new FirstOfArgument("target", Arrays.asList(
@ -171,21 +171,21 @@ class CommandList extends Command {
if (listAllShops) {
// Listing all shops:
TextUtils.sendMessage(sender, Settings.msgListAllShopsHeader,
TextUtils.sendMessage(sender, Messages.listAllShopsHeader,
"shopsCount", shopsCount,
"page", page,
"maxPage", maxPage
);
} else if (listAdminShops) {
// Listing admin shops:
TextUtils.sendMessage(sender, Settings.msgListAdminShopsHeader,
TextUtils.sendMessage(sender, Messages.listAdminShopsHeader,
"shopsCount", shopsCount,
"page", page,
"maxPage", maxPage
);
} else {
// Listing player shops:
TextUtils.sendMessage(sender, Settings.msgListPlayerShopsHeader,
TextUtils.sendMessage(sender, Messages.listPlayerShopsHeader,
"player", TextUtils.getPlayerText(targetPlayerName, targetPlayerUUID),
"shopsCount", shopsCount,
"page", page,
@ -201,7 +201,7 @@ class CommandList extends Command {
// TODO Add shop info as hover text.
// TODO Add owner name/uuid as message arguments?
// TODO Move into shopkeeper.
TextUtils.sendMessage(sender, Settings.msgListShopsEntry,
TextUtils.sendMessage(sender, Messages.listShopsEntry,
"shopIndex", (index + 1),
"shopUUID", shopkeeper.getUniqueId().toString(),
// deprecated, use {shopId} instead; TODO Remove at some point

View File

@ -3,8 +3,8 @@ package com.nisovin.shopkeepers.commands.shopkeepers;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.SKShopkeepersPlugin;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.commands.lib.Command;
import com.nisovin.shopkeepers.commands.lib.CommandContextView;
@ -23,7 +23,7 @@ class CommandReload extends Command {
this.setPermission(ShopkeepersPlugin.RELOAD_PERMISSION);
// Set description:
this.setDescription(Settings.msgCommandDescriptionReload);
this.setDescription(Messages.commandDescriptionReload);
}
@Override

View File

@ -5,7 +5,7 @@ import java.util.Arrays;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.api.shopkeeper.Shopkeeper;
import com.nisovin.shopkeepers.commands.arguments.ShopkeeperArgument;
@ -30,7 +30,7 @@ class CommandRemote extends Command {
this.setPermission(ShopkeepersPlugin.REMOTE_PERMISSION);
// Set description:
this.setDescription(Settings.msgCommandDescriptionRemote);
this.setDescription(Messages.commandDescriptionRemote);
// Arguments:
this.addArgument(new TargetShopkeeperFallback(

View File

@ -10,7 +10,7 @@ import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.api.events.PlayerDeleteShopkeeperEvent;
import com.nisovin.shopkeepers.api.shopkeeper.Shopkeeper;
@ -55,7 +55,7 @@ class CommandRemove extends Command {
// Permission gets checked by testPermission and during execution.
// Set description:
this.setDescription(Settings.msgCommandDescriptionRemove);
this.setDescription(Messages.commandDescriptionRemove);
// Arguments: TODO Allow specifying a single shopkeeper?
this.addArgument(new FirstOfArgument("target", Arrays.asList(
@ -200,17 +200,17 @@ class CommandRemove extends Command {
// Print the result message:
if (admin) {
// Removed all admin shops:
TextUtils.sendMessage(sender, Settings.msgRemovedAdminShops,
TextUtils.sendMessage(sender, Messages.removedAdminShops,
"shopsCount", actualShopCount
);
} else if (all) {
// Removed all player shops:
TextUtils.sendMessage(sender, Settings.msgRemovedPlayerShops,
TextUtils.sendMessage(sender, Messages.removedPlayerShops,
"shopsCount", actualShopCount
);
} else {
// Removed all shops of the specified player:
TextUtils.sendMessage(sender, Settings.msgRemovedShopsOfPlayer,
TextUtils.sendMessage(sender, Messages.removedShopsOfPlayer,
"player", TextUtils.getPlayerText(finalTargetPlayerName, finalTargetPlayerUUID),
"shopsCount", actualShopCount
);
@ -223,28 +223,28 @@ class CommandRemove extends Command {
int shopsCount = affectedShops.size();
if (admin) {
// Removing all admin shops:
TextUtils.sendMessage(sender, Settings.msgConfirmRemoveAllAdminShops,
TextUtils.sendMessage(sender, Messages.confirmRemoveAllAdminShops,
"shopsCount", shopsCount
);
} else if (all) {
// Removing all player shops:
TextUtils.sendMessage(sender, Settings.msgConfirmRemoveAllPlayerShops,
TextUtils.sendMessage(sender, Messages.confirmRemoveAllPlayerShops,
"shopsCount", shopsCount
);
} else if (targetOwnShops) {
// Removing own shops:
TextUtils.sendMessage(sender, Settings.msgConfirmRemoveAllOwnShops,
TextUtils.sendMessage(sender, Messages.confirmRemoveAllOwnShops,
"shopsCount", shopsCount
);
} else {
// Removing shops of specific player:
TextUtils.sendMessage(sender, Settings.msgConfirmRemoveAllShopsOfPlayer,
TextUtils.sendMessage(sender, Messages.confirmRemoveAllShopsOfPlayer,
"player", TextUtils.getPlayerText(targetPlayerName, targetPlayerUUID),
"shopsCount", shopsCount
);
}
// Inform player on how to confirm the action:
// TODO Add clickable command suggestion?
TextUtils.sendMessage(sender, Settings.msgConfirmationRequired);
TextUtils.sendMessage(sender, Messages.confirmationRequired);
}
}

View File

@ -3,7 +3,7 @@ package com.nisovin.shopkeepers.commands.shopkeepers;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.api.shopkeeper.player.PlayerShopkeeper;
import com.nisovin.shopkeepers.commands.arguments.ShopkeeperArgument;
@ -29,7 +29,7 @@ class CommandSetForHire extends PlayerCommand {
this.setPermission(ShopkeepersPlugin.SET_FOR_HIRE_PERMISSION);
// Set description:
this.setDescription(Settings.msgCommandDescriptionSetforhire);
this.setDescription(Messages.commandDescriptionSetforhire);
// Arguments:
this.addArgument(new TargetShopkeeperFallback(
@ -50,13 +50,13 @@ class CommandSetForHire extends PlayerCommand {
if (ItemUtils.isEmpty(hireCost)) {
// TODO Allow disabling hiring again, maybe with empty hand?
// TODO Show hire item via hover event?
TextUtils.sendMessage(player, Settings.msgMustHoldHireItem);
TextUtils.sendMessage(player, Messages.mustHoldHireItem);
return;
}
// Check that the shop is owned by the executing player:
if (!shopkeeper.isOwner(player) && !PermissionUtils.hasPermission(player, ShopkeepersPlugin.BYPASS_PERMISSION)) {
TextUtils.sendMessage(player, Settings.msgNotOwner);
TextUtils.sendMessage(player, Messages.notOwner);
return;
} else {
// Set for hire:
@ -64,7 +64,7 @@ class CommandSetForHire extends PlayerCommand {
}
// Success:
TextUtils.sendMessage(player, Settings.msgSetForHire);
TextUtils.sendMessage(player, Messages.setForHire);
// Save:
ShopkeepersPlugin.getInstance().getShopkeeperStorage().save();

View File

@ -4,7 +4,7 @@ import java.util.Arrays;
import org.bukkit.command.CommandSender;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.api.shopkeeper.Shopkeeper;
import com.nisovin.shopkeepers.api.shopkeeper.admin.AdminShopkeeper;
@ -36,7 +36,7 @@ class CommandSetTradePerm extends Command {
this.setPermission(ShopkeepersPlugin.SET_TRADE_PERM_PERMISSION);
// Set description:
this.setDescription(Settings.msgCommandDescriptionSettradeperm);
this.setDescription(Messages.commandDescriptionSettradeperm);
// Arguments:
this.addArgument(new TargetShopkeeperFallback(
@ -65,13 +65,13 @@ class CommandSetTradePerm extends Command {
if (removePerm) {
// Remove trade permission:
assert newTradePerm == null;
TextUtils.sendMessage(sender, Settings.msgTradePermRemoved, "perm", currentTradePerm);
TextUtils.sendMessage(sender, Messages.tradePermRemoved, "perm", currentTradePerm);
} else if (newTradePerm != null) {
// Set trade permission:
TextUtils.sendMessage(sender, Settings.msgTradePermSet, "perm", newTradePerm);
TextUtils.sendMessage(sender, Messages.tradePermSet, "perm", newTradePerm);
} else {
// Display current trade permission:
TextUtils.sendMessage(sender, Settings.msgTradePermView, "perm", currentTradePerm);
TextUtils.sendMessage(sender, Messages.tradePermView, "perm", currentTradePerm);
return;
}

View File

@ -3,7 +3,7 @@ package com.nisovin.shopkeepers.commands.shopkeepers;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.api.shopkeeper.player.PlayerShopkeeper;
import com.nisovin.shopkeepers.commands.arguments.ShopkeeperArgument;
@ -30,7 +30,7 @@ class CommandTransfer extends Command {
this.setPermission(ShopkeepersPlugin.TRANSFER_PERMISSION);
// Set description:
this.setDescription(Settings.msgCommandDescriptionTransfer);
this.setDescription(Messages.commandDescriptionTransfer);
// Arguments:
this.addArgument(new TargetShopkeeperFallback(
@ -53,7 +53,7 @@ class CommandTransfer extends Command {
// Check that the shop is owned by the executing player:
Player player = (sender instanceof Player) ? (Player) sender : null;
if ((player == null || !shopkeeper.isOwner(player)) && !PermissionUtils.hasPermission(sender, ShopkeepersPlugin.BYPASS_PERMISSION)) {
TextUtils.sendMessage(sender, Settings.msgNotOwner);
TextUtils.sendMessage(sender, Messages.notOwner);
return;
}
@ -61,7 +61,7 @@ class CommandTransfer extends Command {
shopkeeper.setOwner(newOwner);
// Success:
TextUtils.sendMessage(player, Settings.msgOwnerSet, "owner", TextUtils.getPlayerText(newOwner));
TextUtils.sendMessage(player, Messages.ownerSet, "owner", TextUtils.getPlayerText(newOwner));
// Save:
ShopkeepersPlugin.getInstance().getShopkeeperStorage().save();

View File

@ -11,6 +11,7 @@ import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
import org.bukkit.util.RayTraceResult;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.SKShopkeepersPlugin;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
@ -53,14 +54,14 @@ public class ShopkeepersCommand extends BaseCommand {
// Permission gets checked by testPermission and during execution.
// Description:
this.setDescription(Settings.msgCommandDescriptionShopkeeper);
this.setDescription(Messages.commandDescriptionShopkeeper);
// Formatting:
this.setHelpTitleFormat(Settings.msgCommandHelpTitle.setPlaceholderArguments(
this.setHelpTitleFormat(Messages.commandHelpTitle.setPlaceholderArguments(
Collections.singletonMap("version", plugin.getDescription().getVersion())
));
this.setHelpUsageFormat(Settings.msgCommandHelpUsageFormat);
this.setHelpDescFormat(Settings.msgCommandHelpDescriptionFormat);
this.setHelpUsageFormat(Messages.commandHelpUsageFormat);
this.setHelpDescFormat(Messages.commandHelpDescriptionFormat);
// Arguments for shopkeeper creation:
this.addArgument(new OptionalArgument<>(new ShopTypeArgument(ARGUMENT_SHOP_TYPE)));
@ -113,7 +114,7 @@ public class ShopkeepersCommand extends BaseCommand {
// Check for valid targeted block:
if (targetBlockInfo == null) {
TextUtils.sendMessage(player, Settings.msgShopCreateFail);
TextUtils.sendMessage(player, Messages.shopCreateFail);
return;
}
Block targetBlock = targetBlockInfo.getHitBlock();
@ -138,14 +139,14 @@ public class ShopkeepersCommand extends BaseCommand {
if (shopType == null || shopObjType == null) {
// The player cannot create shops at all:
TextUtils.sendMessage(player, Settings.msgNoPermission);
TextUtils.sendMessage(player, Messages.noPermission);
return;
}
// Validate the selected shop type:
if (!(shopType instanceof PlayerShopType)) {
// Only player shop types are allowed here:
TextUtils.sendMessage(player, Settings.msgNoPlayerShopTypeSelected);
TextUtils.sendMessage(player, Messages.noPlayerShopTypeSelected);
return;
}
} else {
@ -153,7 +154,7 @@ public class ShopkeepersCommand extends BaseCommand {
// Check permission:
if (!PermissionUtils.hasPermission(player, ShopkeepersPlugin.ADMIN_PERMISSION)) {
TextUtils.sendMessage(sender, Settings.msgNoPermission);
TextUtils.sendMessage(sender, Messages.noPermission);
return;
}
@ -169,7 +170,7 @@ public class ShopkeepersCommand extends BaseCommand {
// Validate the selected shop type:
if (!(shopType instanceof AdminShopType)) {
// Only admin shop types are allowed here:
TextUtils.sendMessage(player, Settings.msgNoAdminShopTypeSelected);
TextUtils.sendMessage(player, Messages.noAdminShopTypeSelected);
return;
}
}

View File

@ -0,0 +1,142 @@
package com.nisovin.shopkeepers.config;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.stream.Collectors;
import org.bukkit.Material;
import org.bukkit.configuration.Configuration;
import com.nisovin.shopkeepers.text.Text;
import com.nisovin.shopkeepers.util.ConfigUtils;
import com.nisovin.shopkeepers.util.ItemData;
import com.nisovin.shopkeepers.util.Log;
import com.nisovin.shopkeepers.util.TextUtils;
public class ConfigHelper {
private ConfigHelper() {
}
public static String toConfigKey(String fieldName) {
return fieldName.replaceAll("([A-Z][a-z]+)", "-$1").toLowerCase(Locale.ROOT);
}
public static Object loadConfigValue(Configuration config, String configKey, Set<String> noColorConversionKeys, Class<?> typeClass, Class<?> genericType) {
if (typeClass == String.class || typeClass == Text.class) {
String string = config.getString(configKey);
// Colorize, if not exempted:
if (!noColorConversionKeys.contains(configKey)) {
string = TextUtils.colorize(string);
}
if (typeClass == Text.class) {
return Text.parse(string);
} else {
return string;
}
} else if (typeClass == int.class) {
return config.getInt(configKey);
} else if (typeClass == short.class) {
return (short) config.getInt(configKey);
} else if (typeClass == boolean.class) {
return config.getBoolean(configKey);
} else if (typeClass == Material.class) {
// This assumes that legacy item conversion has already been performed
Material material = ConfigUtils.loadMaterial(config, configKey);
if (material == null) {
Log.warning("Config: Unknown material for config entry '" + configKey + "': " + config.get(configKey));
Log.warning("Config: All valid material names can be found here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html");
}
return material;
} else if (typeClass == ItemData.class) {
ItemData itemData = loadItemData(config.get(configKey), configKey);
// Normalize to not null:
if (itemData == null) {
itemData = new ItemData(Material.AIR);
}
return itemData;
} else if (typeClass == List.class) {
if (genericType == String.class || genericType == Text.class) {
List<String> stringList = config.getStringList(configKey);
// Colorize, if not exempted:
if (!noColorConversionKeys.contains(configKey)) {
stringList = TextUtils.colorize(stringList);
}
if (genericType == Text.class) {
return Text.parse(stringList);
} else {
return stringList;
}
} else if (genericType == ItemData.class) {
List<?> list = config.getList(configKey, Collections.emptyList());
List<ItemData> itemDataList = new ArrayList<>(list.size());
int index = 0;
for (Object entry : list) {
index += 1;
ItemData itemData = loadItemData(entry, configKey + "[" + index + "]");
if (itemData != null) {
itemDataList.add(itemData);
}
}
return itemDataList;
} else {
throw new IllegalStateException("Unsupported config setting list type: " + genericType.getName());
}
}
throw new IllegalStateException("Unsupported config setting type: " + typeClass.getName());
}
public static ItemData loadItemData(Object dataObject, String configEntryIdentifier) {
ItemData itemData = ItemData.deserialize(dataObject, (warning) -> {
Log.warning("Config: Couldn't load item data for config entry '" + configEntryIdentifier + "': " + warning);
if (warning.contains("Unknown item type")) { // TODO this is ugly
Log.warning("Config: All valid material names can be found here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html");
}
});
return itemData;
}
public static void setConfigValue(Configuration config, String configKey, Set<String> noColorConversionKeys, Class<?> typeClass, Class<?> genericType, Object value) {
if (value == null) {
// Remove value:
config.set(configKey, null);
return;
}
if (typeClass == Material.class) {
config.set(configKey, ((Material) value).name());
} else if (typeClass == String.class || typeClass == Text.class) {
String stringValue;
if (typeClass == Text.class) {
stringValue = ((Text) value).toPlainFormatText();
} else {
stringValue = (String) value;
}
// Decolorize, if not exempted:
if (!noColorConversionKeys.contains(configKey)) {
value = TextUtils.decolorize(stringValue);
}
config.set(configKey, value);
} else if (typeClass == List.class && (genericType == String.class || genericType == Text.class)) {
List<String> stringList;
if (genericType == Text.class) {
stringList = ((List<Text>) value).stream().map(Text::toPlainFormatText).collect(Collectors.toList());
} else {
stringList = (List<String>) value;
}
// Decolorize, if not exempted:
if (!noColorConversionKeys.contains(configKey)) {
value = TextUtils.decolorize(stringList);
}
config.set(configKey, value);
} else if (typeClass == ItemData.class) {
config.set(configKey, ((ItemData) value).serialize());
} else {
config.set(configKey, value);
}
}
}

View File

@ -0,0 +1,24 @@
package com.nisovin.shopkeepers.config.migration;
import org.bukkit.configuration.Configuration;
import com.nisovin.shopkeepers.util.Log;
/**
* Migrates the config from version 3 to version 4.
*/
public class ConfigMigration4 implements ConfigMigration {
@Override
public void apply(Configuration config) {
// Migrate language 'en' to 'en-default':
String key = "language";
if (config.isSet(key)) {
Object oldValue = config.get(key);
if (oldValue.equals("en")) {
Log.info(" Migrating setting '" + key + "' from value 'en' to new value 'en-default'.");
config.set(key, "en-default");
}
}
}
}

View File

@ -18,7 +18,8 @@ public class ConfigMigrations {
private static final List<ConfigMigration> migrations = Arrays.asList(
new ConfigMigration1(),
new ConfigMigration2(),
new ConfigMigration3()
new ConfigMigration3(),
new ConfigMigration4()
);
public static int getLatestVersion() {

View File

@ -9,6 +9,7 @@ import org.bukkit.event.HandlerList;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.api.shopkeeper.Shopkeeper;
@ -93,7 +94,7 @@ public class ItemConversions {
// Inform player:
if (convertedStacks > 0 && informPlayer) {
TextUtils.sendMessage(player, Settings.msgItemsConverted,
TextUtils.sendMessage(player, Messages.itemsConverted,
"count", convertedStacks
);
}

View File

@ -7,8 +7,8 @@ import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.SKShopkeepersPlugin;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.api.events.ShopkeeperEditedEvent;
import com.nisovin.shopkeepers.api.shopkeeper.Shopkeeper;
import com.nisovin.shopkeepers.shopkeeper.AbstractShopkeeper;
@ -67,7 +67,7 @@ public class ShopkeeperNaming {
} else {
// Validate name:
if (!((AbstractShopkeeper) shopkeeper).isValidName(newName)) {
TextUtils.sendMessage(player, Settings.msgNameInvalid);
TextUtils.sendMessage(player, Messages.nameInvalid);
return false;
}
}
@ -78,12 +78,12 @@ public class ShopkeeperNaming {
// Compare to previous name:
if (oldName.equals(shopkeeper.getName())) {
TextUtils.sendMessage(player, Settings.msgNameHasNotChanged);
TextUtils.sendMessage(player, Messages.nameHasNotChanged);
return false;
}
// Inform player:
TextUtils.sendMessage(player, Settings.msgNameSet);
TextUtils.sendMessage(player, Messages.nameSet);
// Close all open windows:
shopkeeper.abortUISessionsDelayed(); // TODO Really needed?

View File

@ -19,6 +19,7 @@ import org.bukkit.event.player.PlayerItemHeldEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.SKShopkeepersPlugin;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
@ -63,7 +64,7 @@ class CreateListener implements Listener {
}
// Print info message about usage:
TextUtils.sendMessage(player, Settings.msgCreationItemSelected);
TextUtils.sendMessage(player, Messages.creationItemSelected);
}
// Since this might check container access by calling another dummy interaction event, we handle (cancel) this event
@ -128,7 +129,7 @@ class CreateListener implements Listener {
if (shopType == null || shopObjType == null) {
// The player cannot create any shops at all:
TextUtils.sendMessage(player, Settings.msgNoPermission);
TextUtils.sendMessage(player, Messages.noPermission);
return;
}
@ -168,12 +169,12 @@ class CreateListener implements Listener {
if (shopkeeperCreation.handleCheckContainer(player, clickedBlock)) {
// Select container:
shopkeeperCreation.selectContainer(player, clickedBlock);
TextUtils.sendMessage(player, Settings.msgContainerSelected);
TextUtils.sendMessage(player, Messages.containerSelected);
}
} else if (ItemUtils.isContainer(clickedBlock.getType())) {
// Player clicked a type of container which cannot be used for shops:
isContainerSelection = true;
TextUtils.sendMessage(player, Settings.msgUnsupportedContainer);
TextUtils.sendMessage(player, Messages.unsupportedContainer);
}
}
@ -181,7 +182,7 @@ class CreateListener implements Listener {
// Player shop creation:
if (selectedContainer == null) {
// Clicked a location without having a container selected:
TextUtils.sendMessage(player, Settings.msgMustSelectContainer);
TextUtils.sendMessage(player, Messages.mustSelectContainer);
return;
}
assert ShopContainers.isSupportedContainer(selectedContainer.getType()); // Checked above already
@ -189,7 +190,7 @@ class CreateListener implements Listener {
// Validate the selected shop type:
if (!(shopType instanceof PlayerShopType)) {
// Only player shop types are allowed here:
TextUtils.sendMessage(player, Settings.msgNoPlayerShopTypeSelected);
TextUtils.sendMessage(player, Messages.noPlayerShopTypeSelected);
return;
}

View File

@ -11,6 +11,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.SKShopkeepersPlugin;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.container.ShopContainers;
@ -91,20 +92,20 @@ public class ShopkeeperCreation {
public boolean handleCheckContainer(Player player, Block containerBlock) {
// Check if the container is already used by some other shopkeeper:
if (SKShopkeepersPlugin.getInstance().getProtectedContainers().isContainerProtected(containerBlock, null)) {
TextUtils.sendMessage(player, Settings.msgContainerAlreadyInUse);
TextUtils.sendMessage(player, Messages.containerAlreadyInUse);
return false;
}
// Check for recently placed:
if (Settings.requireContainerRecentlyPlaced && !plugin.getShopkeeperCreation().isRecentlyPlacedContainer(player, containerBlock)) {
// Container was not recently placed:
TextUtils.sendMessage(player, Settings.msgContainerNotPlaced);
TextUtils.sendMessage(player, Messages.containerNotPlaced);
return false;
}
// Check if the player can access the container:
if (!Utils.checkBlockInteract(player, containerBlock)) { // checks access via dummy interact event
TextUtils.sendMessage(player, Settings.msgNoContainerAccess);
TextUtils.sendMessage(player, Messages.noContainerAccess);
return false;
}
return true;

View File

@ -9,8 +9,8 @@ import org.bukkit.block.BlockFace;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.SKShopkeepersPlugin;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.api.events.PlayerCreateShopkeeperEvent;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.api.shopkeeper.ShopType;
@ -34,14 +34,14 @@ public abstract class AbstractShopType<T extends AbstractShopkeeper> extends Abs
@Override
protected void onSelect(Player player) {
TextUtils.sendMessage(player, Settings.msgSelectedShopType,
TextUtils.sendMessage(player, Messages.selectedShopType,
"type", this.getDisplayName(),
"description", this.getDescription()
);
}
protected Text getCreatedMessage() {
Text text = Settings.msgShopkeeperCreated;
Text text = Messages.shopkeeperCreated;
text.setPlaceholderArguments(
"type", this.getDisplayName(),
"description", this.getDescription(),
@ -91,21 +91,21 @@ public abstract class AbstractShopType<T extends AbstractShopkeeper> extends Abs
// Can the selected shop type be used?
if (!shopType.hasPermission(creator)) {
TextUtils.sendMessage(creator, Settings.msgNoPermission);
TextUtils.sendMessage(creator, Messages.noPermission);
return null;
}
if (!shopType.isEnabled()) {
TextUtils.sendMessage(creator, Settings.msgShopTypeDisabled, "type", shopType.getIdentifier());
TextUtils.sendMessage(creator, Messages.shopTypeDisabled, "type", shopType.getIdentifier());
return null;
}
// Can the selected shop object type be used?
if (!shopObjectType.hasPermission(creator)) {
TextUtils.sendMessage(creator, Settings.msgNoPermission);
TextUtils.sendMessage(creator, Messages.noPermission);
return null;
}
if (!shopObjectType.isEnabled()) {
TextUtils.sendMessage(creator, Settings.msgShopObjectTypeDisabled, "type", shopObjectType.getIdentifier());
TextUtils.sendMessage(creator, Messages.shopObjectTypeDisabled, "type", shopObjectType.getIdentifier());
return null;
}
@ -115,13 +115,13 @@ public abstract class AbstractShopType<T extends AbstractShopkeeper> extends Abs
// Check if the shop can be placed there (enough space, etc.):
if (!shopObjectType.isValidSpawnLocation(spawnLocation, targetedBlockFace)) {
// Invalid spawn location or targeted block face:
TextUtils.sendMessage(creator, Settings.msgShopCreateFail);
TextUtils.sendMessage(creator, Messages.shopCreateFail);
return null;
}
if (spawnLocation != null && !shopkeeperRegistry.getShopkeepersAtLocation(spawnLocation).isEmpty()) {
// There is already a shopkeeper at that location:
TextUtils.sendMessage(creator, Settings.msgShopCreateFail);
TextUtils.sendMessage(creator, Messages.shopCreateFail);
return null;
}

View File

@ -3,7 +3,7 @@ package com.nisovin.shopkeepers.shopkeeper.admin;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.api.shopkeeper.ShopkeeperCreateException;
import com.nisovin.shopkeepers.api.shopkeeper.admin.AdminShopCreationData;
@ -38,7 +38,7 @@ public abstract class AbstractAdminShopkeeper extends AbstractShopkeeper impleme
if (tradePermission != null && !PermissionUtils.hasPermission(player, tradePermission)) {
if (!silent) {
Log.debug(() -> "Blocked trading UI opening for " + player.getName() + ": Missing custom trade permission '" + tradePermission + "'.");
TextUtils.sendMessage(player, Settings.msgMissingCustomTradePerm);
TextUtils.sendMessage(player, Messages.missingCustomTradePerm);
}
return false;
}

View File

@ -4,7 +4,7 @@ import java.util.List;
import org.bukkit.configuration.ConfigurationSection;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.api.shopkeeper.ShopkeeperCreateException;
@ -18,22 +18,22 @@ public class RegularAdminShopType extends AbstractAdminShopType<SKRegularAdminSh
@Override
public String getDisplayName() {
return Settings.msgShopTypeAdminRegular;
return Messages.shopTypeAdminRegular;
}
@Override
public String getDescription() {
return Settings.msgShopTypeDescAdminRegular;
return Messages.shopTypeDescAdminRegular;
}
@Override
public String getSetupDescription() {
return Settings.msgShopSetupDescAdminRegular;
return Messages.shopSetupDescAdminRegular;
}
@Override
public List<String> getTradeSetupDescription() {
return Settings.msgTradeSetupDescAdminRegular;
return Messages.tradeSetupDescAdminRegular;
}
@Override

View File

@ -7,6 +7,7 @@ import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.SKShopkeepersPlugin;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.api.events.PlayerCreatePlayerShopkeeperEvent;
@ -45,14 +46,14 @@ public abstract class AbstractPlayerShopType<T extends AbstractPlayerShopkeeper>
Block containerBlock = playerShopCreationData.getShopContainer();
if (!ShopContainers.isSupportedContainer(containerBlock.getType())) {
// The block is not / no longer a supported container:
TextUtils.sendMessage(creator, Settings.msgInvalidContainer);
TextUtils.sendMessage(creator, Messages.invalidContainer);
return false;
}
// Check if the selected container is too far away:
if (!containerBlock.getWorld().equals(spawnLocation.getWorld())
|| (int) containerBlock.getLocation().distanceSquared(spawnLocation) > (Settings.maxContainerDistance * Settings.maxContainerDistance)) {
TextUtils.sendMessage(creator, Settings.msgContainerTooFarAway);
TextUtils.sendMessage(creator, Messages.containerTooFarAway);
return false;
}
@ -64,7 +65,7 @@ public abstract class AbstractPlayerShopType<T extends AbstractPlayerShopkeeper>
// Check worldguard:
if (Settings.enableWorldGuardRestrictions) {
if (!WorldGuardHandler.isShopAllowed(creator, spawnLocation)) {
TextUtils.sendMessage(creator, Settings.msgShopCreateFail);
TextUtils.sendMessage(creator, Messages.shopCreateFail);
return false;
}
}
@ -72,7 +73,7 @@ public abstract class AbstractPlayerShopType<T extends AbstractPlayerShopkeeper>
// Check towny:
if (Settings.enableTownyRestrictions) {
if (!TownyHandler.isCommercialArea(spawnLocation)) {
TextUtils.sendMessage(creator, Settings.msgShopCreateFail);
TextUtils.sendMessage(creator, Messages.shopCreateFail);
return false;
}
}
@ -92,7 +93,7 @@ public abstract class AbstractPlayerShopType<T extends AbstractPlayerShopkeeper>
if (maxShopsLimit > 0) {
int count = SKShopkeepersPlugin.getInstance().getShopkeeperRegistry().getPlayerShopkeepersByOwner(creator.getUniqueId()).size();
if (count >= maxShopsLimit) {
TextUtils.sendMessage(creator, Settings.msgTooManyShops);
TextUtils.sendMessage(creator, Messages.tooManyShops);
return false;
}
}

View File

@ -6,6 +6,7 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.SKShopkeepersPlugin;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.api.events.PlayerShopkeeperHireEvent;
@ -65,7 +66,7 @@ public class PlayerShopHiringHandler extends HiringHandler {
if (Settings.hireRequireCreationPermission && (!this.getShopkeeper().getType().hasPermission(player)
|| !this.getShopkeeper().getShopObject().getType().hasPermission(player))) {
// Missing permission to hire this type of shopkeeper:
TextUtils.sendMessage(player, Settings.msgCantHireShopType);
TextUtils.sendMessage(player, Messages.cantHireShopType);
this.getUISession(player).abortDelayed();
return;
}
@ -95,7 +96,7 @@ public class PlayerShopHiringHandler extends HiringHandler {
if (hireCost.getAmount() != 0) {
// Not enough money:
TextUtils.sendMessage(player, Settings.msgCantHire);
TextUtils.sendMessage(player, Messages.cantHire);
// Close window for this player:
this.getUISession(player).abortDelayed();
return;
@ -117,7 +118,7 @@ public class PlayerShopHiringHandler extends HiringHandler {
if (maxShops > 0) {
int count = SKShopkeepersPlugin.getInstance().getShopkeeperRegistry().getPlayerShopkeepersByOwner(player.getUniqueId()).size();
if (count >= maxShops) {
TextUtils.sendMessage(player, Settings.msgTooManyShops);
TextUtils.sendMessage(player, Messages.tooManyShops);
this.getUISession(player).abortDelayed();
return;
}
@ -128,7 +129,7 @@ public class PlayerShopHiringHandler extends HiringHandler {
shopkeeper.setForHire(null);
shopkeeper.setOwner(player);
shopkeeper.save();
TextUtils.sendMessage(player, Settings.msgHired);
TextUtils.sendMessage(player, Messages.hired);
// Close all open windows for this shopkeeper:
shopkeeper.abortUISessionsDelayed();

View File

@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.api.shopkeeper.player.PlayerShopkeeper;
@ -41,7 +42,7 @@ public abstract class PlayerShopTradingHandler extends TradingHandler {
if (ownerPlayer != null) {
if (!silent) {
Log.debug(() -> "Blocked trade window opening for " + player.getName() + ", because the shop owner is online.");
TextUtils.sendMessage(player, Settings.msgCantTradeWhileOwnerOnline, "owner", ownerPlayer.getName());
TextUtils.sendMessage(player, Messages.cantTradeWhileOwnerOnline, "owner", ownerPlayer.getName());
}
return false;
}
@ -58,7 +59,7 @@ public abstract class PlayerShopTradingHandler extends TradingHandler {
// No trading with own shop:
if (Settings.preventTradingWithOwnShop && shopkeeper.isOwner(tradingPlayer)
&& !PermissionUtils.hasPermission(tradingPlayer, ShopkeepersPlugin.BYPASS_PERMISSION)) {
TextUtils.sendMessage(tradingPlayer, Settings.msgCantTradeWithOwnShop);
TextUtils.sendMessage(tradingPlayer, Messages.cantTradeWithOwnShop);
this.debugPreventedTrade(tradingPlayer, "Trading with the own shop is not allowed.");
return false;
}
@ -68,7 +69,7 @@ public abstract class PlayerShopTradingHandler extends TradingHandler {
Player ownerPlayer = shopkeeper.getOwner();
if (ownerPlayer != null && !shopkeeper.isOwner(tradingPlayer)
&& !PermissionUtils.hasPermission(tradingPlayer, ShopkeepersPlugin.BYPASS_PERMISSION)) {
TextUtils.sendMessage(tradingPlayer, Settings.msgCantTradeWhileOwnerOnline, "owner", ownerPlayer.getName());
TextUtils.sendMessage(tradingPlayer, Messages.cantTradeWhileOwnerOnline, "owner", ownerPlayer.getName());
this.debugPreventedTrade(tradingPlayer, "Trading is not allowed while the shop owner is online.");
return false;
}
@ -77,7 +78,7 @@ public abstract class PlayerShopTradingHandler extends TradingHandler {
// Check for the shop's container:
Block container = shopkeeper.getContainer();
if (!ShopContainers.isSupportedContainer(container.getType())) {
TextUtils.sendMessage(tradingPlayer, Settings.msgCantTradeWithShopMissingContainer, "owner", shopkeeper.getOwnerName());
TextUtils.sendMessage(tradingPlayer, Messages.cantTradeWithShopMissingContainer, "owner", shopkeeper.getOwnerName());
this.debugPreventedTrade(tradingPlayer, "The shop's container is missing.");
return false;
}

View File

@ -4,7 +4,7 @@ import java.util.List;
import org.bukkit.configuration.ConfigurationSection;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.api.shopkeeper.ShopkeeperCreateException;
@ -19,22 +19,22 @@ public class BookPlayerShopType extends AbstractPlayerShopType<SKBookPlayerShopk
@Override
public String getDisplayName() {
return Settings.msgShopTypeBook;
return Messages.shopTypeBook;
}
@Override
public String getDescription() {
return Settings.msgShopTypeDescBook;
return Messages.shopTypeDescBook;
}
@Override
public String getSetupDescription() {
return Settings.msgShopSetupDescBook;
return Messages.shopSetupDescBook;
}
@Override
public List<String> getTradeSetupDescription() {
return Settings.msgTradeSetupDescBook;
return Messages.tradeSetupDescBook;
}
@Override

View File

@ -15,7 +15,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
import org.bukkit.inventory.meta.BookMeta.Generation;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.ShopkeeperCreateException;
import com.nisovin.shopkeepers.api.shopkeeper.TradingRecipe;
import com.nisovin.shopkeepers.api.shopkeeper.offers.BookOffer;
@ -199,7 +199,7 @@ public class SKBookPlayerShopkeeper extends AbstractPlayerShopkeeper implements
ItemStack item = new ItemStack(Material.WRITTEN_BOOK, 1);
BookMeta meta = (BookMeta) item.getItemMeta();
meta.setTitle(title);
meta.setAuthor(Settings.msgUnknownBookAuthor);
meta.setAuthor(Messages.unknownBookAuthor);
meta.setGeneration(Generation.TATTERED);
item.setItemMeta(meta);
return item;

View File

@ -5,7 +5,7 @@ import java.util.List;
import org.bukkit.configuration.ConfigurationSection;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.api.shopkeeper.ShopkeeperCreateException;
@ -20,22 +20,22 @@ public class BuyingPlayerShopType extends AbstractPlayerShopType<SKBuyingPlayerS
@Override
public String getDisplayName() {
return Settings.msgShopTypeBuying;
return Messages.shopTypeBuying;
}
@Override
public String getDescription() {
return Settings.msgShopTypeDescBuying;
return Messages.shopTypeDescBuying;
}
@Override
public String getSetupDescription() {
return Settings.msgShopSetupDescBuying;
return Messages.shopSetupDescBuying;
}
@Override
public List<String> getTradeSetupDescription() {
return Settings.msgTradeSetupDescBuying;
return Messages.tradeSetupDescBuying;
}
@Override

View File

@ -5,7 +5,7 @@ import java.util.List;
import org.bukkit.configuration.ConfigurationSection;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.api.shopkeeper.ShopkeeperCreateException;
@ -20,22 +20,22 @@ public class SellingPlayerShopType extends AbstractPlayerShopType<SKSellingPlaye
@Override
public String getDisplayName() {
return Settings.msgShopTypeSelling;
return Messages.shopTypeSelling;
}
@Override
public String getDescription() {
return Settings.msgShopTypeDescSelling;
return Messages.shopTypeDescSelling;
}
@Override
public String getSetupDescription() {
return Settings.msgShopSetupDescSelling;
return Messages.shopSetupDescSelling;
}
@Override
public List<String> getTradeSetupDescription() {
return Settings.msgTradeSetupDescSelling;
return Messages.tradeSetupDescSelling;
}
@Override

View File

@ -5,7 +5,7 @@ import java.util.List;
import org.bukkit.configuration.ConfigurationSection;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.api.shopkeeper.ShopkeeperCreateException;
@ -20,22 +20,22 @@ public class TradingPlayerShopType extends AbstractPlayerShopType<SKTradingPlaye
@Override
public String getDisplayName() {
return Settings.msgShopTypeTrading;
return Messages.shopTypeTrading;
}
@Override
public String getDescription() {
return Settings.msgShopTypeDescTrading;
return Messages.shopTypeDescTrading;
}
@Override
public String getSetupDescription() {
return Settings.msgShopSetupDescTrading;
return Messages.shopSetupDescTrading;
}
@Override
public List<String> getTradeSetupDescription() {
return Settings.msgTradeSetupDescTrading;
return Messages.tradeSetupDescTrading;
}
@Override

View File

@ -7,7 +7,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.api.shopobjects.ShopObjectType;
import com.nisovin.shopkeepers.shopkeeper.AbstractShopkeeper;
@ -27,7 +27,7 @@ public abstract class AbstractShopObjectType<T extends AbstractShopObject> exten
@Override
protected void onSelect(Player player) {
TextUtils.sendMessage(player, Settings.msgSelectedShopObjectType, "type", this.getDisplayName());
TextUtils.sendMessage(player, Messages.selectedShopObjectType, "type", this.getDisplayName());
}
/**

View File

@ -7,7 +7,7 @@ import org.bukkit.Location;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.api.shopobjects.citizens.CitizensShopObjectType;
import com.nisovin.shopkeepers.shopkeeper.AbstractShopkeeper;
@ -24,7 +24,7 @@ public class SKCitizensShopObjectType extends AbstractEntityShopObjectType<SKCit
@Override
public String getDisplayName() {
return Settings.msgShopObjectTypeNpc;
return Messages.shopObjectTypeNpc;
}
@Override

View File

@ -5,6 +5,7 @@ import java.util.List;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.api.shopobjects.living.LivingShopObjectType;
@ -39,7 +40,7 @@ public abstract class SKLivingShopObjectType<T extends SKLivingShopObject<?>> ex
@Override
public String getDisplayName() {
// TODO Translation support for the entity type name?
return TextUtils.replaceArguments(Settings.msgShopObjectTypeLiving, "type", StringUtils.normalize(entityType.name()));
return TextUtils.replaceArguments(Messages.shopObjectTypeLiving, "type", StringUtils.normalize(entityType.name()));
}
@Override

View File

@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.property.BooleanProperty;
import com.nisovin.shopkeepers.property.Property;
@ -106,7 +106,7 @@ public class BabyableShop<E extends Ageable> extends SKLivingShopObject<E> {
private ItemStack getBabyEditorItem() {
ItemStack iconItem = new ItemStack(Material.EGG);
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonBaby, Settings.msgButtonBabyLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonBaby, Messages.buttonBabyLore);
return iconItem;
}

View File

@ -12,7 +12,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.property.EnumProperty;
import com.nisovin.shopkeepers.property.Property;
@ -148,7 +148,7 @@ public class CatShop extends SittableShop<Cat> {
ItemUtils.setLeatherColor(iconItem, Color.PURPLE);
break;
}
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonCatVariant, Settings.msgButtonCatVariantLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonCatVariant, Messages.buttonCatVariantLore);
return iconItem;
}
@ -198,7 +198,7 @@ public class CatShop extends SittableShop<Cat> {
} else {
iconItem = new ItemStack(ItemUtils.getWoolType(collarColor));
}
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonCollarColor, Settings.msgButtonCollarColorLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonCollarColor, Messages.buttonCollarColorLore);
return iconItem;
}

View File

@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.property.BooleanProperty;
import com.nisovin.shopkeepers.property.Property;
@ -76,7 +76,7 @@ public class ChestedHorseShop<E extends ChestedHorse> extends BabyableShop<E> {
private ItemStack getCarryingChestEditorItem() {
ItemStack iconItem = new ItemStack(Material.CHEST);
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonCarryingChest, Settings.msgButtonCarryingChestLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonCarryingChest, Messages.buttonCarryingChestLore);
return iconItem;
}

View File

@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.property.BooleanProperty;
import com.nisovin.shopkeepers.property.Property;
@ -82,7 +82,7 @@ public class CreeperShop extends SKLivingShopObject<Creeper> {
} else {
iconItem = new ItemStack(Material.LIME_WOOL);
}
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonCreeperCharged, Settings.msgButtonCreeperChargedLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonCreeperCharged, Messages.buttonCreeperChargedLore);
return iconItem;
}

View File

@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.property.BooleanProperty;
import com.nisovin.shopkeepers.property.EnumProperty;
@ -106,7 +106,7 @@ public class FoxShop extends SittableShop<Fox> {
ItemUtils.setLeatherColor(iconItem, Color.ORANGE);
break;
}
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonFoxVariant, Settings.msgButtonFoxVariantLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonFoxVariant, Messages.buttonFoxVariantLore);
return iconItem;
}
@ -150,7 +150,7 @@ public class FoxShop extends SittableShop<Fox> {
private ItemStack getSleepingEditorItem() {
ItemStack iconItem = new ItemStack(sleeping ? Material.GREEN_BED : Material.RED_BED);
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonFoxSleeping, Settings.msgButtonFoxSleepingLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonFoxSleeping, Messages.buttonFoxSleepingLore);
return iconItem;
}
@ -194,7 +194,7 @@ public class FoxShop extends SittableShop<Fox> {
private ItemStack getCrouchingEditorItem() {
ItemStack iconItem = new ItemStack(crouching ? Material.GREEN_CARPET : Material.RED_CARPET);
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonFoxCrouching, Settings.msgButtonFoxCrouchingLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonFoxCrouching, Messages.buttonFoxCrouchingLore);
return iconItem;
}

View File

@ -15,7 +15,7 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BannerMeta;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.property.EnumProperty;
import com.nisovin.shopkeepers.property.Property;
@ -140,7 +140,7 @@ public class HorseShop extends BabyableShop<Horse> {
ItemUtils.setLeatherColor(iconItem, Color.WHITE);
break;
}
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonHorseColor, Settings.msgButtonHorseColorLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonHorseColor, Messages.buttonHorseColorLore);
return iconItem;
}
@ -184,7 +184,7 @@ public class HorseShop extends BabyableShop<Horse> {
meta.addPattern(new Pattern(DyeColor.BROWN, PatternType.TRIANGLES_BOTTOM));
meta.addPattern(new Pattern(DyeColor.BROWN, PatternType.TRIANGLES_TOP));
iconItem.setItemMeta(meta);
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonHorseStyle, Settings.msgButtonHorseStyleLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonHorseStyle, Messages.buttonHorseStyleLore);
return iconItem;
}
@ -223,7 +223,7 @@ public class HorseShop extends BabyableShop<Horse> {
private ItemStack getArmorEditorItem() {
ItemStack iconItem = new ItemStack(armor == null ? Material.BARRIER : armor.getMaterial());
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonHorseArmor, Settings.msgButtonHorseArmorLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonHorseArmor, Messages.buttonHorseArmorLore);
return iconItem;
}

View File

@ -12,7 +12,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.property.EnumProperty;
import com.nisovin.shopkeepers.property.Property;
@ -106,7 +106,7 @@ public class LlamaShop<E extends Llama> extends ChestedHorseShop<E> {
ItemUtils.setLeatherColor(iconItem, Color.WHITE.mixDyes(DyeColor.ORANGE));
break;
}
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonLlamaVariant, Settings.msgButtonLlamaVariantLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonLlamaVariant, Messages.buttonLlamaVariantLore);
return iconItem;
}
@ -145,7 +145,7 @@ public class LlamaShop<E extends Llama> extends ChestedHorseShop<E> {
private ItemStack getCarpetColorEditorItem() {
ItemStack iconItem = new ItemStack(carpetColor == null ? Material.BARRIER : ItemUtils.getCarpetType(carpetColor));
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonLlamaCarpetColor, Settings.msgButtonLlamaCarpetColorLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonLlamaCarpetColor, Messages.buttonLlamaCarpetColorLore);
return iconItem;
}

View File

@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.property.IntegerProperty;
import com.nisovin.shopkeepers.shopkeeper.AbstractShopkeeper;
@ -91,8 +91,8 @@ public class MagmaCubeShop extends SKLivingShopObject<MagmaCube> {
private ItemStack getMagmaCubeSizeEditorItem() {
ItemStack iconItem = new ItemStack(Material.SLIME_BLOCK);
String displayName = TextUtils.replaceArguments(Settings.msgButtonMagmaCubeSize, "size", magmaCubeSize);
List<String> lore = TextUtils.replaceArguments(Settings.msgButtonMagmaCubeSizeLore, "size", magmaCubeSize);
String displayName = TextUtils.replaceArguments(Messages.buttonMagmaCubeSize, "size", magmaCubeSize);
List<String> lore = TextUtils.replaceArguments(Messages.buttonMagmaCubeSizeLore, "size", magmaCubeSize);
ItemUtils.setItemStackNameAndLore(iconItem, displayName, lore);
return iconItem;
}

View File

@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.property.EnumProperty;
import com.nisovin.shopkeepers.property.Property;
@ -88,7 +88,7 @@ public class MooshroomShop extends BabyableShop<MushroomCow> {
iconItem = new ItemStack(Material.BROWN_MUSHROOM);
break;
}
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonMooshroomVariant, Settings.msgButtonMooshroomVariantLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonMooshroomVariant, Messages.buttonMooshroomVariantLore);
return iconItem;
}

View File

@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.property.EnumProperty;
import com.nisovin.shopkeepers.property.Property;
@ -81,7 +81,7 @@ public class PandaShop extends BabyableShop<Panda> {
private ItemStack getGeneEditorItem() {
ItemStack iconItem = new ItemStack(Material.PANDA_SPAWN_EGG);
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonPandaVariant, Settings.msgButtonPandaVariantLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonPandaVariant, Messages.buttonPandaVariantLore);
return iconItem;
}

View File

@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.property.EnumProperty;
import com.nisovin.shopkeepers.property.Property;
@ -97,7 +97,7 @@ public class ParrotShop extends SittableShop<Parrot> {
iconItem = new ItemStack(ItemUtils.getWoolType(DyeColor.RED));
break;
}
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonParrotVariant, Settings.msgButtonParrotVariantLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonParrotVariant, Messages.buttonParrotVariantLore);
return iconItem;
}

View File

@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.property.BooleanProperty;
import com.nisovin.shopkeepers.property.Property;
@ -76,7 +76,7 @@ public class PigShop extends BabyableShop<Pig> {
private ItemStack getSaddleEditorItem() {
ItemStack iconItem = new ItemStack(Material.SADDLE);
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonPigSaddle, Settings.msgButtonPigSaddleLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonPigSaddle, Messages.buttonPigSaddleLore);
return iconItem;
}

View File

@ -11,7 +11,7 @@ import org.bukkit.entity.Rabbit;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.property.EnumProperty;
import com.nisovin.shopkeepers.property.Property;
@ -120,7 +120,7 @@ public class RabbitShop extends BabyableShop<Rabbit> {
ItemUtils.setLeatherColor(iconItem, Color.PURPLE);
break;
}
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonRabbitVariant, Settings.msgButtonRabbitVariantLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonRabbitVariant, Messages.buttonRabbitVariantLore);
return iconItem;
}

View File

@ -11,7 +11,7 @@ import org.bukkit.entity.Sheep;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.property.BooleanProperty;
import com.nisovin.shopkeepers.property.EnumProperty;
@ -87,7 +87,7 @@ public class SheepShop extends BabyableShop<Sheep> {
private ItemStack getColorEditorItem() {
ItemStack iconItem = new ItemStack(ItemUtils.getWoolType(color));
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonSheepColor, Settings.msgButtonSheepColorLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonSheepColor, Messages.buttonSheepColorLore);
return iconItem;
}
@ -126,7 +126,7 @@ public class SheepShop extends BabyableShop<Sheep> {
private ItemStack getShearedEditorItem() {
ItemStack iconItem = new ItemStack(Material.SHEARS);
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonSheepSheared, Settings.msgButtonSheepShearedLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonSheepSheared, Messages.buttonSheepShearedLore);
return iconItem;
}

View File

@ -11,7 +11,7 @@ import org.bukkit.entity.Sittable;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.property.BooleanProperty;
import com.nisovin.shopkeepers.property.Property;
@ -78,7 +78,7 @@ public class SittableShop<E extends Ageable & Sittable> extends BabyableShop<E>
private ItemStack getSittingEditorItem() {
ItemStack iconItem = new ItemStack(Material.IRON_HORSE_ARMOR);
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonSitting, Settings.msgButtonSittingLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonSitting, Messages.buttonSittingLore);
return iconItem;
}

View File

@ -10,7 +10,7 @@ import org.bukkit.entity.Slime;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.property.IntegerProperty;
import com.nisovin.shopkeepers.shopkeeper.AbstractShopkeeper;
@ -91,8 +91,8 @@ public class SlimeShop extends SKLivingShopObject<Slime> {
private ItemStack getSlimeSizeEditorItem() {
ItemStack iconItem = new ItemStack(Material.SLIME_BLOCK);
String displayName = TextUtils.replaceArguments(Settings.msgButtonSlimeSize, "size", slimeSize);
List<String> lore = TextUtils.replaceArguments(Settings.msgButtonSlimeSizeLore, "size", slimeSize);
String displayName = TextUtils.replaceArguments(Messages.buttonSlimeSize, "size", slimeSize);
List<String> lore = TextUtils.replaceArguments(Messages.buttonSlimeSizeLore, "size", slimeSize);
ItemUtils.setItemStackNameAndLore(iconItem, displayName, lore);
return iconItem;
}

View File

@ -13,7 +13,7 @@ import org.bukkit.entity.Villager.Profession;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.property.EnumProperty;
import com.nisovin.shopkeepers.property.IntegerProperty;
@ -180,7 +180,7 @@ public class VillagerShop extends BabyableShop<Villager> {
break;
}
assert iconItem != null;
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonVillagerProfession, Settings.msgButtonVillagerProfessionLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonVillagerProfession, Messages.buttonVillagerProfessionLore);
return iconItem;
}
@ -244,7 +244,7 @@ public class VillagerShop extends BabyableShop<Villager> {
ItemUtils.setLeatherColor(iconItem, Color.WHITE.mixDyes(DyeColor.BROWN));
break;
}
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonVillagerVariant, Settings.msgButtonVillagerVariantLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonVillagerVariant, Messages.buttonVillagerVariantLore);
return iconItem;
}
@ -310,7 +310,7 @@ public class VillagerShop extends BabyableShop<Villager> {
break;
}
assert iconItem != null;
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonVillagerLevel, Settings.msgButtonVillagerLevelLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonVillagerLevel, Messages.buttonVillagerLevelLore);
return iconItem;
}

View File

@ -11,7 +11,7 @@ import org.bukkit.entity.Wolf;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.property.BooleanProperty;
import com.nisovin.shopkeepers.property.EnumProperty;
@ -91,7 +91,7 @@ public class WolfShop extends SittableShop<Wolf> {
private ItemStack getAngryEditorItem() {
ItemStack iconItem = new ItemStack(angry ? Material.RED_WOOL : Material.WHITE_WOOL);
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonWolfAngry, Settings.msgButtonWolfAngryLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonWolfAngry, Messages.buttonWolfAngryLore);
return iconItem;
}
@ -140,7 +140,7 @@ public class WolfShop extends SittableShop<Wolf> {
} else {
iconItem = new ItemStack(ItemUtils.getWoolType(collarColor));
}
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonCollarColor, Settings.msgButtonCollarColorLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonCollarColor, Messages.buttonCollarColorLore);
return iconItem;
}

View File

@ -10,7 +10,7 @@ import org.bukkit.entity.Zombie;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.property.BooleanProperty;
import com.nisovin.shopkeepers.property.Property;
@ -78,7 +78,7 @@ public class ZombieShop<E extends Zombie> extends SKLivingShopObject<E> {
private ItemStack getBabyEditorItem() {
ItemStack iconItem = new ItemStack(Material.EGG);
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonBaby, Settings.msgButtonBabyLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonBaby, Messages.buttonBabyLore);
return iconItem;
}

View File

@ -12,7 +12,7 @@ import org.bukkit.entity.ZombieVillager;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.property.EnumProperty;
import com.nisovin.shopkeepers.property.Property;
@ -131,7 +131,7 @@ public class ZombieVillagerShop extends ZombieShop<ZombieVillager> {
break;
}
assert iconItem != null;
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonZombieVillagerProfession, Settings.msgButtonZombieVillagerProfessionLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonZombieVillagerProfession, Messages.buttonZombieVillagerProfessionLore);
return iconItem;
}

View File

@ -16,6 +16,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.api.shopkeeper.player.PlayerShopkeeper;
@ -363,6 +364,6 @@ public class SKSignShopObject extends AbstractBlockShopObject implements SignSho
protected ItemStack getSignTypeEditorItem() {
ItemStack iconItem = new ItemStack(signType.getSignMaterial());
return ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonSignVariant, Settings.msgButtonSignVariantLore);
return ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonSignVariant, Messages.buttonSignVariantLore);
}
}

View File

@ -3,6 +3,7 @@ package com.nisovin.shopkeepers.shopobjects.sign;
import org.bukkit.Location;
import org.bukkit.block.BlockFace;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.api.shopkeeper.ShopCreationData;
import com.nisovin.shopkeepers.api.shopobjects.sign.SignShopObjectType;
@ -20,7 +21,7 @@ public class SKSignShopObjectType extends AbstractBlockShopObjectType<SKSignShop
@Override
public String getDisplayName() {
return Settings.msgShopObjectTypeSign;
return Messages.shopObjectTypeSign;
}
@Override

View File

@ -23,8 +23,9 @@ import com.nisovin.shopkeepers.util.Validate;
* <p>
* The structure and semantics of this Text representation are closely oriented on regular text with color codes, but
* still supports advanced text features such as {@link HoverEventText hover events}. The goal is that
* {@link #toPlainText()} for Texts produced by {@link Text#parse(String)} will reproduce the original input text. These
* differences to Minecraft's / Spigot's text components need to be considered during conversions.
* {@link #toPlainText()} for Texts produced by {@link Text#parse(String)} will reproduce the original input text (using
* '§' as color character though). These differences to Minecraft's / Spigot's text components need to be considered
* during conversions.
*/
public interface Text {
@ -79,7 +80,7 @@ public interface Text {
* <p>
* This takes into account:
* <ul>
* <li>Legacy color codes (starting with '§')
* <li>Legacy color codes (starting with '&' or '§')
* <li>Placeholders
* </ul>
* <p>

View File

@ -2,6 +2,8 @@ package com.nisovin.shopkeepers.text;
import org.bukkit.ChatColor;
import com.nisovin.shopkeepers.util.TextUtils;
class TextParser {
private static final TextParser INSTANCE = new TextParser();
@ -47,7 +49,7 @@ class TextParser {
// Color codes:
ChatColor color = null;
if (c == ChatColor.COLOR_CHAR && i + 1 < length) {
if ((c == ChatColor.COLOR_CHAR || c == TextUtils.COLOR_CHAR_ALTERNATIVE) && i + 1 < length) {
char colorChar = Character.toLowerCase(input.charAt(i + 1));
color = ChatColor.getByChar(colorChar);
}

View File

@ -18,6 +18,7 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.shopkeeper.TradingRecipeDraft;
import com.nisovin.shopkeepers.ui.AbstractUIType;
@ -364,7 +365,7 @@ public abstract class AbstractEditorHandler extends UIHandler {
prevPage = (page - 1);
prevPageText = String.valueOf(prevPage);
}
String itemName = TextUtils.replaceArguments(Settings.msgButtonPreviousPage,
String itemName = TextUtils.replaceArguments(Messages.buttonPreviousPage,
"prev_page", prevPageText,
"page", page,
"max_page", getMaxTradesPages()
@ -372,7 +373,7 @@ public abstract class AbstractEditorHandler extends UIHandler {
ItemStack item = Settings.previousPageItem.createItemStack();
// Note: Can exceed the item's natural max stack size.
item.setAmount(MathUtils.trim(prevPage, 1, ItemUtils.MAX_STACK_SIZE));
return ItemUtils.setItemStackNameAndLore(item, itemName, Settings.msgButtonPreviousPageLore);
return ItemUtils.setItemStackNameAndLore(item, itemName, Messages.buttonPreviousPageLore);
}
protected ItemStack createNextPageIcon(int page) {
@ -382,7 +383,7 @@ public abstract class AbstractEditorHandler extends UIHandler {
nextPage = (page + 1);
nextPageText = String.valueOf(nextPage);
}
String itemName = TextUtils.replaceArguments(Settings.msgButtonNextPage,
String itemName = TextUtils.replaceArguments(Messages.buttonNextPage,
"next_page", nextPageText,
"page", page,
"max_page", getMaxTradesPages()
@ -390,18 +391,18 @@ public abstract class AbstractEditorHandler extends UIHandler {
ItemStack item = Settings.nextPageItem.createItemStack();
// Note: Can exceed the item's natural max stack size.
item.setAmount(MathUtils.trim(nextPage, 1, ItemUtils.MAX_STACK_SIZE));
return ItemUtils.setItemStackNameAndLore(item, itemName, Settings.msgButtonNextPageLore);
return ItemUtils.setItemStackNameAndLore(item, itemName, Messages.buttonNextPageLore);
}
protected ItemStack createCurrentPageIcon(int page) {
String itemName = TextUtils.replaceArguments(Settings.msgButtonCurrentPage,
String itemName = TextUtils.replaceArguments(Messages.buttonCurrentPage,
"page", page,
"max_page", getMaxTradesPages()
);
ItemStack item = Settings.currentPageItem.createItemStack();
// Note: Can exceed the item's natural max stack size.
item.setAmount(MathUtils.trim(page, 1, ItemUtils.MAX_STACK_SIZE));
return ItemUtils.setItemStackNameAndLore(item, itemName, Settings.msgButtonCurrentPageLore);
return ItemUtils.setItemStackNameAndLore(item, itemName, Messages.buttonCurrentPageLore);
}
protected abstract ItemStack createTradeSetupIcon();

View File

@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.SKShopkeepersPlugin;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.api.events.PlayerDeleteShopkeeperEvent;
@ -100,7 +101,7 @@ public abstract class EditorHandler extends AbstractEditorHandler implements Sho
@Override
protected ItemStack createTradeSetupIcon() {
ShopType<?> shopType = this.getShopkeeper().getType();
String itemName = TextUtils.replaceArguments(Settings.msgTradeSetupDescHeader, "shopType", shopType.getDisplayName());
String itemName = TextUtils.replaceArguments(Messages.tradeSetupDescHeader, "shopType", shopType.getDisplayName());
List<String> itemLore = shopType.getTradeSetupDescription();
return ItemUtils.setItemStackNameAndLore(Settings.tradeSetupItem.createItemStack(), itemName, itemLore);
}
@ -167,7 +168,7 @@ public abstract class EditorHandler extends AbstractEditorHandler implements Sho
// Start naming:
SKShopkeepersPlugin.getInstance().getShopkeeperNaming().startNaming(player, shopkeeper);
TextUtils.sendMessage(player, Settings.msgTypeNewName);
TextUtils.sendMessage(player, Messages.typeNewName);
}
};
}

View File

@ -6,6 +6,7 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.inventory.InventoryView;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.shopkeeper.AbstractShopkeeper;
@ -28,7 +29,7 @@ public abstract class HiringHandler extends AbstractShopkeeperUIHandler {
if (!PermissionUtils.hasPermission(player, ShopkeepersPlugin.HIRE_PERMISSION)) {
if (!silent) {
Log.debug(() -> "Blocked hire window opening for " + player.getName() + ": Missing hire permission.");
TextUtils.sendMessage(player, Settings.msgMissingHirePerm);
TextUtils.sendMessage(player, Messages.missingHirePerm);
}
return false;
}

View File

@ -19,6 +19,7 @@ import org.bukkit.inventory.MerchantInventory;
import org.bukkit.inventory.MerchantRecipe;
import org.bukkit.inventory.PlayerInventory;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.api.events.ShopkeeperTradeEvent;
@ -129,7 +130,7 @@ public class TradingHandler extends AbstractShopkeeperUIHandler {
if (!PermissionUtils.hasPermission(player, ShopkeepersPlugin.TRADE_PERMISSION)) {
if (!silent) {
Log.debug(() -> "Blocked trade window opening for " + player.getName() + ": Missing trade permission.");
TextUtils.sendMessage(player, Settings.msgMissingTradePerm);
TextUtils.sendMessage(player, Messages.missingTradePerm);
}
return false;
}
@ -187,9 +188,9 @@ public class TradingHandler extends AbstractShopkeeperUIHandler {
protected String getInventoryTitle() {
String title = this.getShopkeeper().getName(); // Can be empty
if (title.isEmpty()) {
title = Settings.msgTradingTitleDefault;
title = Messages.tradingTitleDefault;
}
return Settings.msgTradingTitlePrefix + title;
return Messages.tradingTitlePrefix + title;
}
protected void updateTrades(Player player) {

View File

@ -21,6 +21,7 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.MerchantRecipe;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Settings.DerivedSettings;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
@ -47,7 +48,7 @@ public final class VillagerEditorHandler extends AbstractEditorHandler {
Validate.notNull(villager, "villager is null");
this.villager = villager;
String villagerName = villager.getName(); // Not null
this.title = TextUtils.replaceArguments(Settings.msgVillagerEditorTitle, "villagerName", villagerName);
this.title = TextUtils.replaceArguments(Messages.villagerEditorTitle, "villagerName", villagerName);
}
public AbstractVillager getVillager() {
@ -68,7 +69,7 @@ public final class VillagerEditorHandler extends AbstractEditorHandler {
if (!silent) {
Log.debug(() -> "Blocked villager editor from opening for " + player.getName()
+ ": Missing edit-wandering-traders permission.");
TextUtils.sendMessage(player, Settings.msgMissingEditWanderingTradersPerm);
TextUtils.sendMessage(player, Messages.missingEditWanderingTradersPerm);
}
return false;
}
@ -77,7 +78,7 @@ public final class VillagerEditorHandler extends AbstractEditorHandler {
if (!silent) {
Log.debug(() -> "Blocked villager editor from opening for " + player.getName()
+ ": Missing edit-villagers permission.");
TextUtils.sendMessage(player, Settings.msgMissingEditVillagersPerm);
TextUtils.sendMessage(player, Messages.missingEditVillagersPerm);
}
return false;
}
@ -154,7 +155,7 @@ public final class VillagerEditorHandler extends AbstractEditorHandler {
int inventorySize = (int) Math.ceil(villagerInventory.getSize() / 9.0D) * 9;
String villagerName = villager.getName(); // Not null
String inventoryTitle = TextUtils.replaceArguments(Settings.msgVillagerInventoryTitle, "villagerName", villagerName);
String inventoryTitle = TextUtils.replaceArguments(Messages.villagerInventoryTitle, "villagerName", villagerName);
Inventory customInventory = Bukkit.createInventory(null, inventorySize, inventoryTitle);
// Copy storage contents:
@ -171,7 +172,7 @@ public final class VillagerEditorHandler extends AbstractEditorHandler {
@Override
public ItemStack getIcon(Session session) {
ItemStack iconItem = new ItemStack(Material.EGG);
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonBaby, Settings.msgButtonBabyLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonBaby, Messages.buttonBabyLore);
return iconItem;
}
@ -251,7 +252,7 @@ public final class VillagerEditorHandler extends AbstractEditorHandler {
break;
}
assert iconItem != null;
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonVillagerProfession, Settings.msgButtonVillagerProfessionLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonVillagerProfession, Messages.buttonVillagerProfessionLore);
return iconItem;
}
@ -269,7 +270,7 @@ public final class VillagerEditorHandler extends AbstractEditorHandler {
// change its profession:
if (regularVillager.getVillagerExperience() == 0) {
regularVillager.setVillagerExperience(1);
TextUtils.sendMessage(player, Settings.msgSetVillagerXp, "xp", 1);
TextUtils.sendMessage(player, Messages.setVillagerXp, "xp", 1);
}
return true;
}
@ -310,7 +311,7 @@ public final class VillagerEditorHandler extends AbstractEditorHandler {
ItemUtils.setLeatherColor(iconItem, Color.WHITE.mixDyes(DyeColor.BROWN));
break;
}
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonVillagerVariant, Settings.msgButtonVillagerVariantLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonVillagerVariant, Messages.buttonVillagerVariantLore);
return iconItem;
}
@ -354,7 +355,7 @@ public final class VillagerEditorHandler extends AbstractEditorHandler {
}
assert iconItem != null;
// TODO Change the default message back to mention the villager level, instead of just the badge color?
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonVillagerLevel, Settings.msgButtonVillagerLevelLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonVillagerLevel, Messages.buttonVillagerLevelLore);
return iconItem;
}
@ -387,7 +388,7 @@ public final class VillagerEditorHandler extends AbstractEditorHandler {
iconItem = new ItemStack(Material.CARVED_PUMPKIN);
}
assert iconItem != null;
ItemUtils.setItemStackNameAndLore(iconItem, Settings.msgButtonMobAi, Settings.msgButtonMobAiLore);
ItemUtils.setItemStackNameAndLore(iconItem, Messages.buttonMobAi, Messages.buttonMobAiLore);
return iconItem;
}
@ -405,8 +406,8 @@ public final class VillagerEditorHandler extends AbstractEditorHandler {
@Override
protected ItemStack createTradeSetupIcon() {
String villagerName = villager.getName(); // Not null
String itemName = TextUtils.replaceArguments(Settings.msgVillagerEditorDescriptionHeader, "villagerName", villagerName);
List<String> itemLore = Settings.msgVillagerEditorDescription;
String itemName = TextUtils.replaceArguments(Messages.villagerEditorDescriptionHeader, "villagerName", villagerName);
List<String> itemLore = Messages.villagerEditorDescription;
return ItemUtils.setItemStackNameAndLore(Settings.tradeSetupItem.createItemStack(), itemName, itemLore);
}
@ -460,10 +461,10 @@ public final class VillagerEditorHandler extends AbstractEditorHandler {
if (changedTrades == 0) {
// No changes:
TextUtils.sendMessage(player, Settings.msgNoVillagerTradesChanged);
TextUtils.sendMessage(player, Messages.noVillagerTradesChanged);
return;
} else {
TextUtils.sendMessage(player, Settings.msgVillagerTradesChanged, "changedTrades", changedTrades);
TextUtils.sendMessage(player, Messages.villagerTradesChanged, "changedTrades", changedTrades);
}
// Stop any current trading with this villager:
@ -482,7 +483,7 @@ public final class VillagerEditorHandler extends AbstractEditorHandler {
// its profession (and thereby its trades):
if (regularVillager.getVillagerExperience() == 0) {
regularVillager.setVillagerExperience(1);
TextUtils.sendMessage(player, Settings.msgSetVillagerXp, "xp", 1);
TextUtils.sendMessage(player, Messages.setVillagerXp, "xp", 1);
}
}
}

View File

@ -10,7 +10,7 @@ import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.text.Text;
public class PlayerUtils {
@ -174,21 +174,21 @@ public class PlayerUtils {
public static boolean handleAmbiguousPlayerName(CommandSender sender, String name, Iterable<Map.Entry<UUID, String>> matches, int maxEntries) {
return CommandUtils.handleAmbiguousInput(sender, name, matches, maxEntries,
() -> {
TextUtils.sendMessage(sender, Settings.msgAmbiguousPlayerName, "name", name);
TextUtils.sendMessage(sender, Messages.ambiguousPlayerName, "name", name);
},
(match, index) -> {
UUID matchUUID = match.getKey();
String matchUUIDString = matchUUID.toString();
String matchName = match.getValue();
TextUtils.sendMessage(sender, Settings.msgAmbiguousPlayerNameEntry,
TextUtils.sendMessage(sender, Messages.ambiguousPlayerNameEntry,
"index", index,
"name", Text.insertion(matchName).childText(matchName).buildRoot(),
"uuid", Text.insertion(matchUUIDString).childText(matchUUIDString).buildRoot()
);
},
() -> {
TextUtils.sendMessage(sender, Settings.msgAmbiguousPlayerNameMore);
TextUtils.sendMessage(sender, Messages.ambiguousPlayerNameMore);
}
);
}

View File

@ -19,8 +19,8 @@ import org.bukkit.entity.Player;
import org.bukkit.util.RayTraceResult;
import org.bukkit.util.Vector;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.SKShopkeepersPlugin;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.api.ShopkeepersAPI;
import com.nisovin.shopkeepers.api.shopkeeper.Shopkeeper;
import com.nisovin.shopkeepers.api.shopkeeper.admin.AdminShopkeeper;
@ -86,7 +86,7 @@ public class ShopkeeperUtils {
@Override
public Text getNoTargetErrorMsg() {
return Settings.msgMustTargetShop;
return Messages.mustTargetShop;
}
@Override
@ -103,12 +103,12 @@ public class ShopkeeperUtils {
@Override
public Text getNoTargetErrorMsg() {
return Settings.msgMustTargetAdminShop;
return Messages.mustTargetAdminShop;
}
@Override
public Text getInvalidTargetErrorMsg(Shopkeeper shopkeeper) {
return Settings.msgTargetShopIsNoAdminShop;
return Messages.targetShopIsNoAdminShop;
}
};
@ -120,12 +120,12 @@ public class ShopkeeperUtils {
@Override
public Text getNoTargetErrorMsg() {
return Settings.msgMustTargetPlayerShop;
return Messages.mustTargetPlayerShop;
}
@Override
public Text getInvalidTargetErrorMsg(Shopkeeper shopkeeper) {
return Settings.msgTargetShopIsNoPlayerShop;
return Messages.targetShopIsNoPlayerShop;
}
};
@ -159,7 +159,7 @@ public class ShopkeeperUtils {
if (ShopContainers.isSupportedContainer(targetBlock.getType())) {
List<PlayerShopkeeper> shopsUsingContainer = SKShopkeepersPlugin.getInstance().getProtectedContainers().getShopkeepersUsingContainer(targetBlock);
if (shopsUsingContainer.isEmpty()) {
return new TargetShopkeepersResult(Settings.msgUnusedContainer);
return new TargetShopkeepersResult(Messages.unusedContainer);
} else {
// Filter shops:
List<Shopkeeper> acceptedShops = new ArrayList<>();
@ -182,7 +182,7 @@ public class ShopkeeperUtils {
assert targetEntity != null;
shopkeeper = ShopkeepersAPI.getShopkeeperRegistry().getShopkeeperByEntity(targetEntity);
if (shopkeeper == null) {
return new TargetShopkeepersResult(Settings.msgTargetEntityIsNoShop);
return new TargetShopkeepersResult(Messages.targetEntityIsNoShop);
}
}

View File

@ -12,7 +12,7 @@ import org.bukkit.event.entity.EntityTransformEvent.TransformReason;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.inventory.ItemStack;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.util.ItemUtils;
import com.nisovin.shopkeepers.util.Log;
import com.nisovin.shopkeepers.util.TextUtils;
@ -35,7 +35,7 @@ public class BlockZombieVillagerCuringListener implements Listener {
// Prevent curing:
Log.debug(() -> "Preventing zombie villager curing at " + TextUtils.getLocationString(player.getLocation()));
event.setCancelled(true);
TextUtils.sendMessage(player, Settings.msgZombieVillagerCuringDisabled);
TextUtils.sendMessage(player, Messages.zombieVillagerCuringDisabled);
}
}
@ -52,7 +52,7 @@ public class BlockZombieVillagerCuringListener implements Listener {
OfflinePlayer conversionOfflinePlayer = zombieVillager.getConversionPlayer();
Player conversionPlayer = (conversionOfflinePlayer == null) ? null : conversionOfflinePlayer.getPlayer();
if (conversionPlayer != null) {
TextUtils.sendMessage(conversionPlayer, Settings.msgZombieVillagerCuringDisabled);
TextUtils.sendMessage(conversionPlayer, Messages.zombieVillagerCuringDisabled);
}
}
}

View File

@ -15,6 +15,7 @@ import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import com.nisovin.shopkeepers.Messages;
import com.nisovin.shopkeepers.SKShopkeepersPlugin;
import com.nisovin.shopkeepers.Settings;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
@ -121,7 +122,7 @@ public class VillagerInteractionListener implements Listener {
ItemStack itemInMainHand = playerInventory.getItemInMainHand();
if (!Settings.isHireItem(itemInMainHand)) {
// TODO Show hire item via hover event?
TextUtils.sendMessage(player, Settings.msgVillagerForHire,
TextUtils.sendMessage(player, Messages.villagerForHire,
"costs", Settings.hireOtherVillagersCosts,
"hire-item", Settings.hireItem.getType().name()
); // TODO Also print required hire item name and lore?
@ -134,7 +135,7 @@ public class VillagerInteractionListener implements Listener {
if (costs > 0) {
ItemStack[] storageContents = playerInventory.getStorageContents();
if (!ItemUtils.containsAtLeast(storageContents, Settings.hireItem, costs)) {
TextUtils.sendMessage(player, Settings.msgCantHire);
TextUtils.sendMessage(player, Messages.cantHire);
Log.debug(" ..not holding enough hire items.");
return false;
}
@ -170,7 +171,7 @@ public class VillagerInteractionListener implements Listener {
// Update client's inventory:
player.updateInventory();
TextUtils.sendMessage(player, Settings.msgHired);
TextUtils.sendMessage(player, Messages.hired);
Log.debug(" ..success (normal trading prevented).");
return true;
}

View File

@ -6,7 +6,7 @@
# *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
# Determines the required config migrations. Do not edit manually!
config-version: 3
config-version: 4
# The initial debugging state of the plugin.
debug: false
# Additional debugging options.
@ -427,364 +427,4 @@ high-currency-min-cost: 20
# Messages
# *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
language: en
msg-shop-type-admin-regular: "Admin shop"
msg-shop-type-selling: "Selling shop"
msg-shop-type-buying: "Buying shop"
msg-shop-type-trading: "Trading shop"
msg-shop-type-book: "Book shop"
msg-shop-type-desc-admin-regular: "has unlimited stock"
msg-shop-type-desc-selling: "sells items to players"
msg-shop-type-desc-buying: "buys items from players"
msg-shop-type-desc-trading: "trades items with players"
msg-shop-type-desc-book: "sells book copies"
msg-shop-object-type-living: "{type}"
msg-shop-object-type-sign: "sign"
msg-shop-object-type-npc: "npc"
msg-selected-shop-type: "&aSelected shop type: &6{type} &7({description})"
msg-selected-shop-object-type: "&aSelected object type: &6{type}"
msg-creation-item-selected: |-
&aShop creation:
&e Left/Right-click to select the shop type.
&e Sneak + left/right-click to select the object type.
&e Right-click a container to select it.
&e Then right-click a block to place the shopkeeper.
msg-button-previous-page: "&6<- Previous page ({prev_page} of {max_page})"
msg-button-previous-page-lore: []
msg-button-next-page: "&6Next page ({next_page} of {max_page}) ->"
msg-button-next-page-lore: []
msg-button-current-page: "&6Page {page} of {max_page}"
msg-button-current-page-lore: []
msg-button-name: "&aSet shop name"
msg-button-name-lore:
- Lets you rename
- your shopkeeper
msg-button-container: "&aView shop inventory"
msg-button-container-lore:
- Lets you view the inventory
- your shopkeeper is using
msg-button-delete: "&4Delete"
msg-button-delete-lore:
- Closes and removes
- this shopkeeper
msg-button-hire: "&aHire"
msg-button-hire-lore:
- Buy this shopkeeper
msg-button-sign-variant: "&aChoose sign variant"
msg-button-sign-variant-lore:
- "Changes the sign's"
- "wood type"
msg-button-baby: "&aToggle baby variant"
msg-button-baby-lore:
- "Toggles between the mob's"
- "baby and adult variant"
msg-button-sitting: "&aToggle sitting pose"
msg-button-sitting-lore:
- "Toggles the mob's"
- "sitting pose"
msg-button-cat-variant: "&aChoose cat variant"
msg-button-cat-variant-lore:
- "Changes the cat's look"
msg-button-rabbit-variant: "&aChoose rabbit variant"
msg-button-rabbit-variant-lore:
- "Changes the rabbit's look"
msg-button-collar-color: "&aChoose collar color"
msg-button-collar-color-lore:
- "Changes the mob's"
- "collar color"
msg-button-wolf-angry: "&aToggle angry wolf"
msg-button-wolf-angry-lore:
- "Toggles the wolf's"
- "angry state"
msg-button-carrying-chest: "&aToggle carrying chest"
msg-button-carrying-chest-lore:
- "Toggles whether the mob"
- "is carrying a chest"
msg-button-horse-color: "&aChoose horse color"
msg-button-horse-color-lore:
- "Changes the color"
- "of the horse"
msg-button-horse-style: "&aChoose horse style"
msg-button-horse-style-lore:
- "Changes the coat pattern"
- "of the horse"
msg-button-horse-armor: "&aChoose horse armor"
msg-button-horse-armor-lore:
- "Changes the armor"
- "of the horse"
msg-button-llama-variant: "&aChoose llama variant"
msg-button-llama-variant-lore:
- "Changes the llama's look"
msg-button-llama-carpet-color: "&aLlama carpet color"
msg-button-llama-carpet-color-lore:
- "Changes the llama's"
- "carpet color"
msg-button-creeper-charged: "&aToggle charged creeper"
msg-button-creeper-charged-lore:
- "Toggles the creeper's"
- "charged state"
msg-button-fox-variant: "&aChoose fox variant"
msg-button-fox-variant-lore:
- "Changes the fox's look"
msg-button-fox-crouching: "&aToggle crouching pose"
msg-button-fox-crouching-lore:
- "Toggles the fox's"
- "crouching pose"
msg-button-fox-sleeping: "&aToggle sleeping pose"
msg-button-fox-sleeping-lore:
- "Toggles the fox's"
- "sleeping pose"
msg-button-mooshroom-variant: "&aChoose mooshroom variant"
msg-button-mooshroom-variant-lore:
- "Changes the look"
- "of the mooshroom"
msg-button-panda-variant: "&aChoose panda variant"
msg-button-panda-variant-lore:
- "Changes the panda's look"
msg-button-parrot-variant: "&aChoose parrot variant"
msg-button-parrot-variant-lore:
- "Changes the parrot's look"
msg-button-pig-saddle: "&aToggle pig saddle"
msg-button-pig-saddle-lore:
- "Toggles the pig's saddle"
msg-button-sheep-color: "&aChoose sheep color"
msg-button-sheep-color-lore:
- "Changes the sheep's"
- "wool color"
msg-button-sheep-sheared: "&aToggle sheared sheep"
msg-button-sheep-sheared-lore:
- "Toggles the sheep's"
- "sheared state"
msg-button-villager-profession: "&aChoose villager profession"
msg-button-villager-profession-lore:
- "Changes the profession"
- "of the villager"
msg-button-villager-variant: "&aChoose villager variant"
msg-button-villager-variant-lore:
- "Changes the look"
- "of the villager"
msg-button-villager-level: "&aChoose villager badge color"
msg-button-villager-level-lore:
- "Changes the badge color"
- "of the villager"
msg-button-zombie-villager-profession: "&aChoose villager profession"
msg-button-zombie-villager-profession-lore:
- "Changes the profession"
- "of the zombie villager"
msg-button-slime-size: "&aChoose slime size"
msg-button-slime-size-lore:
- "Cycles the slime's size."
- "Current size: &e{size}"
msg-button-magma-cube-size: "&aChoose magma cube size"
msg-button-magma-cube-size-lore:
- "Cycles the magma cube's size."
- "Current size: &e{size}"
msg-trading-title-prefix: "&2"
msg-trading-title-default: "Shopkeeper"
msg-container-selected: "&aContainer selected! Right-click a block to place your shopkeeper."
msg-unsupported-container: "&7This type of container cannot be used for shops."
msg-must-select-container: "&7You must right-click a container before placing your shopkeeper."
msg-invalid-container: "&7The selected block is not a valid container!"
msg-container-too-far-away: "&7The shopkeeper's container is too far away!"
msg-container-not-placed: "&7You must select a container you have recently placed!"
msg-container-already-in-use: "&7Another shopkeeper is already using the selected container!"
msg-no-container-access: "&7You cannot access the selected container!"
msg-too-many-shops: "&7You have too many shops!"
msg-no-admin-shop-type-selected: "&7You have to select an admin shop type!"
msg-no-player-shop-type-selected: "&7You have to select a player shop type!"
msg-shop-create-fail: "&7You cannot create a shopkeeper there."
msg-type-new-name: "&aPlease type the shop's name into the chat.\n &aType a dash (-) to remove the name."
msg-name-set: "&aThe shop's name has been set!"
msg-name-has-not-changed: "&aThe shop's name has not changed."
msg-name-invalid: "&aThat name is not valid!"
msg-shop-type-disabled: "&7The shop type '&6{type}&7' is disabled."
msg-shop-object-type-disabled: "&7The shop object type '&6{type}&7' is disabled."
msg-must-target-shop: "&7You have to target a shopkeeper."
msg-must-target-admin-shop: "&7You have to target an admin shopkeeper."
msg-must-target-player-shop: "&7You have to target a player shopkeeper."
msg-target-entity-is-no-shop: "&7The targeted entity is no shopkeeper."
msg-target-shop-is-no-admin-shop: "&7The targeted shopkeeper is no admin shopkeeper."
msg-target-shop-is-no-player-shop: "&7The targeted shopkeeper is no player shopkeeper."
msg-unused-container: "&7No shopkeeper is using this container."
msg-not-owner: "&7You are not the owner of this shopkeeper."
msg-owner-set: "&aNew owner was set to &e{owner}"
msg-shop-creation-items-given: "&aPlayer &e{player}&a has received &e{amount}&a shop creation item(s)!"
msg-shop-creation-items-received: "&aYou have received &e{amount}&a shop creation item(s)!"
msg-currency-items-given: "&aPlayer &e{player}&a has received &e{amount}&a currency item(s)!"
msg-currency-items-received: "&aYou have received &e{amount}&a currency item(s)!"
msg-high-currency-items-given: "&aPlayer &e{player}&a has received &e{amount}&a high currency item(s)!"
msg-high-currency-items-received: "&aYou have received &e{amount}&a high currency item(s)!"
msg-high-currency-disabled: "&cThe high currency is disabled!"
msg-items-converted: "&aConverted &e{count}&a item stack(s)!"
msg-unknown-book-author: "Unknown"
msg-trade-perm-set: "&aThe shop's trading permission has been set to '&e{perm}&a'!"
msg-trade-perm-removed: "&aThe shop's trading permission '&e{perm}&a' has been removed!"
msg-trade-perm-view: "&aThe shop's current trading permission is '&e{perm}&a'."
msg-zombie-villager-curing-disabled: "&7Curing of zombie villagers is disabled."
msg-must-hold-hire-item: "&7You have to hold the required hire item in your hand."
msg-set-for-hire: "&aThe Shopkeeper was set for hire."
msg-hired: "&aYou have hired this shopkeeper!"
msg-missing-hire-perm: "&7You do not have the permission to hire shopkeepers."
msg-cant-hire: "&7You cannot afford to hire this shopkeeper."
msg-cant-hire-shop-type: "&7You do not have the permission to hire this type of shopkeeper."
msg-villager-for-hire: "&aThe villager offered his services as a shopkeeper in exchange for &6{costs}x {hire-item}&a."
msg-missing-trade-perm: "&7You do not have the permission to trade with this shop."
msg-missing-custom-trade-perm: "&7You do not have the permission to trade with this shop."
msg-cant-trade-with-own-shop: "&7You cannot trade with your own shop."
msg-cant-trade-while-owner-online: "&7You cannot trade while the owner of this shop ('&e{owner}&7') is online."
msg-cant-trade-with-shop-missing-container: "&7You cannot trade with this shop, because its container is missing."
msg-shopkeeper-created: "&aShopkeeper created: &6{type} &7({description})\n{setupDesc}"
msg-shop-setup-desc-selling: |-
&e Add items you want to sell to your container, then
&e right-click the shop while sneaking to modify costs.
msg-shop-setup-desc-buying: |-
&e Add one of each item you want to buy to your container,
&e then right-click the shop while sneaking to modify costs.
msg-shop-setup-desc-trading: |-
&e Add items you want to sell to your container, then
&e right-click the shop while sneaking to modify costs.
msg-shop-setup-desc-book: |-
&e Add written and blank books to your container, then
&e right-click the shop while sneaking to modify costs.
msg-shop-setup-desc-admin-regular: |-
&e Right-click the shop while sneaking to modify trades.
msg-trade-setup-desc-header: '&6{shopType}'
msg-trade-setup-desc-admin-regular:
- Has unlimited stock.
- Insert items from your inventory.
- 'Top row: Result items'
- 'Bottom rows: Cost items'
msg-trade-setup-desc-selling:
- Sells items to players.
- Insert items to sell into the container.
- Left/Right click to adjust amounts.
- 'Top row: Items being sold'
- 'Bottom rows: Cost items'
msg-trade-setup-desc-buying:
- Buys items from players.
- Insert one of each item you want to
- buy and plenty of currency items
- into the container.
- Left/Right click to adjust amounts.
- 'Top row: Cost items'
- 'Bottom row: Items being bought'
msg-trade-setup-desc-trading:
- Trades items with players.
- Pickup an item from your inventory
- and then click a slot to place it.
- Left/Right click to adjust amounts.
- 'Top row: Result items'
- 'Bottom rows: Cost items'
msg-trade-setup-desc-book:
- Sells book copies.
- Insert written and blank books
- into the container.
- Left/Right click to adjust costs.
- 'Top row: Books being sold'
- 'Bottom rows: Cost items'
msg-missing-edit-villagers-perm: "&7You do not have the permission to edit villagers."
msg-missing-edit-wandering-traders-perm: "&7You do not have the permission to edit wandering traders."
msg-must-target-entity: "&7You have to target an entity."
msg-must-target-villager: "&7You have to target a villager."
msg-target-entity-is-no-villager: "&7The targeted entity is no regular villager."
msg-villager-editor-title: "&aVillager Editor: &e{villagerName}"
msg-villager-editor-description-header: "&6Villager Editor"
msg-villager-editor-description:
- 'Top row: Result items'
- 'Bottom rows: Cost items'
- 'Edited trades have infinite'
- 'uses and no XP rewards.'
msg-button-delete-villager: "&4Delete"
msg-button-delete-villager-lore:
- Deletes the villager
msg-button-villager-inventory: "&aView villager inventory"
msg-button-villager-inventory-lore:
- Lets you view a copy of
- the villager's inventory
msg-button-mob-ai: "&aToggle mob AI"
msg-button-mob-ai-lore:
- "Toggles the mob's AI"
msg-villager-inventory-title: "Villager inventory (copy)"
msg-set-villager-xp: "&aSet the villager's XP to &e{xp}"
msg-no-villager-trades-changed: "&aNo trades have been changed."
msg-villager-trades-changed: "&e{changedTrades}&a trades have been changed."
msg-list-admin-shops-header: "&9There are &e{shopsCount} &9admin shops: &e(Page {page} of {maxPage})"
msg-list-all-shops-header: "&9There are &e{shopsCount} &9shops in total: &e(Page {page} of {maxPage})"
msg-list-player-shops-header: "&9Player '&e{player}&9' has &e{shopsCount} &9shops: &e(Page {page} of {maxPage})"
msg-list-shops-entry: " &e{shopId}) &7{shopName}&r&8at &7({location})&8, type: &7{shopType}&8, object: &7{objectType}"
msg-removed-admin-shops: "&e{shopsCount} &aadmin shops were removed."
msg-removed-shops-of-player: "&e{shopsCount} &ashops of player '&e{player}&a' were removed."
msg-removed-player-shops: "&e{shopsCount} &aplayer shops were removed."
msg-confirm-remove-all-admin-shops: "&cYou are about to irrevocable remove all admin shops (&6{shopsCount}&c)!"
msg-confirm-remove-all-own-shops: "&cYou are about to irrevocable remove all your shops (&6{shopsCount}&c)!"
msg-confirm-remove-all-shops-of-player: "&cYou are about to irrevocable remove all shops of player &6{player}&c (&6{shopsCount}&c)!"
msg-confirm-remove-all-player-shops: "&cYou are about to irrevocable remove all player shops of all players (&6{shopsCount}&c)!"
msg-confirmation-required: "&7Please confirm this action by typing &6/shopkeepers confirm"
msg-confirmation-expired: "&cConfirmation expired."
msg-nothing-to-confirm: "&cThere is nothing to confirm currently."
msg-no-permission: "&cYou don't have the permission to do that."
msg-command-unknown: "&cUnknown command '&e{command}&c'!"
msg-command-argument-unexpected: "&cUnexpected argument '&e{argument}&c'."
msg-command-argument-requires-player: "&cArgument '&e{argumentFormat}&c' requires a player to execute the command."
msg-command-argument-missing: "&cMissing argument '&e{argumentFormat}&c'."
msg-command-argument-invalid: "&cInvalid argument '&e{argument}&c'."
msg-command-player-argument-missing: "&cNo player specified for '&e{argumentFormat}&c'."
msg-command-player-argument-invalid: "&cNo player found for '&e{argument}&c'."
msg-command-shop-type-argument-invalid: "&cUnknown shop type '&e{argument}&c'."
msg-command-shop-object-type-argument-invalid: "&cUnknown shop object type '&e{argument}&c'."
msg-command-shopkeeper-argument-invalid: "&cNo shopkeeper found for '&e{argument}&c'."
msg-command-shopkeeper-argument-no-admin-shop: "&cShopkeeper '&e{argument}&c' is no admin shopkeeper."
msg-command-shopkeeper-argument-no-player-shop: "&cShopkeeper '&e{argument}&c' is no player shopkeeper."
msg-ambiguous-player-name: "&cThere are multiple matches for the name '&e{name}&c'!"
msg-ambiguous-player-name-entry: "&c - '&e{name}&r&c' (&6{uuid}&c)"
msg-ambiguous-player-name-more: "&c - ...."
msg-command-help-title: "&9***** &8[&6Shopkeepers v{version}&8] &9*****"
msg-command-help-usage-format: "&e{usage}"
msg-command-help-description-format: "&8 - &3{description}"
msg-command-description-shopkeeper: "Creates a shopkeeper."
msg-command-description-help: "Shows this help page."
msg-command-description-reload: "Reloads this plugin."
msg-command-description-debug: "Toggles debug mode on and off."
msg-command-description-list: "Lists all shops for the specified player, or all admin shops."
msg-command-description-remove: "Removes all shops for the specified player, all players, or all admin shops."
msg-command-description-give: "Gives shop creation item(s) to the specified player."
msg-command-description-give-currency: "Gives currency item(s) to the specified player."
msg-command-description-convert-items: "Converts the held (or all) items to conform to Spigot's data format."
msg-command-description-remote: "Remotely opens a shop (Optionally: For another player)."
msg-command-description-remote-edit: "Remotely edits a shop."
msg-command-description-transfer: "Transfers the ownership of a shop."
msg-command-description-settradeperm: "Sets, removes (-) or displays (?) the trading permission."
msg-command-description-setforhire: "Sets one of your shops for sale."
msg-command-description-edit-villager: "Opens the editor for the target villager."
language: en-default

View File

@ -0,0 +1,367 @@
# *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
# Shopkeepers Default Language File
# This file acts as a template for custom language files and is not meant to be
# modified. It gets overwritten on every plugin startup.
# Community translations: https://github.com/Shopkeepers/Translations
# *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
# Language: en-default
shop-type-admin-regular: "Admin shop"
shop-type-selling: "Selling shop"
shop-type-buying: "Buying shop"
shop-type-trading: "Trading shop"
shop-type-book: "Book shop"
shop-type-desc-admin-regular: "has unlimited stock"
shop-type-desc-selling: "sells items to players"
shop-type-desc-buying: "buys items from players"
shop-type-desc-trading: "trades items with players"
shop-type-desc-book: "sells book copies"
shop-object-type-living: "{type}"
shop-object-type-sign: "sign"
shop-object-type-npc: "npc"
selected-shop-type: "&aSelected shop type: &6{type} &7({description})"
selected-shop-object-type: "&aSelected object type: &6{type}"
creation-item-selected: |-
&aShop creation:
&e Left/Right-click to select the shop type.
&e Sneak + left/right-click to select the object type.
&e Right-click a container to select it.
&e Then right-click a block to place the shopkeeper.
button-previous-page: "&6<- Previous page ({prev_page} of {max_page})"
button-previous-page-lore: []
button-next-page: "&6Next page ({next_page} of {max_page}) ->"
button-next-page-lore: []
button-current-page: "&6Page {page} of {max_page}"
button-current-page-lore: []
button-name: "&aSet shop name"
button-name-lore:
- Lets you rename
- your shopkeeper
button-container: "&aView shop inventory"
button-container-lore:
- Lets you view the inventory
- your shopkeeper is using
button-delete: "&4Delete"
button-delete-lore:
- Closes and removes
- this shopkeeper
button-hire: "&aHire"
button-hire-lore:
- Buy this shopkeeper
button-sign-variant: "&aChoose sign variant"
button-sign-variant-lore:
- "Changes the sign's"
- "wood type"
button-baby: "&aToggle baby variant"
button-baby-lore:
- "Toggles between the mob's"
- "baby and adult variant"
button-sitting: "&aToggle sitting pose"
button-sitting-lore:
- "Toggles the mob's"
- "sitting pose"
button-cat-variant: "&aChoose cat variant"
button-cat-variant-lore:
- "Changes the cat's look"
button-rabbit-variant: "&aChoose rabbit variant"
button-rabbit-variant-lore:
- "Changes the rabbit's look"
button-collar-color: "&aChoose collar color"
button-collar-color-lore:
- "Changes the mob's"
- "collar color"
button-wolf-angry: "&aToggle angry wolf"
button-wolf-angry-lore:
- "Toggles the wolf's"
- "angry state"
button-carrying-chest: "&aToggle carrying chest"
button-carrying-chest-lore:
- "Toggles whether the mob"
- "is carrying a chest"
button-horse-color: "&aChoose horse color"
button-horse-color-lore:
- "Changes the color"
- "of the horse"
button-horse-style: "&aChoose horse style"
button-horse-style-lore:
- "Changes the coat pattern"
- "of the horse"
button-horse-armor: "&aChoose horse armor"
button-horse-armor-lore:
- "Changes the armor"
- "of the horse"
button-llama-variant: "&aChoose llama variant"
button-llama-variant-lore:
- "Changes the llama's look"
button-llama-carpet-color: "&aLlama carpet color"
button-llama-carpet-color-lore:
- "Changes the llama's"
- "carpet color"
button-creeper-charged: "&aToggle charged creeper"
button-creeper-charged-lore:
- "Toggles the creeper's"
- "charged state"
button-fox-variant: "&aChoose fox variant"
button-fox-variant-lore:
- "Changes the fox's look"
button-fox-crouching: "&aToggle crouching pose"
button-fox-crouching-lore:
- "Toggles the fox's"
- "crouching pose"
button-fox-sleeping: "&aToggle sleeping pose"
button-fox-sleeping-lore:
- "Toggles the fox's"
- "sleeping pose"
button-mooshroom-variant: "&aChoose mooshroom variant"
button-mooshroom-variant-lore:
- "Changes the look"
- "of the mooshroom"
button-panda-variant: "&aChoose panda variant"
button-panda-variant-lore:
- "Changes the panda's look"
button-parrot-variant: "&aChoose parrot variant"
button-parrot-variant-lore:
- "Changes the parrot's look"
button-pig-saddle: "&aToggle pig saddle"
button-pig-saddle-lore:
- "Toggles the pig's saddle"
button-sheep-color: "&aChoose sheep color"
button-sheep-color-lore:
- "Changes the sheep's"
- "wool color"
button-sheep-sheared: "&aToggle sheared sheep"
button-sheep-sheared-lore:
- "Toggles the sheep's"
- "sheared state"
button-villager-profession: "&aChoose villager profession"
button-villager-profession-lore:
- "Changes the profession"
- "of the villager"
button-villager-variant: "&aChoose villager variant"
button-villager-variant-lore:
- "Changes the look"
- "of the villager"
button-villager-level: "&aChoose villager badge color"
button-villager-level-lore:
- "Changes the badge color"
- "of the villager"
button-zombie-villager-profession: "&aChoose villager profession"
button-zombie-villager-profession-lore:
- "Changes the profession"
- "of the zombie villager"
button-slime-size: "&aChoose slime size"
button-slime-size-lore:
- "Cycles the slime's size."
- "Current size: &e{size}"
button-magma-cube-size: "&aChoose magma cube size"
button-magma-cube-size-lore:
- "Cycles the magma cube's size."
- "Current size: &e{size}"
trading-title-prefix: "&2"
trading-title-default: "Shopkeeper"
container-selected: "&aContainer selected! Right-click a block to place your shopkeeper."
unsupported-container: "&7This type of container cannot be used for shops."
must-select-container: "&7You must right-click a container before placing your shopkeeper."
invalid-container: "&7The selected block is not a valid container!"
container-too-far-away: "&7The shopkeeper's container is too far away!"
container-not-placed: "&7You must select a container you have recently placed!"
container-already-in-use: "&7Another shopkeeper is already using the selected container!"
no-container-access: "&7You cannot access the selected container!"
too-many-shops: "&7You have too many shops!"
no-admin-shop-type-selected: "&7You have to select an admin shop type!"
no-player-shop-type-selected: "&7You have to select a player shop type!"
shop-create-fail: "&7You cannot create a shopkeeper there."
type-new-name: "&aPlease type the shop's name into the chat.\n &aType a dash (-) to remove the name."
name-set: "&aThe shop's name has been set!"
name-has-not-changed: "&aThe shop's name has not changed."
name-invalid: "&aThat name is not valid!"
shop-type-disabled: "&7The shop type '&6{type}&7' is disabled."
shop-object-type-disabled: "&7The shop object type '&6{type}&7' is disabled."
must-target-shop: "&7You have to target a shopkeeper."
must-target-admin-shop: "&7You have to target an admin shopkeeper."
must-target-player-shop: "&7You have to target a player shopkeeper."
target-entity-is-no-shop: "&7The targeted entity is no shopkeeper."
target-shop-is-no-admin-shop: "&7The targeted shopkeeper is no admin shopkeeper."
target-shop-is-no-player-shop: "&7The targeted shopkeeper is no player shopkeeper."
unused-container: "&7No shopkeeper is using this container."
not-owner: "&7You are not the owner of this shopkeeper."
owner-set: "&aNew owner was set to &e{owner}"
shop-creation-items-given: "&aPlayer &e{player}&a has received &e{amount}&a shop creation item(s)!"
shop-creation-items-received: "&aYou have received &e{amount}&a shop creation item(s)!"
currency-items-given: "&aPlayer &e{player}&a has received &e{amount}&a currency item(s)!"
currency-items-received: "&aYou have received &e{amount}&a currency item(s)!"
high-currency-items-given: "&aPlayer &e{player}&a has received &e{amount}&a high currency item(s)!"
high-currency-items-received: "&aYou have received &e{amount}&a high currency item(s)!"
high-currency-disabled: "&cThe high currency is disabled!"
items-converted: "&aConverted &e{count}&a item stack(s)!"
unknown-book-author: "Unknown"
trade-perm-set: "&aThe shop's trading permission has been set to '&e{perm}&a'!"
trade-perm-removed: "&aThe shop's trading permission '&e{perm}&a' has been removed!"
trade-perm-view: "&aThe shop's current trading permission is '&e{perm}&a'."
zombie-villager-curing-disabled: "&7Curing of zombie villagers is disabled."
must-hold-hire-item: "&7You have to hold the required hire item in your hand."
set-for-hire: "&aThe Shopkeeper was set for hire."
hired: "&aYou have hired this shopkeeper!"
missing-hire-perm: "&7You do not have the permission to hire shopkeepers."
cant-hire: "&7You cannot afford to hire this shopkeeper."
cant-hire-shop-type: "&7You do not have the permission to hire this type of shopkeeper."
villager-for-hire: "&aThe villager offered his services as a shopkeeper in exchange for &6{costs}x {hire-item}&a."
missing-trade-perm: "&7You do not have the permission to trade with this shop."
missing-custom-trade-perm: "&7You do not have the permission to trade with this shop."
cant-trade-with-own-shop: "&7You cannot trade with your own shop."
cant-trade-while-owner-online: "&7You cannot trade while the owner of this shop ('&e{owner}&7') is online."
cant-trade-with-shop-missing-container: "&7You cannot trade with this shop, because its container is missing."
shopkeeper-created: "&aShopkeeper created: &6{type} &7({description})\n{setupDesc}"
shop-setup-desc-selling: |-
&e Add items you want to sell to your container, then
&e right-click the shop while sneaking to modify costs.
shop-setup-desc-buying: |-
&e Add one of each item you want to buy to your container,
&e then right-click the shop while sneaking to modify costs.
shop-setup-desc-trading: |-
&e Add items you want to sell to your container, then
&e right-click the shop while sneaking to modify costs.
shop-setup-desc-book: |-
&e Add written and blank books to your container, then
&e right-click the shop while sneaking to modify costs.
shop-setup-desc-admin-regular: |-
&e Right-click the shop while sneaking to modify trades.
trade-setup-desc-header: '&6{shopType}'
trade-setup-desc-admin-regular:
- Has unlimited stock.
- Insert items from your inventory.
- 'Top row: Result items'
- 'Bottom rows: Cost items'
trade-setup-desc-selling:
- Sells items to players.
- Insert items to sell into the container.
- Left/Right click to adjust amounts.
- 'Top row: Items being sold'
- 'Bottom rows: Cost items'
trade-setup-desc-buying:
- Buys items from players.
- Insert one of each item you want to
- buy and plenty of currency items
- into the container.
- Left/Right click to adjust amounts.
- 'Top row: Cost items'
- 'Bottom row: Items being bought'
trade-setup-desc-trading:
- Trades items with players.
- Pickup an item from your inventory
- and then click a slot to place it.
- Left/Right click to adjust amounts.
- 'Top row: Result items'
- 'Bottom rows: Cost items'
trade-setup-desc-book:
- Sells book copies.
- Insert written and blank books
- into the container.
- Left/Right click to adjust costs.
- 'Top row: Books being sold'
- 'Bottom rows: Cost items'
missing-edit-villagers-perm: "&7You do not have the permission to edit villagers."
missing-edit-wandering-traders-perm: "&7You do not have the permission to edit wandering traders."
must-target-entity: "&7You have to target an entity."
must-target-villager: "&7You have to target a villager."
target-entity-is-no-villager: "&7The targeted entity is no regular villager."
villager-editor-title: "&aVillager Editor: &e{villagerName}"
villager-editor-description-header: "&6Villager Editor"
villager-editor-description:
- 'Top row: Result items'
- 'Bottom rows: Cost items'
- 'Edited trades have infinite'
- 'uses and no XP rewards.'
button-delete-villager: "&4Delete"
button-delete-villager-lore:
- Deletes the villager
button-villager-inventory: "&aView villager inventory"
button-villager-inventory-lore:
- Lets you view a copy of
- the villager's inventory
button-mob-ai: "&aToggle mob AI"
button-mob-ai-lore:
- "Toggles the mob's AI"
villager-inventory-title: "Villager inventory (copy)"
set-villager-xp: "&aSet the villager's XP to &e{xp}"
no-villager-trades-changed: "&aNo trades have been changed."
villager-trades-changed: "&e{changedTrades}&a trades have been changed."
list-admin-shops-header: "&9There are &e{shopsCount} &9admin shops: &e(Page {page} of {maxPage})"
list-all-shops-header: "&9There are &e{shopsCount} &9shops in total: &e(Page {page} of {maxPage})"
list-player-shops-header: "&9Player '&e{player}&9' has &e{shopsCount} &9shops: &e(Page {page} of {maxPage})"
list-shops-entry: " &e{shopId}) &7{shopName}&r&8at &7({location})&8, type: &7{shopType}&8, object: &7{objectType}"
removed-admin-shops: "&e{shopsCount} &aadmin shops were removed."
removed-shops-of-player: "&e{shopsCount} &ashops of player '&e{player}&a' were removed."
removed-player-shops: "&e{shopsCount} &aplayer shops were removed."
confirm-remove-all-admin-shops: "&cYou are about to irrevocable remove all admin shops (&6{shopsCount}&c)!"
confirm-remove-all-own-shops: "&cYou are about to irrevocable remove all your shops (&6{shopsCount}&c)!"
confirm-remove-all-shops-of-player: "&cYou are about to irrevocable remove all shops of player &6{player}&c (&6{shopsCount}&c)!"
confirm-remove-all-player-shops: "&cYou are about to irrevocable remove all player shops of all players (&6{shopsCount}&c)!"
confirmation-required: "&7Please confirm this action by typing &6/shopkeepers confirm"
confirmation-expired: "&cConfirmation expired."
nothing-to-confirm: "&cThere is nothing to confirm currently."
no-permission: "&cYou don't have the permission to do that."
command-unknown: "&cUnknown command '&e{command}&c'!"
command-argument-unexpected: "&cUnexpected argument '&e{argument}&c'."
command-argument-requires-player: "&cArgument '&e{argumentFormat}&c' requires a player to execute the command."
command-argument-missing: "&cMissing argument '&e{argumentFormat}&c'."
command-argument-invalid: "&cInvalid argument '&e{argument}&c'."
command-player-argument-missing: "&cNo player specified for '&e{argumentFormat}&c'."
command-player-argument-invalid: "&cNo player found for '&e{argument}&c'."
command-shop-type-argument-invalid: "&cUnknown shop type '&e{argument}&c'."
command-shop-object-type-argument-invalid: "&cUnknown shop object type '&e{argument}&c'."
command-shopkeeper-argument-invalid: "&cNo shopkeeper found for '&e{argument}&c'."
command-shopkeeper-argument-no-admin-shop: "&cShopkeeper '&e{argument}&c' is no admin shopkeeper."
command-shopkeeper-argument-no-player-shop: "&cShopkeeper '&e{argument}&c' is no player shopkeeper."
ambiguous-player-name: "&cThere are multiple matches for the name '&e{name}&c'!"
ambiguous-player-name-entry: "&c - '&e{name}&r&c' (&6{uuid}&c)"
ambiguous-player-name-more: "&c - ...."
command-help-title: "&9***** &8[&6Shopkeepers v{version}&8] &9*****"
command-help-usage-format: "&e{usage}"
command-help-description-format: "&8 - &3{description}"
command-description-shopkeeper: "Creates a shopkeeper."
command-description-help: "Shows this help page."
command-description-reload: "Reloads this plugin."
command-description-debug: "Toggles debug mode on and off."
command-description-list: "Lists all shops for the specified player, or all admin shops."
command-description-remove: "Removes all shops for the specified player, all players, or all admin shops."
command-description-give: "Gives shop creation item(s) to the specified player."
command-description-give-currency: "Gives currency item(s) to the specified player."
command-description-convert-items: "Converts the held (or all) items to conform to Spigot's data format."
command-description-remote: "Remotely opens a shop (Optionally: For another player)."
command-description-remote-edit: "Remotely edits a shop."
command-description-transfer: "Transfers the ownership of a shop."
command-description-settradeperm: "Sets, removes (-) or displays (?) the trading permission."
command-description-setforhire: "Sets one of your shops for sale."
command-description-edit-villager: "Opens the editor for the target villager."

View File

@ -18,20 +18,19 @@ import com.nisovin.shopkeepers.text.Text;
public class TextTest extends AbstractBukkitTest {
// tests Text parsing and backwards conversion with the actual default messages extracted from the default config
// Tests Text parsing and backwards conversion with the actual default messages extracted from the default config
@Test
public void testRealMessageConversions() throws IOException {
// read default config:
Configuration config;
ClassLoader classLoader = this.getClass().getClassLoader();
try (Reader reader = new BufferedReader(new InputStreamReader(classLoader.getResourceAsStream("config.yml")))) {
try (Reader reader = new BufferedReader(new InputStreamReader(classLoader.getResourceAsStream("lang/language-en-default.yml")))) {
config = YamlConfiguration.loadConfiguration(reader);
}
Set<String> configKeys = config.getKeys(false);
int tested = 0;
for (String key : configKeys) {
if (!key.startsWith("msg")) continue;
Object value = config.get(key);
if (value.getClass() != String.class) continue;