diff --git a/src/main/java/net/knarcraft/minigames/gui/ArenaGUI.java b/src/main/java/net/knarcraft/minigames/gui/ArenaGUI.java
index a41e15e..0983f37 100644
--- a/src/main/java/net/knarcraft/minigames/gui/ArenaGUI.java
+++ b/src/main/java/net/knarcraft/minigames/gui/ArenaGUI.java
@@ -4,15 +4,19 @@ import net.knarcraft.knargui.AbstractGUI;
import net.knarcraft.knargui.GUIAction;
import net.knarcraft.knargui.item.GUIItemFactory;
import net.knarcraft.knargui.item.PlayerHeadGUIItemFactory;
+import net.knarcraft.knargui.item.SimpleGUIItemFactory;
import net.knarcraft.minigames.MiniGames;
import net.knarcraft.minigames.arena.ArenaPlayerRegistry;
import net.knarcraft.minigames.arena.ArenaSession;
import net.knarcraft.minigames.arena.PlayerVisibilityManager;
import net.knarcraft.minigames.arena.parkour.ParkourArenaSession;
+import net.knarcraft.minigames.util.GeyserHelper;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Material;
+import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
@@ -33,32 +37,41 @@ public abstract class ArenaGUI extends AbstractGUI {
}
/**
- * Gets an item describing a retry arena action
+ * Gets an item describing a retry arena action (for Java edition)
*
* @return
An arena restart item
*/
- protected ItemStack getRestartItem() {
+ @NotNull
+ protected ItemStack getRestartItemJava() {
PlayerHeadGUIItemFactory restartItemFactory = new PlayerHeadGUIItemFactory();
restartItemFactory.useSkin("e23b225ed0443c4eec7cf30a034490485904e6eb3d53ef2ab9e39c73bdf22c30");
- List loreLines = getLoreLines();
- loreLines.add(ChatColor.GRAY + "Use this item to retry the arena");
- restartItemFactory.setName(ChatColor.BLUE + "Retry arena");
- restartItemFactory.setLore(loreLines);
- return restartItemFactory.build();
+ return setRestartItemData(restartItemFactory);
}
/**
- * Gets an item describing a retry arena action
+ * Gets an item describing a retry arena action (for Bedrock edition)
*
* @return An arena restart item
*/
+ @NotNull
protected ItemStack getRestartItemBedrock() {
- GUIItemFactory restartItemFactory = new GUIItemFactory(Material.MAGENTA_GLAZED_TERRACOTTA);
+ return setRestartItemData(new SimpleGUIItemFactory(Material.MAGENTA_GLAZED_TERRACOTTA));
+ }
+
+ /**
+ * Sets the lore and name for a retry item, and returns the finished item
+ *
+ * @param guiItemFactory The factory to apply the data to
+ * @return The finished item, with the data applied
+ */
+ @NotNull
+ protected ItemStack setRestartItemData(@NotNull GUIItemFactory guiItemFactory) {
List loreLines = getLoreLines();
loreLines.add(ChatColor.GRAY + "Use this item to retry the arena");
- restartItemFactory.setName(ChatColor.BLUE + "Retry arena");
- restartItemFactory.setLore(loreLines);
- return restartItemFactory.build();
+ loreLines.add(ChatColor.GRAY + "(deaths and time is reset to 0)");
+ guiItemFactory.setName(ChatColor.BLUE + "Retry arena");
+ guiItemFactory.setLore(loreLines);
+ return guiItemFactory.build();
}
/**
@@ -67,7 +80,7 @@ public abstract class ArenaGUI extends AbstractGUI {
* @return A player toggle item
*/
protected ItemStack getTogglePlayersItemDisabled() {
- GUIItemFactory togglePlayersItemFactory = new GUIItemFactory(Material.PLAYER_HEAD);
+ GUIItemFactory togglePlayersItemFactory = new SimpleGUIItemFactory(Material.PLAYER_HEAD);
List loreLines = getLoreLines();
loreLines.add(ChatColor.GRAY + "Use this item to disable the visibility");
loreLines.add(ChatColor.GRAY + "of other players");
@@ -79,17 +92,26 @@ public abstract class ArenaGUI extends AbstractGUI {
/**
* Gets an item describing player visibility toggling
*
+ * @param player The player to get the item for
* @return A player toggle item
*/
- protected ItemStack getTogglePlayersItemEnabled() {
+ protected ItemStack getTogglePlayersItemEnabled(Player player) {
+ if (GeyserHelper.isGeyserPlayer(player)) {
+ return getTogglePlayersItemEnabledBedrock();
+ } else {
+ return getTogglePlayersItemEnabledJava();
+ }
+ }
+
+ /**
+ * Gets an item describing player visibility toggling
+ *
+ * @return A player toggle item
+ */
+ protected ItemStack getTogglePlayersItemEnabledJava() {
PlayerHeadGUIItemFactory togglePlayersItemFactory = new PlayerHeadGUIItemFactory();
togglePlayersItemFactory.useSkin("c10591e6909e6a281b371836e462d67a2c78fa0952e910f32b41a26c48c1757c");
- List loreLines = getLoreLines();
- loreLines.add(ChatColor.GRAY + "Use this item to enable the visibility");
- loreLines.add(ChatColor.GRAY + "of other players");
- togglePlayersItemFactory.setName(ChatColor.BLUE + "Enable Players");
- togglePlayersItemFactory.setLore(loreLines);
- return togglePlayersItemFactory.build();
+ return setTogglePlayersItemData(togglePlayersItemFactory);
}
/**
@@ -98,13 +120,22 @@ public abstract class ArenaGUI extends AbstractGUI {
* @return A player toggle item
*/
protected ItemStack getTogglePlayersItemEnabledBedrock() {
- GUIItemFactory togglePlayersItemFactory = new GUIItemFactory(Material.SKELETON_SKULL);
+ return setTogglePlayersItemData(new SimpleGUIItemFactory(Material.SKELETON_SKULL));
+ }
+
+ /**
+ * Sets the lore and name for a toggle players item, and returns the finished item
+ *
+ * @param itemFactory The factory to apply the data to
+ * @return The finished item, with the data applied
+ */
+ protected ItemStack setTogglePlayersItemData(@NotNull GUIItemFactory itemFactory) {
List loreLines = getLoreLines();
loreLines.add(ChatColor.GRAY + "Use this item to enable the visibility");
loreLines.add(ChatColor.GRAY + "of other players");
- togglePlayersItemFactory.setName(ChatColor.BLUE + "Enable Players");
- togglePlayersItemFactory.setLore(loreLines);
- return togglePlayersItemFactory.build();
+ itemFactory.setName(ChatColor.BLUE + "Enable Players");
+ itemFactory.setLore(loreLines);
+ return itemFactory.build();
}
/**
@@ -113,10 +144,10 @@ public abstract class ArenaGUI extends AbstractGUI {
* @return A give up item
*/
protected ItemStack getGiveUpItem() {
- GUIItemFactory giveUpItemFactory = new GUIItemFactory(Material.RESPAWN_ANCHOR);
+ GUIItemFactory giveUpItemFactory = new SimpleGUIItemFactory(Material.RESPAWN_ANCHOR);
List loreLines = getLoreLines();
- loreLines.add(ChatColor.GRAY + "Use this item to give up");
- loreLines.add(ChatColor.GRAY + "and go to the last checkpoint");
+ loreLines.add(ChatColor.GRAY + "Use this item to give up and");
+ loreLines.add(ChatColor.GRAY + "go to your current checkpoint");
giveUpItemFactory.setName(ChatColor.RED + "Give up");
giveUpItemFactory.setLore(loreLines);
return giveUpItemFactory.build();
@@ -128,7 +159,7 @@ public abstract class ArenaGUI extends AbstractGUI {
* @return A leave item
*/
protected ItemStack getLeaveItem() {
- GUIItemFactory leaveItemFactory = new GUIItemFactory(Material.BARRIER);
+ GUIItemFactory leaveItemFactory = new SimpleGUIItemFactory(Material.BARRIER);
List loreLines = getLoreLines();
loreLines.add(ChatColor.GRAY + "Use this item to leave the arena");
leaveItemFactory.setName(ChatColor.DARK_RED + "Leave");
@@ -198,7 +229,7 @@ public abstract class ArenaGUI extends AbstractGUI {
PlayerVisibilityManager visibilityManager = MiniGames.getInstance().getPlayerVisibilityManager();
visibilityManager.toggleHidePlayers(playerRegistry, player);
if (MiniGames.getInstance().getPlayerVisibilityManager().isHidingPlayers(player)) {
- setItem(inventorySlot, getTogglePlayersItemEnabled());
+ setItem(inventorySlot, getTogglePlayersItemEnabled(player));
} else {
setItem(inventorySlot, getTogglePlayersItemDisabled());
}
diff --git a/src/main/java/net/knarcraft/minigames/gui/DropperGUI.java b/src/main/java/net/knarcraft/minigames/gui/DropperGUI.java
index 68422ff..9cf36e5 100644
--- a/src/main/java/net/knarcraft/minigames/gui/DropperGUI.java
+++ b/src/main/java/net/knarcraft/minigames/gui/DropperGUI.java
@@ -16,12 +16,12 @@ public class DropperGUI extends ArenaGUI {
public DropperGUI(Player player) {
super(9, "Dropper");
if (MiniGames.getInstance().getPlayerVisibilityManager().isHidingPlayers(player)) {
- setItem(0, getTogglePlayersItemEnabled());
+ setItem(0, getTogglePlayersItemEnabled(player));
} else {
setItem(0, getTogglePlayersItemDisabled());
}
setItem(2, getLeaveItem());
- setItem(4, getRestartItem());
+ setItem(4, getRestartItemJava());
setAnyClickAction(0, getTogglePlayersAction(MiniGames.getInstance().getDropperArenaPlayerRegistry(), 0));
setAnyClickAction(2, getLeaveAction());
diff --git a/src/main/java/net/knarcraft/minigames/gui/DropperGUIBedrock.java b/src/main/java/net/knarcraft/minigames/gui/DropperGUIBedrock.java
index 68ffbf6..fbf497a 100644
--- a/src/main/java/net/knarcraft/minigames/gui/DropperGUIBedrock.java
+++ b/src/main/java/net/knarcraft/minigames/gui/DropperGUIBedrock.java
@@ -16,16 +16,16 @@ public class DropperGUIBedrock extends ArenaGUI {
public DropperGUIBedrock(Player player) {
super(27, "Dropper");
if (MiniGames.getInstance().getPlayerVisibilityManager().isHidingPlayers(player)) {
- setItem(9, getTogglePlayersItemEnabledBedrock());
+ setItem(10, getTogglePlayersItemEnabledBedrock());
} else {
- setItem(9, getTogglePlayersItemDisabled());
+ setItem(10, getTogglePlayersItemDisabled());
}
- setItem(11, getLeaveItem());
- setItem(13, getRestartItemBedrock());
+ setItem(12, getLeaveItem());
+ setItem(14, getRestartItemBedrock());
- setAnyClickAction(9, getTogglePlayersAction(MiniGames.getInstance().getDropperArenaPlayerRegistry(), 9));
- setAnyClickAction(11, getLeaveAction());
- setAnyClickAction(13, getRestartAction());
+ setAnyClickAction(10, getTogglePlayersAction(MiniGames.getInstance().getDropperArenaPlayerRegistry(), 10));
+ setAnyClickAction(12, getLeaveAction());
+ setAnyClickAction(14, getRestartAction());
}
}
diff --git a/src/main/java/net/knarcraft/minigames/gui/MiniGamesGUI.java b/src/main/java/net/knarcraft/minigames/gui/MiniGamesGUI.java
index c12ef6c..f380e2b 100644
--- a/src/main/java/net/knarcraft/minigames/gui/MiniGamesGUI.java
+++ b/src/main/java/net/knarcraft/minigames/gui/MiniGamesGUI.java
@@ -16,7 +16,7 @@ public class MiniGamesGUI extends ArenaGUI {
public MiniGamesGUI(Player player) {
super(9, "MiniGames");
if (MiniGames.getInstance().getPlayerVisibilityManager().isHidingPlayers(player)) {
- setItem(0, getTogglePlayersItemEnabled());
+ setItem(0, getTogglePlayersItemEnabled(player));
} else {
setItem(0, getTogglePlayersItemDisabled());
}
diff --git a/src/main/java/net/knarcraft/minigames/gui/ParkourGUI.java b/src/main/java/net/knarcraft/minigames/gui/ParkourGUI.java
index 6b1d8dc..a08147f 100644
--- a/src/main/java/net/knarcraft/minigames/gui/ParkourGUI.java
+++ b/src/main/java/net/knarcraft/minigames/gui/ParkourGUI.java
@@ -16,18 +16,18 @@ public class ParkourGUI extends ArenaGUI {
public ParkourGUI(Player player) {
super(9, "Parkour");
if (MiniGames.getInstance().getPlayerVisibilityManager().isHidingPlayers(player)) {
- setItem(0, getTogglePlayersItemEnabled());
+ setItem(1, getTogglePlayersItemEnabled(player));
} else {
- setItem(0, getTogglePlayersItemDisabled());
+ setItem(1, getTogglePlayersItemDisabled());
}
- setItem(2, getGiveUpItem());
- setItem(4, getLeaveItem());
- setItem(6, getRestartItem());
+ setItem(3, getGiveUpItem());
+ setItem(5, getLeaveItem());
+ setItem(7, getRestartItemJava());
- setAnyClickAction(0, getTogglePlayersAction(MiniGames.getInstance().getParkourArenaPlayerRegistry(), 0));
- setAnyClickAction(2, getGiveUpAction());
- setAnyClickAction(4, getLeaveAction());
- setAnyClickAction(6, getRestartAction());
+ setAnyClickAction(1, getTogglePlayersAction(MiniGames.getInstance().getParkourArenaPlayerRegistry(), 1));
+ setAnyClickAction(3, getGiveUpAction());
+ setAnyClickAction(5, getLeaveAction());
+ setAnyClickAction(7, getRestartAction());
}
}
diff --git a/src/main/java/net/knarcraft/minigames/gui/ParkourGUIBedrock.java b/src/main/java/net/knarcraft/minigames/gui/ParkourGUIBedrock.java
index b23de48..2a27c64 100644
--- a/src/main/java/net/knarcraft/minigames/gui/ParkourGUIBedrock.java
+++ b/src/main/java/net/knarcraft/minigames/gui/ParkourGUIBedrock.java
@@ -16,18 +16,18 @@ public class ParkourGUIBedrock extends ArenaGUI {
public ParkourGUIBedrock(Player player) {
super(27, "Parkour");
if (MiniGames.getInstance().getPlayerVisibilityManager().isHidingPlayers(player)) {
- setItem(9, getTogglePlayersItemEnabledBedrock());
+ setItem(10, getTogglePlayersItemEnabled(player));
} else {
- setItem(9, getTogglePlayersItemDisabled());
+ setItem(10, getTogglePlayersItemDisabled());
}
- setItem(11, getGiveUpItem());
- setItem(13, getLeaveItem());
- setItem(15, getRestartItemBedrock());
+ setItem(12, getGiveUpItem());
+ setItem(14, getLeaveItem());
+ setItem(16, getRestartItemBedrock());
- setAnyClickAction(9, getTogglePlayersAction(MiniGames.getInstance().getParkourArenaPlayerRegistry(), 9));
- setAnyClickAction(11, getGiveUpAction());
- setAnyClickAction(13, getLeaveAction());
- setAnyClickAction(15, getRestartAction());
+ setAnyClickAction(10, getTogglePlayersAction(MiniGames.getInstance().getParkourArenaPlayerRegistry(), 10));
+ setAnyClickAction(12, getGiveUpAction());
+ setAnyClickAction(14, getLeaveAction());
+ setAnyClickAction(16, getRestartAction());
}
}
diff --git a/src/main/java/net/knarcraft/minigames/util/GUIHelper.java b/src/main/java/net/knarcraft/minigames/util/GUIHelper.java
index fa68e73..69e428a 100644
--- a/src/main/java/net/knarcraft/minigames/util/GUIHelper.java
+++ b/src/main/java/net/knarcraft/minigames/util/GUIHelper.java
@@ -2,6 +2,7 @@ package net.knarcraft.minigames.util;
import net.knarcraft.knargui.item.GUIItemFactory;
import net.knarcraft.knargui.item.PlayerHeadGUIItemFactory;
+import net.knarcraft.knargui.item.SimpleGUIItemFactory;
import net.knarcraft.minigames.MiniGames;
import net.knarcraft.minigames.arena.ArenaSession;
import net.knarcraft.minigames.gui.MiniGamesGUI;
@@ -64,7 +65,7 @@ public final class GUIHelper {
* @return The item used for opening the GUI
*/
public static ItemStack getGUIOpenItemBedrock() {
- GUIItemFactory factory = new GUIItemFactory(Material.BEACON);
+ GUIItemFactory factory = new SimpleGUIItemFactory(Material.BEACON);
factory.setName(ChatColor.AQUA + "MiniGames Menu");
ItemStack item = factory.build();
ItemMeta meta = item.getItemMeta();