mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-18 23:46:28 +01:00
Dispose games properly upon room disposal
This commit is contained in:
parent
483e7cad69
commit
e2c56e6efe
@ -17,9 +17,7 @@ public class ReloadRoomCommand extends Command {
|
||||
|
||||
@Override
|
||||
public boolean handle(GameClient gameClient, String[] params) throws Exception {
|
||||
Emulator.getThreading().run(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Emulator.getThreading().run(() -> {
|
||||
Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
|
||||
if (room != null) {
|
||||
Collection<Habbo> habbos = new ArrayList<>(room.getHabbos());
|
||||
@ -30,7 +28,6 @@ public class ReloadRoomCommand extends Command {
|
||||
habbo.getClient().sendResponse(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
|
||||
return true;
|
||||
|
@ -223,6 +223,14 @@ public abstract class Game implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
for (GameTeam team : this.teams.values()) {
|
||||
team.clearMembers();
|
||||
}
|
||||
this.teams.clear();
|
||||
|
||||
this.stop();
|
||||
}
|
||||
|
||||
private void saveScores() {
|
||||
if (this.room == null)
|
||||
|
@ -1,6 +1,9 @@
|
||||
package com.eu.habbo.habbohotel.games;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.plugin.Event;
|
||||
import com.eu.habbo.plugin.events.games.GameHabboLeaveEvent;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
public class GameTeam {
|
||||
@ -65,6 +68,16 @@ public class GameTeam {
|
||||
}
|
||||
}
|
||||
|
||||
public void clearMembers() {
|
||||
for (GamePlayer player : this.members) {
|
||||
player.getHabbo().getHabboInfo().getGamePlayer().reset();
|
||||
player.getHabbo().getHabboInfo().setCurrentGame(null);
|
||||
player.getHabbo().getHabboInfo().setGamePlayer(null);
|
||||
}
|
||||
|
||||
this.members.clear();
|
||||
}
|
||||
|
||||
|
||||
public THashSet<GamePlayer> getMembers() {
|
||||
return this.members;
|
||||
|
@ -853,7 +853,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
}
|
||||
|
||||
for (Game game : this.games) {
|
||||
game.stop();
|
||||
game.dispose();
|
||||
}
|
||||
this.games.clear();
|
||||
|
||||
@ -2130,6 +2130,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
|
||||
public boolean deleteGame(Game game) {
|
||||
game.stop();
|
||||
game.dispose();
|
||||
synchronized (this.games) {
|
||||
return this.games.remove(game);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user