Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
UnlimitedNinjas committed Feb 17, 2022
2 parents d00fe65 + 6008217 commit ce442b6
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
6 changes: 5 additions & 1 deletion src/main/java/tsp/headdb/command/CommandHeadDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ public boolean onCommand(CommandSender sender, Command command, String s, String
}

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;
}

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/tsp/headdb/inventory/InventoryUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ public static void openDatabase(Player player) {
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);
Expand Down Expand Up @@ -312,7 +312,7 @@ public static boolean processPayment(Player player, int amount, String category,
// 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;
}
Expand All @@ -323,17 +323,17 @@ public static boolean processPayment(Player player, int amount, String category,
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;
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/tsp/headdb/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public static void playSound(Player player, String key) {
}

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) {
Expand Down
19 changes: 18 additions & 1 deletion src/main/resources/messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,28 @@ 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%)"
category: "&c&lHeadDB &8- &e%category%"
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"
3 changes: 3 additions & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ permissions:
headdb.local: true
headdb.tagsearch: true
headdb.update: true
headdb.reload: true
headdb.open:
default: op
headdb.search:
Expand All @@ -37,4 +38,6 @@ permissions:
headdb.tagsearch:
default: op
headdb.update:
default: op
headdb.reload:
default: op

0 comments on commit ce442b6

Please sign in to comment.