mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-19 07:56:26 +01:00
Dispose games properly upon room disposal
This commit is contained in:
parent
483e7cad69
commit
e2c56e6efe
@ -17,18 +17,15 @@ public class ReloadRoomCommand extends Command {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(GameClient gameClient, String[] params) throws Exception {
|
public boolean handle(GameClient gameClient, String[] params) throws Exception {
|
||||||
Emulator.getThreading().run(new Runnable() {
|
Emulator.getThreading().run(() -> {
|
||||||
@Override
|
Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
|
||||||
public void run() {
|
if (room != null) {
|
||||||
Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
|
Collection<Habbo> habbos = new ArrayList<>(room.getHabbos());
|
||||||
if (room != null) {
|
Emulator.getGameEnvironment().getRoomManager().unloadRoom(room);
|
||||||
Collection<Habbo> habbos = new ArrayList<>(room.getHabbos());
|
room = Emulator.getGameEnvironment().getRoomManager().loadRoom(room.getId());
|
||||||
Emulator.getGameEnvironment().getRoomManager().unloadRoom(room);
|
ServerMessage message = new ForwardToRoomComposer(room.getId()).compose();
|
||||||
room = Emulator.getGameEnvironment().getRoomManager().loadRoom(room.getId());
|
for (Habbo habbo : habbos) {
|
||||||
ServerMessage message = new ForwardToRoomComposer(room.getId()).compose();
|
habbo.getClient().sendResponse(message);
|
||||||
for (Habbo habbo : habbos) {
|
|
||||||
habbo.getClient().sendResponse(message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 100);
|
}, 100);
|
||||||
|
@ -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() {
|
private void saveScores() {
|
||||||
if (this.room == null)
|
if (this.room == null)
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package com.eu.habbo.habbohotel.games;
|
package com.eu.habbo.habbohotel.games;
|
||||||
|
|
||||||
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
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;
|
import gnu.trove.set.hash.THashSet;
|
||||||
|
|
||||||
public class GameTeam {
|
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() {
|
public THashSet<GamePlayer> getMembers() {
|
||||||
return this.members;
|
return this.members;
|
||||||
|
@ -853,7 +853,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Game game : this.games) {
|
for (Game game : this.games) {
|
||||||
game.stop();
|
game.dispose();
|
||||||
}
|
}
|
||||||
this.games.clear();
|
this.games.clear();
|
||||||
|
|
||||||
@ -2130,6 +2130,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
|
|
||||||
public boolean deleteGame(Game game) {
|
public boolean deleteGame(Game game) {
|
||||||
game.stop();
|
game.stop();
|
||||||
|
game.dispose();
|
||||||
synchronized (this.games) {
|
synchronized (this.games) {
|
||||||
return this.games.remove(game);
|
return this.games.remove(game);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user