Recoded Paginated menu api and redid all arena menus
This commit is contained in:
parent
e11fdd3931
commit
1775f11016
@ -4,6 +4,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import rip.tilly.bedwars.BedWars;
|
||||
import rip.tilly.bedwars.menus.arena.buttons.ArenaButton;
|
||||
import rip.tilly.bedwars.utils.CC;
|
||||
import rip.tilly.bedwars.utils.ItemBuilder;
|
||||
import rip.tilly.bedwars.utils.menu.Button;
|
||||
import rip.tilly.bedwars.utils.menu.pagination.PageButton;
|
||||
@ -18,7 +19,7 @@ public class ArenaManagerMenu extends PaginatedMenu {
|
||||
|
||||
@Override
|
||||
public String getPrePaginatedTitle(Player player) {
|
||||
return "Arena Management";
|
||||
return CC.translate("&eArena Management");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,20 +25,19 @@ public class ArenaButton extends Button {
|
||||
public ItemStack getButtonItem(Player player) {
|
||||
return new ItemBuilder(Material.valueOf(arena.getIcon()))
|
||||
.durability(arena.getIconData())
|
||||
.name("&b" + arena.getName())
|
||||
.lore(CC.translate(
|
||||
Arrays.asList(
|
||||
" ",
|
||||
"&bArena Information&7:",
|
||||
" &9&l▸ &fState: " + (arena.isEnabled() ? "&aEnabled" : "&cDisabled"),
|
||||
" &9&l▸ &fType: &b" + (arena.getAvailableArenas().size() == 0 ? "Shared" : "Standalone"),
|
||||
" &9&l▸ &fCopies: &b" + (arena.getCopiedArenas().size() == 0 ? "Not Required!" : arena.getCopiedArenas().size()),
|
||||
" &9&l▸ &fAvailable: &b" + (arena.getAvailableArenas().size() == 0 ? +1 : arena.getAvailableArenas().size()),
|
||||
" ",
|
||||
(arena.getCopiedArenas().size() == 0 ? "&4&l&mMIDDLE-CLICK &4&mto see arena copies" : "&6&lMIDDLE-CLICK &6to see arena copies"),
|
||||
"&a&lLEFT-CLICK &ato teleport to arena",
|
||||
"&b&lRIGHT CLICK &bto generate standalone arenas")
|
||||
)
|
||||
.name("&d&l" + arena.getName())
|
||||
.lore(Arrays.asList(
|
||||
" ",
|
||||
"&dArena Information:",
|
||||
" &7⚫ &9State: " + (arena.isEnabled() ? "&aEnabled" : "&cDisabled"),
|
||||
" &7⚫ &9Copies: &e" + (arena.getCopiedArenas().size() == 0 ? "&cZERO!" : arena.getCopiedArenas().size()),
|
||||
" &7⚫ &9Available: &e" + (arena.getAvailableArenas().size() == 0 ? 0 : arena.getAvailableArenas().size()),
|
||||
" ",
|
||||
"&c/arena info " + arena.getName() + " for more information.",
|
||||
" ",
|
||||
(arena.getCopiedArenas().size() == 0 ? "&4&l&mMiddle Click &4&mto see copied arenas" : "&6&lMiddle Click &6to see copied arenas"),
|
||||
"&a&lLeft Click &ato teleport to arena",
|
||||
"&b&lRight Click &bto generate copied arenas")
|
||||
)
|
||||
.hideFlags()
|
||||
.build();
|
||||
@ -46,21 +45,23 @@ public class ArenaButton extends Button {
|
||||
|
||||
@Override
|
||||
public void clicked(Player player, int slot, ClickType clickType, int hotbarButton) {
|
||||
playSuccess(player);
|
||||
playNeutral(player);
|
||||
switch (clickType) {
|
||||
case LEFT:
|
||||
player.teleport(arena.getA().toBukkitLocation());
|
||||
player.closeInventory();
|
||||
break;
|
||||
case RIGHT:
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(BedWars.getInstance(), () -> new ArenaGenerationMenu(arena).openMenu(player), 1L);
|
||||
player.closeInventory();
|
||||
break;
|
||||
case MIDDLE:
|
||||
if (arena.getCopiedArenas().size() >= 1) {
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(BedWars.getInstance(), () -> new ArenaCopyMenu(arena).openMenu(player), 1L);
|
||||
} else {
|
||||
player.sendMessage(CC.translate("&cThis arena has no copied arenas! &4Generate some!"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
player.closeInventory();
|
||||
}
|
||||
}
|
||||
|
@ -27,18 +27,17 @@ public class ArenaCopyButton extends Button {
|
||||
@Override
|
||||
public ItemStack getButtonItem(Player player) {
|
||||
return new ItemBuilder(Material.PAPER)
|
||||
.name("&8" + number)
|
||||
.name("&d&lCopy #" + number)
|
||||
.lore(CC.translate(
|
||||
Arrays.asList(
|
||||
"&bCopy Information&7:",
|
||||
" &9&l▸ &fParent Arena: &b" + arena.getName() + " &7(&f#" + number + "&7)",
|
||||
" &9&l▸ &f1st Spawn: &b" + Math.round(arenaCopy.getA().getX()) + "&7, &b" + Math.round(arenaCopy.getA().getY()) + "&7, &b" + Math.round(arenaCopy.getA().getZ()),
|
||||
" &9&l▸ &f2nd Spawn: &b" + Math.round(arenaCopy.getB().getX()) + "&7, &b" + Math.round(arenaCopy.getB().getY()) + "&7, &b" + Math.round(arenaCopy.getB().getZ()),
|
||||
" &9&l▸ &fMin Location: &b" + Math.round(arenaCopy.getMin().getX()) + "&7, &b" + Math.round(arenaCopy.getMin().getY()) + "&7, &b" + Math.round(arenaCopy.getMin().getZ()),
|
||||
" &9&l▸ &fMax Location: &b" + Math.round(arenaCopy.getMax().getX()) + "&7, &b" + Math.round(arenaCopy.getMax().getY()) + "&7, &b" + Math.round(arenaCopy.getMax().getZ()),
|
||||
" ",
|
||||
"&a&lLEFT-CLICK &ato teleport to this copy!",
|
||||
"&c&lRIGHT-CLICK &cto delete this copy!"
|
||||
"&dCopied Arena Information:",
|
||||
" &7⚫ &9Parent Arena: &e" + arena.getName(),
|
||||
" &7⚫ &91st Spawn: &e" + Math.round(arenaCopy.getA().getX()) + "&7, &e" + Math.round(arenaCopy.getA().getY()) + "&7, &e" + Math.round(arenaCopy.getA().getZ()),
|
||||
" &7⚫ &92nd Spawn: &e" + Math.round(arenaCopy.getB().getX()) + "&7, &e" + Math.round(arenaCopy.getB().getY()) + "&7, &e" + Math.round(arenaCopy.getB().getZ()),
|
||||
" ",
|
||||
"&a&lLeft Click &ato teleport to this copied arena",
|
||||
"&c&lRight Click &cto delete this copied arena"
|
||||
))
|
||||
)
|
||||
.build();
|
||||
|
@ -21,14 +21,14 @@ public class ArenaGenerateButton extends Button {
|
||||
@Override
|
||||
public ItemStack getButtonItem(Player player) {
|
||||
return new ItemBuilder(Material.PAPER)
|
||||
.name("&aCreate " + currentCopyAmount + " Arena Copies")
|
||||
.name("&eCreate " + currentCopyAmount + " Arena Copies")
|
||||
.lore(CC.translate(
|
||||
Arrays.asList(
|
||||
" ",
|
||||
"&7Clicking here will generate &b&l" + currentCopyAmount,
|
||||
"&7arenas for the map &b" + arena.getName() + "&7!",
|
||||
"&7Clicking here will generate &d&l" + currentCopyAmount,
|
||||
"&7arenas for the map &d&l" + arena.getName() + "&7!",
|
||||
" ",
|
||||
"&a&lLEFT-CLICK &ato generate arenas")
|
||||
"&a&lLeft Click &ato generate arenas")
|
||||
))
|
||||
.amount(currentCopyAmount)
|
||||
.build();
|
||||
@ -39,11 +39,10 @@ public class ArenaGenerateButton extends Button {
|
||||
player.performCommand("arena generate " + arena.getName() + " " + currentCopyAmount);
|
||||
|
||||
player.sendMessage(CC.chatBar);
|
||||
player.sendMessage(CC.translate("&b&lGENERATING ARENAS&b..."));
|
||||
player.sendMessage(CC.translate("&d&lGENERATING ARENAS&d..."));
|
||||
player.sendMessage(CC.translate(" "));
|
||||
player.sendMessage(CC.translate("&fFrost is currently generating copies for:"));
|
||||
player.sendMessage(CC.translate(" &9&l▸ &fArena: &b" + arena.getName()));
|
||||
player.sendMessage(CC.translate(" &9&l▸ &fCopies: &b" + currentCopyAmount));
|
||||
player.sendMessage(CC.translate(" &7⚫ &9Arena: &e" + arena.getName()));
|
||||
player.sendMessage(CC.translate(" &7⚫ &9Copies: &e" + currentCopyAmount));
|
||||
player.sendMessage(CC.translate(" "));
|
||||
player.sendMessage(CC.translate("&7&oYou can check the progress in console."));
|
||||
player.sendMessage(CC.chatBar);
|
||||
|
@ -1,15 +1,16 @@
|
||||
package rip.tilly.bedwars.utils.menu.buttons;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import rip.tilly.bedwars.utils.ItemBuilder;
|
||||
import rip.tilly.bedwars.utils.menu.Button;
|
||||
import rip.tilly.bedwars.utils.menu.Menu;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class BackButton extends Button {
|
||||
|
||||
@ -17,19 +18,16 @@ public class BackButton extends Button {
|
||||
|
||||
@Override
|
||||
public ItemStack getButtonItem(Player player) {
|
||||
ItemStack itemStack = new ItemStack(Material.BED);
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
|
||||
itemMeta.setDisplayName(ChatColor.RED + "Go back");
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
|
||||
return itemStack;
|
||||
return new ItemBuilder(Material.BED)
|
||||
.name("&cGo Back")
|
||||
.lore(Arrays.asList(" ", "&9Click to go back."))
|
||||
.hideFlags()
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clicked(Player player, int i, ClickType clickType, int hb) {
|
||||
Button.playNeutral(player);
|
||||
|
||||
this.back.openMenu(player);
|
||||
playNeutral(player);
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
package rip.tilly.bedwars.utils.menu.pagination;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import rip.tilly.bedwars.utils.ItemBuilder;
|
||||
import rip.tilly.bedwars.utils.menu.Button;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class JumpToPageButton extends Button {
|
||||
@ -20,26 +20,27 @@ public class JumpToPageButton extends Button {
|
||||
|
||||
@Override
|
||||
public ItemStack getButtonItem(Player player) {
|
||||
ItemStack itemStack = new ItemStack(this.current ? Material.ENCHANTED_BOOK : Material.BOOK, this.page);
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
|
||||
itemMeta.setDisplayName(ChatColor.GREEN + "Page " + this.page);
|
||||
List<String> lore = new ArrayList<>();
|
||||
|
||||
lore.add(" ");
|
||||
if (this.current) {
|
||||
itemMeta.setLore(Arrays.asList(
|
||||
"",
|
||||
ChatColor.GREEN + "Current page"
|
||||
));
|
||||
lore.add("&9Current page");
|
||||
} else {
|
||||
lore.add("&9Other page");
|
||||
}
|
||||
lore.add(" ");
|
||||
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
|
||||
return itemStack;
|
||||
return new ItemBuilder(Material.INK_SACK)
|
||||
.name("&d&lPage: &e" + this.page)
|
||||
.durability(this.current ? 10 : 8)
|
||||
.lore(lore)
|
||||
.hideFlags()
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clicked(Player player, int i, ClickType clickType, int hb) {
|
||||
this.menu.modPage(player, this.page - this.menu.getPage());
|
||||
Button.playNeutral(player);
|
||||
playNeutral(player);
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
package rip.tilly.bedwars.utils.menu.pagination;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import rip.tilly.bedwars.utils.ItemBuilder;
|
||||
import rip.tilly.bedwars.utils.menu.Button;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class PageButton extends Button {
|
||||
@ -19,24 +19,19 @@ public class PageButton extends Button {
|
||||
|
||||
@Override
|
||||
public ItemStack getButtonItem(Player player) {
|
||||
ItemStack itemStack = new ItemStack(Material.CARPET);
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
List<String> lore = new ArrayList<>();
|
||||
|
||||
if (this.hasNext(player)) {
|
||||
itemMeta.setDisplayName(this.mod > 0 ? ChatColor.GREEN + "Next page" : ChatColor.RED + "Previous page");
|
||||
} else {
|
||||
itemMeta.setDisplayName(ChatColor.GRAY + (this.mod > 0 ? "Last page" : "First page"));
|
||||
}
|
||||
lore.add(" ");
|
||||
lore.add("&9Right Click to");
|
||||
lore.add("&9switch to a page.");
|
||||
lore.add(" ");
|
||||
|
||||
itemMeta.setLore(Arrays.asList(
|
||||
"",
|
||||
ChatColor.GREEN + "Right click to",
|
||||
ChatColor.GREEN + "jump to a page"
|
||||
));
|
||||
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
|
||||
return itemStack;
|
||||
return new ItemBuilder(Material.CARPET)
|
||||
.name(this.hasNext(player) ? (this.mod > 0 ? "&aNext Page" : "&cPrevious Page") : (this.mod > 0 ? "&7Last Page" : "&7First Page"))
|
||||
.durability(this.hasNext(player) ? (this.mod > 0 ? 5 : 14) : 8)
|
||||
.lore(lore)
|
||||
.hideFlags()
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -47,9 +42,9 @@ public class PageButton extends Button {
|
||||
} else {
|
||||
if (hasNext(player)) {
|
||||
this.menu.modPage(player, this.mod);
|
||||
Button.playNeutral(player);
|
||||
playNeutral(player);
|
||||
} else {
|
||||
Button.playFail(player);
|
||||
playFail(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,10 @@ package rip.tilly.bedwars.utils.menu.pagination;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import rip.tilly.bedwars.utils.CC;
|
||||
import rip.tilly.bedwars.utils.ItemBuilder;
|
||||
import rip.tilly.bedwars.utils.menu.Button;
|
||||
import rip.tilly.bedwars.utils.menu.Menu;
|
||||
import rip.tilly.bedwars.utils.menu.buttons.BackButton;
|
||||
@ -19,7 +21,7 @@ public class ViewAllPagesMenu extends Menu {
|
||||
|
||||
@Override
|
||||
public String getTitle(Player player) {
|
||||
return CC.translate("&eJump to page");
|
||||
return CC.translate("&eSwitch to page...");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -37,6 +39,8 @@ public class ViewAllPagesMenu extends Menu {
|
||||
}
|
||||
}
|
||||
|
||||
fillEmptySlots(buttons, new ItemBuilder(Material.STAINED_GLASS_PANE).durability(7).name(" ").build());
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
||||
@ -44,4 +48,9 @@ public class ViewAllPagesMenu extends Menu {
|
||||
public boolean isAutoUpdate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return 3 * 9;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user