3
0
Mirror von https://github.com/TheSilentPro/HeadDB.git synchronisiert 2024-12-27 11:20:05 +01:00

Merge pull request #25 from Altruiis/localization-improvements

Localization & reload command improvements
Dieser Commit ist enthalten in:
Silent 2022-02-17 15:01:57 +01:00 committet von GitHub
Commit 6008217367
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
5 geänderte Dateien mit 35 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -46,8 +46,12 @@ public class CommandHeadDB implements CommandExecutor {
}
if (sub.equalsIgnoreCase("reload") || sub.equalsIgnoreCase("r")) {
if (!sender.hasPermission("headdb.reload")) {
Utils.sendMessage(sender, localization.getMessage("noPermission"));
return true;
}
HeadDB.getInstance().getLocalization().load();
Utils.sendMessage(sender, "&aReloaded messages file!");
Utils.sendMessage(sender, localization.getMessage("reloadMessages"));
return true;
}

Datei anzeigen

@ -181,9 +181,9 @@ public class InventoryUtils {
for (Category category : Category.cache) {
ItemStack item = getUIItem(category.getName(), category.getItem());
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(Utils.colorize(category.getColor() + "&l" + category.getName().toUpperCase()));
meta.setDisplayName(Utils.colorize(localization.getMessage("menu.heads." + category.getName())));
List<String> lore = new ArrayList<>();
lore.add(Utils.colorize("&e" + HeadAPI.getHeads(category).size() + " heads"));
lore.add(Utils.colorize(replace(localization.getMessage("menu.lore"), HeadAPI.getHeads(category).size(), "Main", "None", player)));
meta.setLore(lore);
item.setItemMeta(meta);
inventory.setItem(getUILocation(category.getName(), category.getLocation()), item);
@ -312,7 +312,7 @@ public class InventoryUtils {
// If economy is disabled or no plugin is present, the item is free.
// Don't mention receiving it for free in this case, since it is always free.
if (economy == null) {
Utils.sendMessage(player, String.format("&7You received &e%d &7x &e%s&7!", amount, description));
Utils.sendMessage(player, String.format(localization.getMessage("noEconomy"), amount, description));
Utils.playSound(player, "noEconomy");
return true;
}
@ -323,17 +323,17 @@ public class InventoryUtils {
if (cost > 0) {
if (economy.has(player, cost)) {
economy.withdrawPlayer(player, cost);
Utils.sendMessage(player, String.format("&7You purchased &e%d &7x &e%s &7for &e%.2f&7!", amount, description, cost));
Utils.sendMessage(player, String.format(localization.getMessage("purchasedHead"), amount, description, cost));
Utils.playSound(player, "paid");
return true;
}
Utils.sendMessage(player, String.format("&cYou do not have enough to purchase &e%d &cx &e%s&7.", amount, description));
Utils.sendMessage(player, String.format(localization.getMessage("notEnoughMoney"), amount, description));
Utils.playSound(player, "unavailable");
return false;
}
// Otherwise, the item is free.
Utils.sendMessage(player, String.format("&7You received &e%d &7x &e%s &7for &efree&7!", amount, description));
Utils.sendMessage(player, String.format(localization.getMessage("free"), amount, description));
Utils.playSound(player, "free");
return true;
}

Datei anzeigen

@ -37,7 +37,9 @@ public class Utils {
}
public static void sendMessage(CommandSender sender, String message) {
sender.sendMessage(colorize(message));
if (!message.isEmpty()) {
sender.sendMessage(colorize(message));
}
}
public static String colorize(String string) {

Datei anzeigen

@ -3,6 +3,11 @@ onlyPlayers: "&cOnly players may open the database."
databaseOpen: "&7Opening &cHead Database"
invalidPlayer: "&cPlayer is not online!"
localFavorites: "&cLocal heads can not be added to favorites!"
noEconomy: "&7You received &e%d &7x &e%s&7!"
purchasedHead: "&7You purchased &e%d &7x &e%s &7for &e%.2f&7!"
notEnoughMoney: "&cYou do not have enough to purchase &e%d &cx &e%s&7."
free: "&7You received &e%d &7x &e%s &7for &efree&7!"
reloadMessages: "&aReloaded messages file!"
menu:
main: "&c&lHeadDB &7(%size%)"
@ -10,4 +15,16 @@ menu:
tagSearch: "&c&lHeadDB &8- &eTag Search: %search%"
search: "&c&lHeadDB &8- &eSearch: %search%"
favorites: "&c&lHeadDB &8- &eFavorites: %player%"
local: "&c&lHeadDB &8- &aLocal Heads &7(%size%)"
local: "&c&lHeadDB &8- &aLocal Heads &7(%size%)"
lore: "&e%size% heads"
heads:
alphabet: "&e&lALPHABET"
animals: "&3&lANIMALS"
blocks: "&8&lBLOCKS"
decoration: "&6&lDECORATION"
food-drinks: "&6&lFOOD-DRINKS"
humans: "&1&lHUMANS"
humanoid: "&b&lHUMANOID"
miscellaneous: "&2&lMISCELLANEOUS"
monsters: "&c&lMONSTERS"
plants: "&a&lPLANTS"

Datei anzeigen

@ -24,6 +24,7 @@ permissions:
headdb.local: true
headdb.tagsearch: true
headdb.update: true
headdb.reload: true
headdb.open:
default: op
headdb.search:
@ -37,4 +38,6 @@ permissions:
headdb.tagsearch:
default: op
headdb.update:
default: op
headdb.reload:
default: op