3
0
Mirror von https://github.com/TheSilentPro/HeadDB.git synchronisiert 2024-12-27 03:12:40 +01:00
Dieser Commit ist enthalten in:
Silent 2022-02-15 18:55:13 +01:00
Ursprung e12944145b
Commit 0e81da9d7c
10 geänderte Dateien mit 190 neuen und 46 gelöschten Zeilen

Datei anzeigen

@ -6,7 +6,7 @@
<groupId>tsp.headdb</groupId> <groupId>tsp.headdb</groupId>
<artifactId>HeadDB</artifactId> <artifactId>HeadDB</artifactId>
<version>3.1.1</version> <version>3.2.0</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>HeadDB</name> <name>HeadDB</name>

Datei anzeigen

@ -11,22 +11,28 @@ import tsp.headdb.listener.JoinListener;
import tsp.headdb.listener.MenuListener; import tsp.headdb.listener.MenuListener;
import tsp.headdb.listener.PagedPaneListener; import tsp.headdb.listener.PagedPaneListener;
import tsp.headdb.storage.PlayerDataFile; import tsp.headdb.storage.PlayerDataFile;
import tsp.headdb.util.Localization;
import tsp.headdb.util.Log; import tsp.headdb.util.Log;
import tsp.headdb.util.Metrics; import tsp.headdb.util.Metrics;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
public class HeadDB extends JavaPlugin { public class HeadDB extends JavaPlugin {
private static HeadDB instance; private static HeadDB instance;
private Economy economy; private Economy economy;
private PlayerDataFile playerData; private PlayerDataFile playerData;
private Localization localization;
@Override @Override
public void onEnable() { public void onEnable() {
instance = this; instance = this;
Log.info("Loading HeadDB - " + getDescription().getVersion()); Log.info("Loading HeadDB - " + getDescription().getVersion());
saveDefaultConfig(); saveDefaultConfig();
createLocalizationFile();
this.playerData = new PlayerDataFile("player_data.json"); this.playerData = new PlayerDataFile("player_data.json");
this.playerData.load(); this.playerData.load();
@ -62,13 +68,8 @@ public class HeadDB extends JavaPlugin {
this.playerData.save(); this.playerData.save();
} }
private Economy setupEconomy() { public Localization getLocalization() {
if (!this.getServer().getPluginManager().isPluginEnabled("Vault")) return null; return localization;
RegisteredServiceProvider<Economy> economyProvider = this.getServer().getServicesManager().getRegistration(Economy.class);
if (economyProvider == null) return null;
return this.economy = economyProvider.getProvider();
} }
@Nullable @Nullable
@ -84,4 +85,36 @@ public class HeadDB extends JavaPlugin {
return instance; return instance;
} }
private Economy setupEconomy() {
if (!this.getServer().getPluginManager().isPluginEnabled("Vault")) return null;
RegisteredServiceProvider<Economy> economyProvider = this.getServer().getServicesManager().getRegistration(Economy.class);
if (economyProvider == null) return null;
return this.economy = economyProvider.getProvider();
}
private void createLocalizationFile() {
if (getClass().getResource("messages.yml") == null || new File(getDataFolder() + "/messages.yml").exists()) {
// File exists or not default available
return;
}
try {
saveResource("messages.yml", false);
File messagesFile = new File(getDataFolder() + "/messages.yml");
if (!messagesFile.exists()) {
messagesFile = new File(getClass().getResource("messages.yml").toURI());
messagesFile.createNewFile();
}
this.localization = new Localization(messagesFile);
this.localization.load();
Log.debug("Localization loaded from jar file.");
} catch (URISyntaxException | IOException ex) {
Log.error("Failed to load localization!");
Log.error(ex);
}
}
} }

Datei anzeigen

@ -5,7 +5,9 @@ import com.mojang.authlib.properties.Property;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import tsp.headdb.HeadDB;
import tsp.headdb.database.Category; import tsp.headdb.database.Category;
import tsp.headdb.util.Log; import tsp.headdb.util.Log;
import tsp.headdb.util.Utils; import tsp.headdb.util.Utils;
@ -23,6 +25,7 @@ public class Head {
private Category category; private Category category;
private int id; private int id;
private List<String> tags; private List<String> tags;
private ItemStack menuItem;
private ItemStack itemStack; private ItemStack itemStack;
public Head() {} public Head() {}
@ -31,8 +34,8 @@ public class Head {
this.id = id; this.id = id;
} }
public ItemStack getItemStack() { public ItemStack getMenuItem() {
if (itemStack == null) { if (menuItem == null) {
Validate.notNull(name, "name must not be null!"); Validate.notNull(name, "name must not be null!");
Validate.notNull(uuid, "uuid must not be null!"); Validate.notNull(uuid, "uuid must not be null!");
Validate.notNull(value, "value must not be null!"); Validate.notNull(value, "value must not be null!");
@ -61,7 +64,19 @@ public class Head {
)); ));
item.setItemMeta(meta); item.setItemMeta(meta);
itemStack = item; menuItem = item;
}
return menuItem;
}
public ItemStack getItemStack() {
if (itemStack == null) {
itemStack = menuItem;
ItemMeta meta = itemStack.getItemMeta();
meta.setDisplayName(HeadDB.getInstance().getLocalization().getMessage("head.name"));
meta.setLore(HeadDB.getInstance().getLocalization().getData().getStringList("head.lore"));
itemStack.setItemMeta(meta);
} }
return itemStack; return itemStack;

Datei anzeigen

