Advertisement
Auftragsgeber

Untitled

Feb 23rd, 2020
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.30 KB | None | 0 0
  1. private static Inventory create9LevelInv(final int min_lvl, final int has_lvl, final int xp){
  2. // min_lvl: das niedrigste level, das angezeigt werden soll
  3. // has_lvl: aktuelles level
  4. // xp: aktuelle xp
  5.  
  6. final int max_lvl = min_lvl + 8;
  7.  
  8. Inventory inv = Bukkit.createInventory(null, 45,"§1Levelübersicht§g");
  9. ItemStack has_item = new ItemStack(Material.LIME_STAINED_GLASS_PANE);
  10. ItemStack is_item = new ItemStack(Material.YELLOW_STAINED_GLASS_PANE);
  11. ItemStack not_item = new ItemStack(Material.RED_STAINED_GLASS_PANE);
  12.  
  13. List<String> has_lore = new ArrayList<>();
  14. has_lore.add("§r");
  15. has_lore.add("§7Du hast dieses Level bereits erreicht.");
  16. has_lore.add("§r");
  17. has_lore.add("§7Fortschritt: §a::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::");
  18.  
  19. List<String> not_lore = new ArrayList<>();
  20. not_lore.add("§r");
  21. not_lore.add("§7Du hast dieses Level §cnoch nicht§7 erreicht.");
  22. not_lore.add("§r");
  23. not_lore.add("§7Fortschritt: §c::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::");
  24.  
  25. List<String> is_lore = new ArrayList<>();
  26. is_lore.add("§r");
  27. is_lore.add("§7Du hast dieses Level §cnoch nicht§7 erreicht.");
  28. is_lore.add("§r");
  29.  
  30. ItemStack creds = new ItemStack(CreditManager.creditMaterial);
  31. ItemStack coins = new ItemStack(CoinManager.coinMaterial);
  32.  
  33. ItemStack noth = new ItemStack(Material.WHITE_STAINED_GLASS_PANE);
  34. ItemStack five = new ItemStack(Material.LIGHT_GRAY_STAINED_GLASS_PANE);
  35. ItemStack ten = new ItemStack(Material.GRAY_STAINED_GLASS_PANE);
  36.  
  37. ItemMeta empt = noth.getItemMeta();
  38. empt.setDisplayName("§r");
  39. noth.setItemMeta(empt);
  40. five.setItemMeta(empt);
  41. ten.setItemMeta(empt);
  42.  
  43. for (int lvl = min_lvl; lvl <= max_lvl ; lvl++){
  44. if (lvl <= has_lvl){
  45. ItemMeta meta = has_item.getItemMeta();
  46. meta.setDisplayName("§aLevel §l§a§s" + lvl);
  47. meta.setLore(has_lore);
  48. has_item.setItemMeta(meta);
  49. // 2. Reihe = lvl - min_lvl + 9
  50. inv.setItem(lvl-min_lvl+9, has_item);
  51. }else if ((has_lvl + 1) == lvl){
  52. ItemMeta meta = is_item.getItemMeta();
  53. meta.setDisplayName("§eLevel §l§e§s" + lvl);
  54. String fort = "§7Fortschritt: §a";
  55. int prog = (int) ((float) xp / getXPNeededForLevel(has_lvl) *60);
  56. for (int i = 1 ; i <= 60; i++){
  57. if (prog >= i){
  58. fort += ":";
  59. }else{
  60. fort += "§c:";
  61. }
  62. }
  63. is_lore.add(fort);
  64. meta.setLore(is_lore);
  65. is_item.setItemMeta(meta);
  66. inv.setItem(lvl-min_lvl+9,is_item);
  67. }else{
  68. ItemMeta meta = not_item.getItemMeta();
  69. meta.setDisplayName("§4Level §l§4§s" + lvl);
  70. meta.setLore(not_lore);
  71. not_item.setItemMeta(meta);
  72. // 2. Reihe = lvl - min_lvl + 9
  73. inv.setItem(lvl-min_lvl+9, not_item);
  74. }
  75. if (lvl != 0){
  76. if (lvl % 10 == 0){
  77. int z = lvl / 10;
  78. int cre = z *10;
  79. ItemMeta meta = creds.getItemMeta();
  80. meta.setDisplayName(CreditManager.creditColorCode + cre + " Credits");
  81. if (lvl <= has_lvl){
  82. meta.setLore(has_lore);
  83. }else if ((has_lvl+1) == lvl){
  84. meta.setLore(is_lore);
  85. }else {
  86. meta.setLore(not_lore);
  87. }
  88. creds.setItemMeta(meta);
  89. inv.setItem(lvl-min_lvl,ten);
  90. inv.setItem(lvl-min_lvl+18,creds);
  91. inv.setItem(lvl-min_lvl+27,ten);
  92. }else if (lvl % 5 == 0){
  93. // TODO: Lootkisten impl
  94. inv.setItem(lvl-min_lvl,five);
  95. //lootkiste
  96. inv.setItem(lvl-min_lvl+27,five);
  97. }else{
  98. final int basis = 7; // TODO: Feintuning
  99. int coi = basis * lvl;
  100. ItemMeta meta = coins.getItemMeta();
  101. meta.setDisplayName(CoinManager.coinColorCode + coi + " Coins");
  102. if (lvl <= has_lvl){
  103. meta.setLore(has_lore);
  104. }else if ((has_lvl+1) == lvl){
  105. meta.setLore(is_lore);
  106. }else {
  107. meta.setLore(not_lore);
  108. }
  109. coins.setItemMeta(meta);
  110. inv.setItem(lvl-min_lvl,noth);
  111. inv.setItem(lvl-min_lvl+18,coins);
  112. inv.setItem(lvl-min_lvl+27,noth);
  113. }
  114. }else{
  115. ItemStack no = new ItemStack(Material.BARRIER);
  116. ItemMeta nmeta = no.getItemMeta();
  117. nmeta.setDisplayName("§4Keine Belohnung für diese Stufe");
  118. nmeta.setLore(has_lore);
  119. no.setItemMeta(nmeta);
  120. inv.setItem(lvl-min_lvl+18,no);
  121. }
  122. }
  123.  
  124. ItemStack prev = new ItemStack(Material.LIME_WOOL);
  125. ItemMeta prev_meta = prev.getItemMeta();
  126. prev_meta.setDisplayName("§a←");
  127. prev.setItemMeta(prev_meta);
  128.  
  129.  
  130. ItemStack next = new ItemStack(Material.RED_WOOL);
  131. ItemMeta next_meta = prev.getItemMeta();
  132. next_meta.setDisplayName("§4→");
  133. next.setItemMeta(next_meta);
  134.  
  135. ItemStack n = new ItemStack(Material.BLACK_STAINED_GLASS_PANE);
  136. n.setItemMeta(empt);
  137.  
  138. if (min_lvl > 0){
  139. for (int i = 36 ; i <= 39 ; i++){
  140. inv.setItem(i, prev);
  141. }
  142. }else{
  143. for (int i = 36 ; i <= 40 ; i++){
  144. inv.setItem(i, n);
  145. }
  146. }
  147. for (int i = 41 ; i <= 44 ; i++){
  148. inv.setItem(i, next);
  149. }
  150.  
  151.  
  152. return inv;
  153. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement