Ensure that Tic-Tac-Toe invites are cleared when the gadget is disabled
This commit is contained in:
parent
d2416d1122
commit
27e9af8659
@ -17,11 +17,9 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import mineplex.core.arcadeevents.CoreGameStartEvent;
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.jsonchat.ClickEvent;
|
||||
import mineplex.core.common.jsonchat.HoverEvent;
|
||||
@ -304,11 +302,16 @@ public class ItemOAndX extends ItemGadget
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerQuit(PlayerQuitEvent event)
|
||||
@Override
|
||||
public void disableCustom(Player player, boolean message)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
super.disableCustom(player, message);
|
||||
|
||||
remove(player);
|
||||
}
|
||||
|
||||
private void remove(Player player)
|
||||
{
|
||||
_gameBoards.removeIf(board ->
|
||||
{
|
||||
if (board.PlayerA.equals(player) || board.PlayerB.equals(player))
|
||||
@ -319,13 +322,8 @@ public class ItemOAndX extends ItemGadget
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void gameStart(CoreGameStartEvent event)
|
||||
{
|
||||
_gameBoards.forEach(board -> cleanupBoard(board, false));
|
||||
_gameBoards.clear();
|
||||
_invites.remove(player.getName());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
Loading…
Reference in New Issue
Block a user