@ -22,7 +22,7 @@ public class LocalHead extends Head {
} }
@Override @Override
public ItemStack getItemStack() { public ItemStack getMenuItem() {
Validate.notNull(uuid, "uuid must not be null!"); Validate.notNull(uuid, "uuid must not be null!");
ItemStack item = new ItemStack(Material.PLAYER_HEAD); ItemStack item = new ItemStack(Material.PLAYER_HEAD);

Datei anzeigen

@ -9,6 +9,7 @@ import org.bukkit.inventory.ItemStack;
import tsp.headdb.HeadDB; import tsp.headdb.HeadDB;
import tsp.headdb.api.Head; import tsp.headdb.api.Head;
import tsp.headdb.api.HeadAPI; import tsp.headdb.api.HeadAPI;
import tsp.headdb.util.Localization;
import tsp.headdb.util.Utils; import tsp.headdb.util.Utils;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -18,24 +19,26 @@ public class CommandHeadDB implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
Localization localization = HeadDB.getInstance().getLocalization();
if (args.length == 0) { if (args.length == 0) {
if (!sender.hasPermission("headdb.open")) { if (!sender.hasPermission("headdb.open")) {
Utils.sendMessage(sender, "&cNo permission!"); Utils.sendMessage(sender, localization.getMessage("noPermission"));
return true; return true;
} }
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
Utils.sendMessage(sender, "&cOnly players may open the database."); Utils.sendMessage(sender, localization.getMessage("onlyPlayers"));
return true; return true;
} }
Player player = (Player) sender; Player player = (Player) sender;
Utils.sendMessage(player, "&7Opening &cHead Database"); Utils.sendMessage(player, localization.getMessage("databaseOpen"));
HeadAPI.openDatabase(player); HeadAPI.openDatabase(player);
return true; return true;
} }
String sub = args[0]; String sub = args[0];
if (sub.equalsIgnoreCase("info") || sub.equalsIgnoreCase("i")) { if (sub.equalsIgnoreCase("info") || sub.equalsIgnoreCase("i")) {
// These should not be customizable
Utils.sendMessage(sender, "&7Running &cHeadDB - " + HeadDB.getInstance().getDescription().getVersion()); Utils.sendMessage(sender, "&7Running &cHeadDB - " + HeadDB.getInstance().getDescription().getVersion());
Utils.sendMessage(sender, "&7Created by &c" + HeadDB.getInstance().getDescription().getAuthors()); Utils.sendMessage(sender, "&7Created by &c" + HeadDB.getInstance().getDescription().getAuthors());
Utils.sendMessage(sender, "&7There are currently &c" + HeadAPI.getHeads().size() + " &7heads in the database."); Utils.sendMessage(sender, "&7There are currently &c" + HeadAPI.getHeads().size() + " &7heads in the database.");
@ -44,7 +47,7 @@ public class CommandHeadDB implements CommandExecutor {
if (sub.equalsIgnoreCase("search") || sub.equalsIgnoreCase("s")) { if (sub.equalsIgnoreCase("search") || sub.equalsIgnoreCase("s")) {
if (!sender.hasPermission("headdb.search")) { if (!sender.hasPermission("headdb.search")) {
Utils.sendMessage(sender, "&cNo permission!"); Utils.sendMessage(sender, localization.getMessage("noPermission"));
return true; return true;
} }
if (args.length < 2) { if (args.length < 2) {
@ -52,7 +55,7 @@ public class CommandHeadDB implements CommandExecutor {
return true; return true;
} }
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
Utils.sendMessage(sender, "&cOnly players may open the database."); Utils.sendMessage(sender, localization.getMessage("onlyPlayers"));
return true; return true;
} }
Player player = (Player) sender; Player player = (Player) sender;
@ -72,7 +75,7 @@ public class CommandHeadDB implements CommandExecutor {
if (sub.equalsIgnoreCase("tagsearch") || sub.equalsIgnoreCase("ts")) { if (sub.equalsIgnoreCase("tagsearch") || sub.equalsIgnoreCase("ts")) {
if (!sender.hasPermission("headdb.tagsearch")) { if (!sender.hasPermission("headdb.tagsearch")) {
Utils.sendMessage(sender, "&cNo permission!"); Utils.sendMessage(sender, localization.getMessage("noPermission"));
return true; return true;
} }
if (args.length < 2) { if (args.length < 2) {
@ -80,7 +83,7 @@ public class CommandHeadDB implements CommandExecutor {
return true; return true;
} }
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
Utils.sendMessage(sender, "&cOnly players may open the database."); Utils.sendMessage(sender, localization.getMessage("onlyPlayers"));
return true; return true;
} }
Player player = (Player) sender; Player player = (Player) sender;
@ -93,7 +96,7 @@ public class CommandHeadDB implements CommandExecutor {
if (sub.equalsIgnoreCase("give") || sub.equalsIgnoreCase("g")) { if (sub.equalsIgnoreCase("give") || sub.equalsIgnoreCase("g")) {
if (!sender.hasPermission("headdb.give")) { if (!sender.hasPermission("headdb.give")) {
Utils.sendMessage(sender, "&cNo permission!"); Utils.sendMessage(sender, localization.getMessage("noPermission"));
return true; return true;
} }
if (args.length < 3) { if (args.length < 3) {
@ -104,7 +107,7 @@ public class CommandHeadDB implements CommandExecutor {
int id = Integer.parseInt(args[1]); int id = Integer.parseInt(args[1]);
Player target = Bukkit.getPlayer(args[2]); Player target = Bukkit.getPlayer(args[2]);
if (target == null) { if (target == null) {
Utils.sendMessage(sender, "&cPlayer is not online!"); Utils.sendMessage(sender, localization.getMessage("invalidPlayer"));
return true; return true;
} }

Datei anzeigen

@ -47,7 +47,7 @@ public enum Category {
public ItemStack getItem() { public ItemStack getItem() {
if (item.containsKey(this)) { if (item.containsKey(this)) {
return item.get(this).getItemStack(); return item.get(this).getMenuItem();
} }
item.put(this, HeadAPI.getHeads(this).get(0)); item.put(this, HeadAPI.getHeads(this).get(0));

Datei anzeigen

@ -14,6 +14,7 @@ import tsp.headdb.api.HeadAPI;
import tsp.headdb.api.LocalHead; import tsp.headdb.api.LocalHead;
import tsp.headdb.database.Category; import tsp.headdb.database.Category;
import tsp.headdb.event.PlayerHeadPurchaseEvent; import tsp.headdb.event.PlayerHeadPurchaseEvent;
import tsp.headdb.util.Localization;
import tsp.headdb.util.Utils; import tsp.headdb.util.Utils;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
@ -29,6 +30,7 @@ import java.util.Map;
*/ */
public class InventoryUtils { public class InventoryUtils {
private static final Localization localization = HeadDB.getInstance().getLocalization();
private static final Map<String, Integer> uiLocation = new HashMap<>(); private static final Map<String, Integer> uiLocation = new HashMap<>();
private static final Map<String, ItemStack> uiItem = new HashMap<>(); private static final Map<String, ItemStack> uiItem = new HashMap<>();
@ -56,7 +58,7 @@ public class InventoryUtils {
int id = HeadDB.getInstance().getConfig().getInt("ui.category." + category + ".head"); int id = HeadDB.getInstance().getConfig().getInt("ui.category." + category + ".head");
Head head = HeadAPI.getHeadByID(id); Head head = HeadAPI.getHeadByID(id);
if (head != null) { if (head != null) {
uiItem.put(category, head.getItemStack()); uiItem.put(category, head.getMenuItem());
return uiItem.get(category); return uiItem.get(category);
} }
} }
@ -79,11 +81,12 @@ public class InventoryUtils {
} }
public static void openLocalMenu(Player player) { public static void openLocalMenu(Player player) {
PagedPane pane = new PagedPane(4, 6, Utils.colorize("&c&lHeadDB &8- &aLocal Heads"));
List<LocalHead> heads = HeadAPI.getLocalHeads(); List<LocalHead> heads = HeadAPI.getLocalHeads();
PagedPane pane = new PagedPane(4, 6,
replace(localization.getMessage("menu.local"), heads.size(), "Local", "None", player));
for (LocalHead localHead : heads) { for (LocalHead localHead : heads) {
pane.addButton(new Button(localHead.getItemStack(), e -> { pane.addButton(new Button(localHead.getMenuItem(), e -> {
if (e.getClick() == ClickType.SHIFT_LEFT) { if (e.getClick() == ClickType.SHIFT_LEFT) {
purchaseHead(player, localHead, 64, "local", localHead.getName()); purchaseHead(player, localHead, 64, "local", localHead.getName());
return; return;
@ -93,7 +96,7 @@ public class InventoryUtils {
return; return;
} }
if (e.getClick() == ClickType.RIGHT) { if (e.getClick() == ClickType.RIGHT) {
Utils.sendMessage(player, "&cLocal heads can not be added to favorites!"); Utils.sendMessage(player, localization.getMessage("localFavorites"));
} }
})); }));
} }
@ -102,11 +105,12 @@ public class InventoryUtils {
} }
public static void openFavoritesMenu(Player player) { public static void openFavoritesMenu(Player player) {
PagedPane pane = new PagedPane(4, 6, Utils.colorize("&c&lHeadDB &8- &eFavorites: " + player.getName()));
List<Head> heads = HeadAPI.getFavoriteHeads(player.getUniqueId()); List<Head> heads = HeadAPI.getFavoriteHeads(player.getUniqueId());
PagedPane pane = new PagedPane(4, 6,
replace(localization.getMessage("menu.favorites"), heads.size(), "Favorites", "None", player));
for (Head head : heads) { for (Head head : heads) {
pane.addButton(new Button(head.getItemStack(), e -> { pane.addButton(new Button(head.getMenuItem(), e -> {
if (e.getClick() == ClickType.SHIFT_LEFT) { if (e.getClick() == ClickType.SHIFT_LEFT) {
purchaseHead(player, head, 64, head.getCategory().getName(), head.getName()); purchaseHead(player, head, 64, head.getCategory().getName(), head.getName());
return; return;
@ -127,11 +131,12 @@ public class InventoryUtils {
} }
public static PagedPane openSearchDatabase(Player player, String search) { public static PagedPane openSearchDatabase(Player player, String search) {
PagedPane pane = new PagedPane(4, 6, Utils.colorize("&c&lHeadDB &8- &eSearch: " + search));
List<Head> heads = HeadAPI.getHeadsByName(search); List<Head> heads = HeadAPI.getHeadsByName(search);
PagedPane pane = new PagedPane(4, 6,
replace(localization.getMessage("menu.search"), heads.size(), "None", search, player));
for (Head head : heads) { for (Head head : heads) {
pane.addButton(new Button(head.getItemStack(), e -> { pane.addButton(new Button(head.getMenuItem(), e -> {
if (e.getClick() == ClickType.SHIFT_LEFT) { if (e.getClick() == ClickType.SHIFT_LEFT) {
purchaseHead(player, head, 64, head.getCategory().getName(), head.getName()); purchaseHead(player, head, 64, head.getCategory().getName(), head.getName());
return; return;
@ -141,7 +146,7 @@ public class InventoryUtils {
} }
if (e.getClick() == ClickType.RIGHT) { if (e.getClick() == ClickType.RIGHT) {
if (!player.hasPermission("headdb.favorites")) { if (!player.hasPermission("headdb.favorites")) {
Utils.sendMessage(player, "&cYou do not have permission for favorites!"); Utils.sendMessage(player, localization.getMessage("noPermission"));
Utils.playSound(player, "noPermission"); Utils.playSound(player, "noPermission");
return; return;
} }
@ -158,11 +163,12 @@ public class InventoryUtils {
} }
public static void openTagSearchDatabase(Player player, String tag) { public static void openTagSearchDatabase(Player player, String tag) {
PagedPane pane = new PagedPane(4, 6, Utils.colorize("&c&lHeadDB &8- &eTag Search: " + tag));
List<Head> heads = HeadAPI.getHeadsByTag(tag); List<Head> heads = HeadAPI.getHeadsByTag(tag);
PagedPane pane = new PagedPane(4, 6,
replace(localization.getMessage("menu.tagSearch"), heads.size(), "None", tag, player));
for (Head head : heads) { for (Head head : heads) {
pane.addButton(new Button(head.getItemStack(), e -> { pane.addButton(new Button(head.getMenuItem(), e -> {
if (e.getClick() == ClickType.SHIFT_LEFT) { if (e.getClick() == ClickType.SHIFT_LEFT) {
purchaseHead(player, head, 64, head.getCategory().getName(), head.getName()); purchaseHead(player, head, 64, head.getCategory().getName(), head.getName());
return; return;
@ -172,7 +178,7 @@ public class InventoryUtils {
} }
if (e.getClick() == ClickType.RIGHT) { if (e.getClick() == ClickType.RIGHT) {
if (!player.hasPermission("headdb.favorites")) { if (!player.hasPermission("headdb.favorites")) {
Utils.sendMessage(player, "&cYou do not have permission for favorites!"); Utils.sendMessage(player, localization.getMessage("noPermission"));
Utils.playSound(player, "noPermission"); Utils.playSound(player, "noPermission");
return; return;
} }
@ -188,11 +194,12 @@ public class InventoryUtils {
} }
public static void openCategoryDatabase(Player player, Category category) { public static void openCategoryDatabase(Player player, Category category) {
PagedPane pane = new PagedPane(4, 6, Utils.colorize("&c&lHeadDB &8- &e" + category.getName()));
List<Head> heads = HeadAPI.getHeads(category); List<Head> heads = HeadAPI.getHeads(category);
PagedPane pane = new PagedPane(4, 6,
replace(localization.getMessage("menu.category"), heads.size(), category.getName(), "None", player));
for (Head head : heads) { for (Head head : heads) {
pane.addButton(new Button(head.getItemStack(), e -> { pane.addButton(new Button(head.getMenuItem(), e -> {
if (e.getClick() == ClickType.SHIFT_LEFT) { if (e.getClick() == ClickType.SHIFT_LEFT) {
purchaseHead(player, head, 64, head.getCategory().getName(), head.getName()); purchaseHead(player, head, 64, head.getCategory().getName(), head.getName());
return; return;
@ -202,7 +209,7 @@ public class InventoryUtils {
} }
if (e.getClick() == ClickType.RIGHT) { if (e.getClick() == ClickType.RIGHT) {
if (!player.hasPermission("headdb.favorites")) { if (!player.hasPermission("headdb.favorites")) {
Utils.sendMessage(player, "&cYou do not have permission for favorites!"); Utils.sendMessage(player, localization.getMessage("noPermission"));
Utils.playSound(player, "noPermission"); Utils.playSound(player, "noPermission");
return; return;
} }
@ -218,7 +225,8 @@ public class InventoryUtils {
} }
public static void openDatabase(Player player) { public static void openDatabase(Player player) {
Inventory inventory = Bukkit.createInventory(null, 54, Utils.colorize("&c&lHeadDB &8(" + HeadAPI.getHeads().size() + ")")); Inventory inventory = Bukkit.createInventory(null, 54,
replace(localization.getMessage("menu.main"), HeadAPI.getHeads().size(), "Main", "None", player));
for (Category category : Category.cache) { for (Category category : Category.cache) {
ItemStack item = getUIItem(category.getName(), category.getItem()); ItemStack item = getUIItem(category.getName(), category.getItem());
@ -345,4 +353,12 @@ public class InventoryUtils {
} }
} }
private static String replace(String message, int size, String category, String search, Player player) {
return message
.replace("%size%", String.valueOf(size))
.replace("%category%", category)
.replace("%search%", search)
.replace("%player%", player.getName());
}
} }

Datei anzeigen

@ -220,7 +220,7 @@ public class PagedPane implements InventoryHolder {
"&7Previous: &c%d", "&7Previous: &c%d",
getCurrentPage() - 1 getCurrentPage() - 1
); );
ItemStack itemStack = setMeta(HeadAPI.getHeadByValue("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODY1MmUyYjkzNmNhODAyNmJkMjg2NTFkN2M5ZjI4MTlkMmU5MjM2OTc3MzRkMThkZmRiMTM1NTBmOGZkYWQ1ZiJ9fX0=").getItemStack(), name, lore); ItemStack itemStack = setMeta(HeadAPI.getHeadByValue("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODY1MmUyYjkzNmNhODAyNmJkMjg2NTFkN2M5ZjI4MTlkMmU5MjM2OTc3MzRkMThkZmRiMTM1NTBmOGZkYWQ1ZiJ9fX0=").getMenuItem(), name, lore);
controlBack = new Button(itemStack, event -> selectPage(currentIndex - 1)); controlBack = new Button(itemStack, event -> selectPage(currentIndex - 1));
inventory.setItem(inventory.getSize() - 8, itemStack); inventory.setItem(inventory.getSize() - 8, itemStack);
} }
@ -236,7 +236,7 @@ public class PagedPane implements InventoryHolder {
"&7Next: &c%d", "&7Next: &c%d",
getCurrentPage() + 1 getCurrentPage() + 1
); );
ItemStack itemStack = setMeta(HeadAPI.getHeadByValue("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMmEzYjhmNjgxZGFhZDhiZjQzNmNhZThkYTNmZTgxMzFmNjJhMTYyYWI4MWFmNjM5YzNlMDY0NGFhNmFiYWMyZiJ9fX0=").getItemStack(), name, lore); ItemStack itemStack = setMeta(HeadAPI.getHeadByValue("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMmEzYjhmNjgxZGFhZDhiZjQzNmNhZThkYTNmZTgxMzFmNjJhMTYyYWI4MWFmNjM5YzNlMDY0NGFhNmFiYWMyZiJ9fX0=").getMenuItem(), name, lore);
controlNext = new Button(itemStack, event -> selectPage(getCurrentPage())); controlNext = new Button(itemStack, event -> selectPage(getCurrentPage()));
inventory.setItem(inventory.getSize() - 2, itemStack); inventory.setItem(inventory.getSize() - 2, itemStack);
} }
@ -247,7 +247,7 @@ public class PagedPane implements InventoryHolder {
"&3&lPage &a&l%d &7/ &c&l%d", "&3&lPage &a&l%d &7/ &c&l%d",
getCurrentPage(), getPageAmount() getCurrentPage(), getPageAmount()
); );
ItemStack itemStack = setMeta(HeadAPI.getHeadByValue("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2Q5MWY1MTI2NmVkZGM2MjA3ZjEyYWU4ZDdhNDljNWRiMDQxNWFkYTA0ZGFiOTJiYjc2ODZhZmRiMTdmNGQ0ZSJ9fX0=").getItemStack(), ItemStack itemStack = setMeta(HeadAPI.getHeadByValue("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2Q5MWY1MTI2NmVkZGM2MjA3ZjEyYWU4ZDdhNDljNWRiMDQxNWFkYTA0ZGFiOTJiYjc2ODZhZmRiMTdmNGQ0ZSJ9fX0=").getMenuItem(),
name, name,
"&7Left-Click to go to the &cMain Menu", "&7Left-Click to go to the &cMain Menu",
"&7Right-Click to go to a &6Specific Page"); "&7Right-Click to go to a &6Specific Page");

Datei anzeigen

@ -0,0 +1,58 @@
package tsp.headdb.util;
import org.apache.commons.lang.Validate;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.File;
import java.util.function.UnaryOperator;
/**
* Localization class for a messages file
*
* @author TheSilentPro
*/
public class Localization {
private final File file;
@Nullable
private FileConfiguration data;
public Localization(@Nonnull File file) {
Validate.notNull(file, "File can not be null.");
this.file = file;
this.data = null;
}
public String getMessage(@Nonnull String key) {
Validate.notNull(data, "File data is null.");
Validate.notNull(key, "Message key can not be null.");
return Utils.colorize(data.getString(key));
}
public String getMessage(@Nonnull String key, @Nonnull UnaryOperator<String> function) {
Validate.notNull(data, "File data is null.");
Validate.notNull(key, "Message key can not be null.");
Validate.notNull(function, "Function can not be null.");
return function.apply(getMessage(key));
}
public void load() {
this.data = YamlConfiguration.loadConfiguration(file);
}
public File getFile() {
return file;
}
@Nullable
public FileConfiguration getData() {
return data;
}
}

Datei anzeigen

@ -0,0 +1,19 @@
noPermission: "&cNo permission!"
onlyPlayers: "&c&cOnly players may open the database."
databaseOpen: "&7Opening &cHead Database"
invalidPlayer: "&cPlayer is not online!"
localFavorites: "&cLocal heads can not be added to favorites!"
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%)"
# Head item given to players
head:
name: "%name%"
lore:
- ''