diff --git a/src/main/java/tsp/headdb/command/CommandHeadDB.java b/src/main/java/tsp/headdb/command/CommandHeadDB.java index 2d779f8..43f70e7 100644 --- a/src/main/java/tsp/headdb/command/CommandHeadDB.java +++ b/src/main/java/tsp/headdb/command/CommandHeadDB.java @@ -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; } diff --git a/src/main/java/tsp/headdb/inventory/InventoryUtils.java b/src/main/java/tsp/headdb/inventory/InventoryUtils.java index d9e7c3d..329f75b 100644 --- a/src/main/java/tsp/headdb/inventory/InventoryUtils.java +++ b/src/main/java/tsp/headdb/inventory/InventoryUtils.java @@ -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 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; } diff --git a/src/main/java/tsp/headdb/util/Utils.java b/src/main/java/tsp/headdb/util/Utils.java index cea3e34..ca26eac 100644 --- a/src/main/java/tsp/headdb/util/Utils.java +++ b/src/main/java/tsp/headdb/util/Utils.java @@ -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) { diff --git a/src/main/resources/messages.yml b/src/main/resources/messages.yml index bbfc5ae..6838218 100644 --- a/src/main/resources/messages.yml +++ b/src/main/resources/messages.yml @@ -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%)" \ No newline at end of file + 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" \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 0a40ed8..1b602f4 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -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 \ No newline at end of file