mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-24 19:45:43 +01:00
Fixed GameSign updating when group is deleted
This commit is contained in:
parent
eed8427eb1
commit
5e2c9ff601
@ -20,6 +20,7 @@ import io.github.dre2n.commons.util.playerutil.PlayerUtil;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
||||
import io.github.dre2n.dungeonsxl.global.GameSign;
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||
import io.github.dre2n.dungeonsxl.sign.MobSign;
|
||||
@ -91,6 +92,10 @@ public class Game {
|
||||
*/
|
||||
public void removeDGroup(DGroup dGroup) {
|
||||
dGroups.remove(dGroup);
|
||||
|
||||
if (dGroups.isEmpty()) {
|
||||
delete();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -252,6 +257,19 @@ public class Game {
|
||||
}
|
||||
|
||||
/* Actions */
|
||||
/**
|
||||
* Remove the Game from the List
|
||||
*/
|
||||
public void delete() {
|
||||
GameSign gameSign = GameSign.getByGame(this);
|
||||
|
||||
plugin.getGames().remove(this);
|
||||
|
||||
if (gameSign != null) {
|
||||
gameSign.update();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mobCountIncreaseRate
|
||||
* the new mob count will be increased by this rate
|
||||
|
@ -195,7 +195,7 @@ public class GameSign extends GlobalProtection {
|
||||
}
|
||||
|
||||
// Set Signs
|
||||
if (game != null) {
|
||||
if (game != null && game.getDGroups().size() > 0) {
|
||||
if (game.getDGroups().get(0).isPlaying()) {
|
||||
sign.setLine(0, IS_PLAYING);
|
||||
|
||||
@ -346,6 +346,24 @@ public class GameSign extends GlobalProtection {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param game
|
||||
* the game to check
|
||||
*/
|
||||
public static GameSign getByGame(Game game) {
|
||||
for (GlobalProtection protection : plugin.getGlobalProtections().getProtections(GameSign.class)) {
|
||||
GameSign gameSign = (GameSign) protection;
|
||||
|
||||
for (Game signGame : gameSign.games) {
|
||||
if (signGame == game) {
|
||||
return gameSign;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/* SUBJECT TO CHANGE*/
|
||||
@Deprecated
|
||||
public static GameSign tryToCreate(Block startSign, String mapName, int maxGames, int maxGroupsPerGame, boolean multiFloor) {
|
||||
@ -523,29 +541,6 @@ public class GameSign extends GlobalProtection {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void updatePerGame(Game gameSearch) {
|
||||
for (GlobalProtection protection : protections.getProtections(GameSign.class)) {
|
||||
GameSign gameSign = (GameSign) protection;
|
||||
|
||||
int i = 0;
|
||||
for (Game game : gameSign.games) {
|
||||
if (game == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (game == gameSearch) {
|
||||
if (gameSearch.isEmpty()) {
|
||||
gameSign.games[i] = null;
|
||||
}
|
||||
gameSign.update();
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static int[] getDirection(byte data) {
|
||||
int[] direction = new int[2];
|
||||
|
@ -29,7 +29,6 @@ import io.github.dre2n.dungeonsxl.event.reward.RewardAdditionEvent;
|
||||
import io.github.dre2n.dungeonsxl.game.Game;
|
||||
import io.github.dre2n.dungeonsxl.game.GameType;
|
||||
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
||||
import io.github.dre2n.dungeonsxl.global.GameSign;
|
||||
import io.github.dre2n.dungeonsxl.global.GroupSign;
|
||||
import io.github.dre2n.dungeonsxl.requirement.Requirement;
|
||||
import io.github.dre2n.dungeonsxl.reward.Reward;
|
||||
@ -431,17 +430,18 @@ public class DGroup {
|
||||
* Remove the group from the List
|
||||
*/
|
||||
public void delete() {
|
||||
Game game = Game.getByDGroup(this);
|
||||
|
||||
plugin.getDGroups().remove(this);
|
||||
|
||||
if (game != null) {
|
||||
game.removeDGroup(this);
|
||||
}
|
||||
|
||||
if (timeIsRunningTask != null) {
|
||||
timeIsRunningTask.cancel();
|
||||
}
|
||||
|
||||
if (Game.getByDGroup(this) != null) {
|
||||
Game.getByDGroup(this).removeDGroup(this);
|
||||
}
|
||||
|
||||
GameSign.updatePerGame(Game.getByDGroup(this));
|
||||
GroupSign.updatePerGroup(this);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user