use of com.andrei1058.bedwars.money.internal.MoneyPerMinuteTask in project BedWars1058 by andrei1058.
the class Arena method changeStatus.
/**
* Change game status starting tasks.
*/
public void changeStatus(GameState status) {
this.status = status;
Bukkit.getPluginManager().callEvent(new GameStateChangeEvent(this, status, status));
refreshSigns();
if (status == GameState.playing) {
for (Player p : players) {
Arena.afkCheck.remove(p.getUniqueId());
BedWars.getAPI().getAFKUtil().setPlayerAFK(p, false);
}
for (Player p : spectators) {
Arena.afkCheck.remove(p.getUniqueId());
BedWars.getAPI().getAFKUtil().setPlayerAFK(p, false);
}
}
// Stop active tasks to prevent issues
BukkitScheduler bs = Bukkit.getScheduler();
if (startingTask != null) {
if (bs.isCurrentlyRunning(startingTask.getTask()) || bs.isQueued(startingTask.getTask()))
startingTask.cancel();
}
startingTask = null;
if (playingTask != null) {
if (bs.isCurrentlyRunning(playingTask.getTask()) || bs.isQueued(playingTask.getTask()))
playingTask.cancel();
}
playingTask = null;
if (restartingTask != null) {
if (bs.isCurrentlyRunning(restartingTask.getTask()) || bs.isQueued(restartingTask.getTask()))
restartingTask.cancel();
}
restartingTask = null;
players.forEach(c -> BedWarsScoreboard.giveScoreboard(c, this, false));
spectators.forEach(c -> BedWarsScoreboard.giveScoreboard(c, this, false));
if (status == GameState.starting) {
startingTask = new GameStartingTask(this);
} else if (status == GameState.playing) {
if (BedWars.getLevelSupport() instanceof InternalLevel) {
perMinuteTask = new PerMinuteTask(this);
}
if (BedWars.getEconomy() instanceof WithEconomy) {
moneyperMinuteTask = new MoneyPerMinuteTask(this);
}
playingTask = new GamePlayingTask(this);
} else if (status == GameState.restarting) {
restartingTask = new GameRestartingTask(this);
if (perMinuteTask != null) {
perMinuteTask.cancel();
}
if (moneyperMinuteTask != null) {
moneyperMinuteTask.cancel();
}
}
}
use of com.andrei1058.bedwars.money.internal.MoneyPerMinuteTask in project BedWars1058 by andrei1058.
the class Arena method destroyData.
public void destroyData() {
destroyReJoins();
if (worldName != null)
arenaByIdentifier.remove(worldName);
arenas.remove(this);
for (ReJoinTask rjt : ReJoinTask.getReJoinTasks()) {
if (rjt.getArena() == this) {
rjt.destroy();
}
}
for (Despawnable despawnable : new ArrayList<>(BedWars.nms.getDespawnablesList().values())) {
if (despawnable.getTeam().getArena() == this) {
despawnable.destroy();
}
}
arenaByName.remove(arenaName);
arenaByPlayer.entrySet().removeIf(entry -> entry.getValue() == this);
players = null;
spectators = null;
signs = null;
yml = null;
cm = null;
world = null;
for (IGenerator og : oreGenerators) {
og.destroyData();
}
isOnABase.entrySet().removeIf(entry -> entry.getValue().getArena().equals(this));
for (ITeam bwt : teams) {
bwt.destroyData();
}
playerLocation.entrySet().removeIf(e -> Objects.requireNonNull(e.getValue().getWorld()).getName().equalsIgnoreCase(worldName));
teams = null;
placed = null;
nextEvents = null;
regionsList = null;
respawnSessions = null;
showTime = null;
playerKills = null;
playerBedsDestroyed = null;
playerFinalKills = null;
playerDeaths = null;
playerFinalKillDeaths = null;
startingTask = null;
playingTask = null;
restartingTask = null;
oreGenerators = null;
perMinuteTask = null;
moneyperMinuteTask = null;
leaving.clear();
fireballCooldowns.clear();
}
Aggregations