SteamWar/FightSystem
Archiviert
13
1

Inviting and removing via GUI

Dieser Commit ist enthalten in:
Travis CI 2019-06-14 17:21:40 +02:00
Ursprung 5b5e941189
Commit 990bddf300
3 geänderte Dateien mit 34 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -13,12 +13,14 @@ import me.yaruma.fightsystem.fight.FightTeam;
import me.yaruma.fightsystem.kit.Kit;
import me.yaruma.fightsystem.kit.KitManager;
import me.yaruma.fightsystem.utils.Config;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class GUI {
@ -44,6 +46,29 @@ public class GUI {
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){
FightPlayer fightPlayer = Fight.getFightPlayer(p);
List<Pair<SWItem, Kit>> iconList = new ArrayList<>();

Datei anzeigen

@ -142,6 +142,8 @@ public class FightTeam {
this.leader = leader;
leader.setKit(KitManager.getKitByName(Config.LeaderDefault));
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(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());

Datei anzeigen

@ -15,12 +15,10 @@ import org.bukkit.inventory.meta.ItemMeta;
public class PlayerInteractListener implements Listener {
private final FightSystem instance = FightSystem.getPlugin();
@EventHandler
public void handlePlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
if(instance.getFightState() == FightState.SETUP &&
if(FightSystem.getFightState() == FightState.SETUP &&
event.getItem() != null &&
Fight.getPlayerTeam(player) != null) {
ItemMeta itemMeta = event.getItem().getItemMeta();
@ -37,6 +35,12 @@ public class PlayerInteractListener implements Listener {
}
switch (displayName) {
case "§cSpieler rauswerfen":
GUI.chooseRemove(player);
break;
case "§eSpieler einladen":
GUI.chooseInvitation(player);
break;
case "§cNicht bereit":
fightTeam.setReady(true);
break;