mirror of
https://github.com/SunNetservers/MiniGames.git
synced 2025-07-21 07:24:43 +02:00
Makes some GUI changes
Makes the current state of the player toggle visible. Makes it possible to toggle player visibility outside arenas.
This commit is contained in:
@ -3,9 +3,11 @@ package net.knarcraft.minigames.gui;
|
||||
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.minigames.MiniGames;
|
||||
import net.knarcraft.minigames.arena.ArenaPlayerRegistry;
|
||||
import net.knarcraft.minigames.arena.ArenaSession;
|
||||
import net.knarcraft.minigames.arena.PlayerVisibilityManager;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@ -38,16 +40,33 @@ public abstract class ArenaGUI extends AbstractGUI {
|
||||
*
|
||||
* @return <p>A player toggle item</p>
|
||||
*/
|
||||
protected ItemStack getTogglePlayersItem() {
|
||||
protected ItemStack getTogglePlayersItemDisabled() {
|
||||
GUIItemFactory togglePlayersItemFactory = new GUIItemFactory(Material.PLAYER_HEAD);
|
||||
List<String> loreLines = getLoreLines();
|
||||
loreLines.add(ChatColor.GRAY + "Use this item to toggle the visibility");
|
||||
loreLines.add(ChatColor.GRAY + "Use this item to disable the visibility");
|
||||
loreLines.add(ChatColor.GRAY + "of other players");
|
||||
togglePlayersItemFactory.setName(ChatColor.BLUE + "Toggle Players");
|
||||
togglePlayersItemFactory.setName(ChatColor.BLUE + "Disable Players");
|
||||
togglePlayersItemFactory.setLore(loreLines);
|
||||
return togglePlayersItemFactory.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an item describing player visibility toggling
|
||||
*
|
||||
* @return <p>A player toggle item</p>
|
||||
*/
|
||||
protected ItemStack getTogglePlayersItemEnabled() {
|
||||
PlayerHeadGUIItemFactory togglePlayersItemFactory = new PlayerHeadGUIItemFactory();
|
||||
togglePlayersItemFactory.useSkin("c10591e6909e6a281b371836e462d67a2c78fa0952e910f32b41a26c48c1757c");
|
||||
List<String> 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();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets an item describing a leave arena action
|
||||
*
|
||||
@ -104,8 +123,15 @@ public abstract class ArenaGUI extends AbstractGUI {
|
||||
* @return <p>The action for triggering player visibility</p>
|
||||
*/
|
||||
protected GUIAction getTogglePlayersAction() {
|
||||
return (player) -> MiniGames.getInstance().getPlayerVisibilityManager().toggleHidePlayers(playerRegistry,
|
||||
player);
|
||||
return (player) -> {
|
||||
PlayerVisibilityManager visibilityManager = MiniGames.getInstance().getPlayerVisibilityManager();
|
||||
visibilityManager.toggleHidePlayers(playerRegistry, player);
|
||||
if (MiniGames.getInstance().getPlayerVisibilityManager().isHidingPlayers(player)) {
|
||||
setItem(0, getTogglePlayersItemEnabled());
|
||||
} else {
|
||||
setItem(0, getTogglePlayersItemDisabled());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.knarcraft.minigames.gui;
|
||||
|
||||
import net.knarcraft.minigames.MiniGames;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* A GUI used in the dropper arena
|
||||
@ -9,10 +10,16 @@ public class DropperGUI extends ArenaGUI {
|
||||
|
||||
/**
|
||||
* Instantiates a new dropper gui
|
||||
*
|
||||
* @param player <p>The player the GUI is created for</p>
|
||||
*/
|
||||
public DropperGUI() {
|
||||
public DropperGUI(Player player) {
|
||||
super(9, "Dropper", MiniGames.getInstance().getDropperArenaPlayerRegistry());
|
||||
setItem(0, getTogglePlayersItem());
|
||||
if (MiniGames.getInstance().getPlayerVisibilityManager().isHidingPlayers(player)) {
|
||||
setItem(0, getTogglePlayersItemEnabled());
|
||||
} else {
|
||||
setItem(0, getTogglePlayersItemDisabled());
|
||||
}
|
||||
setItem(2, getLeaveItem());
|
||||
|
||||
setAnyClickAction(0, getTogglePlayersAction());
|
||||
|
27
src/main/java/net/knarcraft/minigames/gui/MiniGamesGUI.java
Normal file
27
src/main/java/net/knarcraft/minigames/gui/MiniGamesGUI.java
Normal file
@ -0,0 +1,27 @@
|
||||
package net.knarcraft.minigames.gui;
|
||||
|
||||
import net.knarcraft.minigames.MiniGames;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* A GUI used outside arenas
|
||||
*/
|
||||
public class MiniGamesGUI extends ArenaGUI {
|
||||
|
||||
/**
|
||||
* Instantiates a new mini games gui
|
||||
*
|
||||
* @param player <p>The player the GUI is created for</p>
|
||||
*/
|
||||
public MiniGamesGUI(Player player) {
|
||||
super(9, "MiniGames", null);
|
||||
if (MiniGames.getInstance().getPlayerVisibilityManager().isHidingPlayers(player)) {
|
||||
setItem(0, getTogglePlayersItemEnabled());
|
||||
} else {
|
||||
setItem(0, getTogglePlayersItemDisabled());
|
||||
}
|
||||
|
||||
setAnyClickAction(0, getTogglePlayersAction());
|
||||
}
|
||||
|
||||
}
|
@ -7,6 +7,7 @@ import net.knarcraft.minigames.arena.ArenaSession;
|
||||
import net.knarcraft.minigames.arena.parkour.ParkourArenaSession;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
@ -16,9 +17,18 @@ import java.util.List;
|
||||
*/
|
||||
public class ParkourGUI extends ArenaGUI {
|
||||
|
||||
public ParkourGUI() {
|
||||
/**
|
||||
* Instantiates a new parkour gui
|
||||
*
|
||||
* @param player <p>The player the GUI is created for</p>
|
||||
*/
|
||||
public ParkourGUI(Player player) {
|
||||
super(9, "Parkour", MiniGames.getInstance().getParkourArenaPlayerRegistry());
|
||||
setItem(0, getTogglePlayersItem());
|
||||
if (MiniGames.getInstance().getPlayerVisibilityManager().isHidingPlayers(player)) {
|
||||
setItem(0, getTogglePlayersItemEnabled());
|
||||
} else {
|
||||
setItem(0, getTogglePlayersItemDisabled());
|
||||
}
|
||||
setItem(2, getGiveUpItem());
|
||||
setItem(4, getLeaveItem());
|
||||
|
||||
|
Reference in New Issue
Block a user