Inviting and removing via GUI
Dieser Commit ist enthalten in:
Ursprung
5b5e941189
Commit
990bddf300
@ -13,12 +13,14 @@ import me.yaruma.fightsystem.fight.FightTeam;
|
|||||||
import me.yaruma.fightsystem.kit.Kit;
|
import me.yaruma.fightsystem.kit.Kit;
|
||||||
import me.yaruma.fightsystem.kit.KitManager;
|
import me.yaruma.fightsystem.kit.KitManager;
|
||||||
import me.yaruma.fightsystem.utils.Config;
|
import me.yaruma.fightsystem.utils.Config;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class GUI {
|
public class GUI {
|
||||||
|
|
||||||
@ -44,6 +46,29 @@ public class GUI {
|
|||||||
inv.open();
|
inv.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void chooseInvitation(Player p){
|
||||||
|
List<Pair<SWItem, UUID>> players = SWListInv.createPlayerList(p);
|
||||||
|
players.removeIf(swItemUUIDPair -> Fight.getFightPlayer(Bukkit.getPlayer(swItemUUIDPair.getValue())) != null);
|
||||||
|
SWListInv<UUID> inv = new SWListInv<>(p, "Spieler einladen", (ClickType click, UUID player) -> {
|
||||||
|
p.performCommand("invite " + WarkingUser.get(player).getUserName());
|
||||||
|
p.closeInventory();
|
||||||
|
}, players);
|
||||||
|
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||||
|
inv.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void chooseRemove(Player p){
|
||||||
|
List<Pair<SWItem, UUID>> players = SWListInv.createPlayerList(p);
|
||||||
|
FightTeam team = Fight.getPlayerTeam(p);
|
||||||
|
players.removeIf(swItemUUIDPair -> !team.equals(Fight.getPlayerTeam(Bukkit.getPlayer(swItemUUIDPair.getValue()))));
|
||||||
|
SWListInv<UUID> inv = new SWListInv<>(p, "Spieler rauswerfen", (ClickType click, UUID player) -> {
|
||||||
|
p.performCommand("ak remove " + WarkingUser.get(player).getUserName());
|
||||||
|
p.closeInventory();
|
||||||
|
}, players);
|
||||||
|
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||||
|
inv.open();
|
||||||
|
}
|
||||||
|
|
||||||
public static void kitSelection(Player p){
|
public static void kitSelection(Player p){
|
||||||
FightPlayer fightPlayer = Fight.getFightPlayer(p);
|
FightPlayer fightPlayer = Fight.getFightPlayer(p);
|
||||||
List<Pair<SWItem, Kit>> iconList = new ArrayList<>();
|
List<Pair<SWItem, Kit>> iconList = new ArrayList<>();
|
||||||
|
@ -142,6 +142,8 @@ public class FightTeam {
|
|||||||
this.leader = leader;
|
this.leader = leader;
|
||||||
leader.setKit(KitManager.getKitByName(Config.LeaderDefault));
|
leader.setKit(KitManager.getKitByName(Config.LeaderDefault));
|
||||||
Inventory inventory = leader.getPlayer().getInventory();
|
Inventory inventory = leader.getPlayer().getInventory();
|
||||||
|
inventory.setItem(0, new ItemBuilder(Material.PAPER).removeAllAtributs().setDisplayName("§eSpieler einladen").build());
|
||||||
|
inventory.setItem(2, new ItemBuilder(Material.FIREWORK_CHARGE).removeAllAtributs().setDisplayName("§cSpieler rauswerfen").build());
|
||||||
inventory.setItem(3, new ItemBuilder(Material.INK_SACK, (short) 10).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
|
inventory.setItem(3, new ItemBuilder(Material.INK_SACK, (short) 10).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
|
||||||
inventory.setItem(5, new ItemBuilder(Material.INK_SACK, (short) 1).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§4Abbrechen").build());
|
inventory.setItem(5, new ItemBuilder(Material.INK_SACK, (short) 1).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§4Abbrechen").build());
|
||||||
inventory.setItem(7, new ItemBuilder(Material.CAULDRON_ITEM).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§e" + Config.GameName + " wählen").build());
|
inventory.setItem(7, new ItemBuilder(Material.CAULDRON_ITEM).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§e" + Config.GameName + " wählen").build());
|
||||||
|
@ -15,12 +15,10 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
|
|
||||||
public class PlayerInteractListener implements Listener {
|
public class PlayerInteractListener implements Listener {
|
||||||
|
|
||||||
private final FightSystem instance = FightSystem.getPlugin();
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerInteract(PlayerInteractEvent event) {
|
public void handlePlayerInteract(PlayerInteractEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if(instance.getFightState() == FightState.SETUP &&
|
if(FightSystem.getFightState() == FightState.SETUP &&
|
||||||
event.getItem() != null &&
|
event.getItem() != null &&
|
||||||
Fight.getPlayerTeam(player) != null) {
|
Fight.getPlayerTeam(player) != null) {
|
||||||
ItemMeta itemMeta = event.getItem().getItemMeta();
|
ItemMeta itemMeta = event.getItem().getItemMeta();
|
||||||
@ -37,6 +35,12 @@ public class PlayerInteractListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (displayName) {
|
switch (displayName) {
|
||||||
|
case "§cSpieler rauswerfen":
|
||||||
|
GUI.chooseRemove(player);
|
||||||
|
break;
|
||||||
|
case "§eSpieler einladen":
|
||||||
|
GUI.chooseInvitation(player);
|
||||||
|
break;
|
||||||
case "§cNicht bereit":
|
case "§cNicht bereit":
|
||||||
fightTeam.setReady(true);
|
fightTeam.setReady(true);
|
||||||
break;
|
break;
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren