Advertisement
JackOUT

Untitled

Dec 9th, 2021
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. package games.coob.elemental.menu;
  2.  
  3. import games.coob.elemental.skywars.SkyWarsCache;
  4. import games.coob.elemental.skywars.menu.KitSelectionMenu;
  5. import games.coob.elemental.skywars.menu.ProjectileTrailSelectionMenu;
  6. import org.bukkit.entity.Player;
  7. import org.bukkit.inventory.ItemStack;
  8. import org.mineacademy.fo.MathUtil;
  9. import org.mineacademy.fo.menu.Menu;
  10. import org.mineacademy.fo.menu.MenuPagged;
  11. import org.mineacademy.fo.menu.button.Button;
  12. import org.mineacademy.fo.menu.button.ButtonMenu;
  13. import org.mineacademy.fo.menu.model.ItemCreator;
  14. import org.mineacademy.fo.remain.CompMaterial;
  15.  
  16. public class ShopMenu extends Menu {
  17. /**
  18. * The skywars cache for convenience
  19. */
  20. private final SkyWarsCache cache;
  21.  
  22. private final Button projectileTrailButton;
  23.  
  24. private final Button kitButton;
  25.  
  26. private ShopMenu(final Player player) {
  27.  
  28. this.cache = SkyWarsCache.getCache(player);
  29.  
  30. setTitle("&2&lShop");
  31. setSize(9 * 3);
  32.  
  33. this.projectileTrailButton = new ButtonMenu(new ProjectileTrailSelectionMenu(null, player, ProjectileTrailSelectionMenu.ViewMode.PURCHASE), ItemCreator.of(
  34. CompMaterial.SPECTRAL_ARROW,
  35. "&e&lProjectile Trails",
  36. "",
  37. "&7Select or purchase",
  38. "&7projectile trails."));
  39.  
  40. this.kitButton = new ButtonMenu(new KitSelectionMenu(null, player, KitSelectionMenu.ViewMode.PURCHASE), ItemCreator.of(
  41. CompMaterial.ARMOR_STAND,
  42. "&4&lKits",
  43. "",
  44. "&7Select or purchase",
  45. "&7kits."));
  46. }
  47.  
  48. /**
  49. * @see MenuPagged#getItemAt(int)
  50. */
  51. @Override
  52. public ItemStack getItemAt(final int slot) {
  53.  
  54. if (slot == 9 + 2)
  55. return this.projectileTrailButton.getItem();
  56.  
  57. if (slot == 15)
  58. return this.kitButton.getItem();
  59.  
  60. return null;
  61. }
  62.  
  63. /**
  64. * @see Menu#getInfo()
  65. */
  66. @Override
  67. protected String[] getInfo() {
  68. return new String[]{
  69. "&aHere's a SkyWars shop.",
  70. "&aUse your gold wisely.",
  71. "",
  72. "Gold: &6" + MathUtil.formatTwoDigitsD(cache.getTotalGold())
  73. };
  74. }
  75.  
  76. // ------–------–------–------–------–------–------–------–------–------–------–------–
  77. // Static access (for usability)
  78. // ------–------–------–------–------–------–------–------–------–------–------–------–
  79.  
  80. /**
  81. * Open the cosmetics menu for the player
  82. *
  83. * @param player
  84. */
  85. public static void openMenu(final Player player) {
  86. new ShopMenu(player).displayTo(player);
  87. }
  88. }
  89.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement