Dieser Commit ist enthalten in:
Ursprung
de50588985
Commit
2c441bbcfd
@ -3,16 +3,16 @@ package de.steamwar.lobby.games;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.lobby.LobbySystem;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class GamesCommand extends SWCommand {
|
||||
|
||||
private final HashMap<Player, List<Player>> CHALLENGES = new HashMap<>();
|
||||
private final Map<Player, List<Player>> CHALLENGES = new HashMap<>();
|
||||
|
||||
public GamesCommand() {
|
||||
super("games");
|
||||
@ -27,7 +27,8 @@ public class GamesCommand extends SWCommand {
|
||||
|
||||
if(CHALLENGES.containsKey(player) && CHALLENGES.get(player).contains(target)) {
|
||||
new TicTacToe(player, target).updateBoard();
|
||||
CHALLENGES.get(player).remove(target);
|
||||
CHALLENGES.remove(player);
|
||||
CHALLENGES.remove(target);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,8 @@ public class TicTacToe implements Listener {
|
||||
|
||||
private int turns = 0;
|
||||
|
||||
private boolean running = true;
|
||||
|
||||
public TicTacToe(Player player1, Player player2) {
|
||||
this.player1 = player1;
|
||||
this.player2 = player2;
|
||||
@ -65,6 +67,7 @@ public class TicTacToe implements Listener {
|
||||
}
|
||||
|
||||
private void win(Player player, int[] winningCombination) {
|
||||
running = false;
|
||||
SWInventory inventory = createCurrentBoard(player1, LobbySystem.getMessage().parse("GAMES_WON", player1, player.getName()));
|
||||
SWInventory inventory2 = createCurrentBoard(player2, LobbySystem.getMessage().parse("GAMES_WON", player2, player.getName()));
|
||||
for (int j : winningCombination) {
|
||||
@ -77,6 +80,7 @@ public class TicTacToe implements Listener {
|
||||
}
|
||||
|
||||
private void draw() {
|
||||
running = false;
|
||||
SWInventory inventory = createCurrentBoard(player1, LobbySystem.getMessage().parse("GAMES_DRAW", player1));
|
||||
SWInventory inventory2 = createCurrentBoard(player2, LobbySystem.getMessage().parse("GAMES_DRAW", player2));
|
||||
remake(inventory, inventory2);
|
||||
@ -92,6 +96,7 @@ public class TicTacToe implements Listener {
|
||||
}
|
||||
|
||||
private void end() {
|
||||
running = false;
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
@ -99,7 +104,7 @@ public class TicTacToe implements Listener {
|
||||
SWInventory inventory = createCurrentBoard(player, LobbySystem.getMessage().parse("GAMES_TURN", player, turn.getName()));
|
||||
inventory.addCloseRunnable(() -> {
|
||||
Bukkit.getScheduler().runTaskLater(LobbySystem.getPlugin(), () -> {
|
||||
if(player.getOpenInventory().getTopInventory().getType() != InventoryType.DROPPER) {
|
||||
if(player.getOpenInventory().getTopInventory().getType() != InventoryType.DROPPER && running) {
|
||||
player1.closeInventory();
|
||||
player2.closeInventory();
|
||||
LobbySystem.getMessage().send("GAMES_LEFT", player1, player.getName());
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren