Add single language inventories
This commit is contained in:
@@ -41,6 +41,8 @@ public class Inventories implements Listener {
|
||||
}
|
||||
|
||||
private static final HashMap<String, HashMap<String, Inventory>> invs = new HashMap<>();
|
||||
private static final HashMap<String, Boolean> invType = new HashMap<>();
|
||||
private static final HashMap<String, String> invLang = new HashMap<>();
|
||||
private static final HashMap<String, HashMap<Integer, Entry<Action, Object>>> invActions = new HashMap<>();
|
||||
private static final HashMap<String, String> invNames = new HashMap<>();
|
||||
private static final HashMap<String, HashMap<String, ItemStack>> items = new HashMap<>();
|
||||
@@ -57,10 +59,26 @@ public class Inventories implements Listener {
|
||||
invNames.put(nameColor + Core.getl(name, lang), type);
|
||||
}
|
||||
invs.put(type, langInvs);
|
||||
invType.put(type, true);
|
||||
invActions.put(type, new HashMap<Integer, Entry<Action, Object>>());
|
||||
}
|
||||
|
||||
public static void buildInvItem(String type, Material m, String name, ChatColor nameColor, ChatColor loreColor, String... lores) {
|
||||
public static void registerInventory(String type, String name, ChatColor nameColor, boolean multilang, String lang) {
|
||||
if (multilang) {
|
||||
registerInventory(type, name, nameColor);
|
||||
return;
|
||||
}
|
||||
invType.put(type, false);
|
||||
HashMap<String, Inventory> langInvs = new HashMap<>();
|
||||
Inventory inv = Bukkit.createInventory(null, 9, nameColor + Core.getl(name, lang));
|
||||
langInvs.put("global", inv);
|
||||
invNames.put(nameColor + Core.getl(name, lang), type);
|
||||
invs.put(type, langInvs);
|
||||
invLang.put(type, lang);
|
||||
invActions.put(type, new HashMap<Integer, Entry<Action, Object>>());
|
||||
}
|
||||
|
||||
public static void buildInvItem(String type, Material m, String name, ChatColor nameColor, ChatColor loreColor, String... lores) { //INV!!
|
||||
HashMap<String, ItemStack> stacks = new HashMap<>();
|
||||
for (String lang : Core.getAvailLangs()) {
|
||||
ItemStack stack = new ItemStack(m);
|
||||
@@ -76,7 +94,7 @@ public class Inventories implements Listener {
|
||||
itemNames.put(display, type);
|
||||
stack.setItemMeta(meta);
|
||||
stacks.put(lang, stack);
|
||||
}
|
||||
}
|
||||
items.put(type, stacks);
|
||||
}
|
||||
|
||||
@@ -102,6 +120,26 @@ public class Inventories implements Listener {
|
||||
return stacks;
|
||||
}
|
||||
|
||||
public static HashMap<String, ItemStack> buildItems(Material m, String name, ChatColor nameColor, String lang, ChatColor loreColor, String... lores) {
|
||||
HashMap<String, ItemStack> stacks = new HashMap<>();
|
||||
ItemStack stack = new ItemStack(m);
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
meta.setDisplayName(nameColor + Core.getl(name, lang));
|
||||
if (loreColor != null) {
|
||||
for (int i = 0; i < lores.length; i++) {
|
||||
lores[i] = loreColor + Core.getl(lores[i], lang);
|
||||
}
|
||||
meta.setLore(Arrays.asList(lores));
|
||||
}
|
||||
stack.setItemMeta(meta);
|
||||
stacks.put(lang, stack);
|
||||
return stacks;
|
||||
}
|
||||
|
||||
public static HashMap<String, ItemStack> buildItems(Material m, String name, ChatColor nameColor, String lang) {
|
||||
return buildItems(m, name, nameColor, lang, null, "none");
|
||||
}
|
||||
|
||||
public static HashMap<String, ItemStack> buildItems(Material m, String name, ChatColor nameColor) {
|
||||
return buildItems(m, name, nameColor, null, "none");
|
||||
}
|
||||
@@ -132,7 +170,11 @@ public class Inventories implements Listener {
|
||||
}
|
||||
|
||||
public static Inventory getInventory(String type, Player P) {
|
||||
return invs.get(type).get(Core.getPlayerLang(P));
|
||||
if (invType.get(type)) {
|
||||
return invs.get(type).get(Core.getPlayerLang(P));
|
||||
} else {
|
||||
return invs.get(type).get("global");
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack getItem(String type, Player P) {
|
||||
|
||||
Reference in New Issue
Block a user