mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 19:11:59 -08:00
Fixed NPE error on "/FIX" chat command;
This commit is contained in:
parent
8cb87269d8
commit
1ccd1c2f2d
1 changed files with 33 additions and 26 deletions
|
|
@ -1,13 +1,5 @@
|
||||||
package mage.server.game;
|
package mage.server.game;
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.concurrent.*;
|
|
||||||
import java.util.concurrent.locks.Lock;
|
|
||||||
import java.util.concurrent.locks.ReadWriteLock;
|
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
|
||||||
import java.util.zip.GZIPOutputStream;
|
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.PassAbility;
|
import mage.abilities.common.PassAbility;
|
||||||
|
|
@ -21,11 +13,7 @@ import mage.choices.Choice;
|
||||||
import mage.constants.ManaType;
|
import mage.constants.ManaType;
|
||||||
import mage.constants.PlayerAction;
|
import mage.constants.PlayerAction;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.game.*;
|
||||||
import mage.game.GameException;
|
|
||||||
import mage.game.GameOptions;
|
|
||||||
import mage.game.GameState;
|
|
||||||
import mage.game.Table;
|
|
||||||
import mage.game.command.Plane;
|
import mage.game.command.Plane;
|
||||||
import mage.game.events.Listener;
|
import mage.game.events.Listener;
|
||||||
import mage.game.events.PlayerQueryEvent;
|
import mage.game.events.PlayerQueryEvent;
|
||||||
|
|
@ -47,6 +35,15 @@ import mage.view.ChatMessage.MessageColor;
|
||||||
import mage.view.ChatMessage.MessageType;
|
import mage.view.ChatMessage.MessageType;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.*;
|
||||||
|
import java.util.concurrent.locks.Lock;
|
||||||
|
import java.util.concurrent.locks.ReadWriteLock;
|
||||||
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -1172,7 +1169,13 @@ public class GameController implements GameCallback {
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getName(Player player) {
|
||||||
|
return player != null ? player.getName() : "-";
|
||||||
|
}
|
||||||
|
|
||||||
public String attemptToFixGame() {
|
public String attemptToFixGame() {
|
||||||
|
// try to fix disconnects
|
||||||
|
|
||||||
if (game == null) {
|
if (game == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
@ -1185,15 +1188,14 @@ public class GameController implements GameCallback {
|
||||||
sb.append(state);
|
sb.append(state);
|
||||||
boolean fixedAlready = false;
|
boolean fixedAlready = false;
|
||||||
|
|
||||||
sb.append("<br>Active player is: ");
|
Player activePlayer = game.getPlayer(state.getActivePlayerId());
|
||||||
sb.append(game.getPlayer(state.getActivePlayerId()).getName());
|
|
||||||
|
// fix active
|
||||||
|
sb.append("<br>Checking active player: " + getName(activePlayer));
|
||||||
|
if (activePlayer != null && activePlayer.hasLeft()) {
|
||||||
|
sb.append("<br>Found disconnected player! Concede...");
|
||||||
|
activePlayer.concede(game);
|
||||||
|
|
||||||
PassAbility pass = new PassAbility();
|
|
||||||
if (game.getPlayer(state.getActivePlayerId()).hasLeft()) {
|
|
||||||
Player p = game.getPlayer(state.getActivePlayerId());
|
|
||||||
if (p != null) {
|
|
||||||
p.concede(game);
|
|
||||||
}
|
|
||||||
Phase currentPhase = game.getPhase();
|
Phase currentPhase = game.getPhase();
|
||||||
if (currentPhase != null) {
|
if (currentPhase != null) {
|
||||||
currentPhase.getStep().skipStep(game, state.getActivePlayerId());
|
currentPhase.getStep().skipStep(game, state.getActivePlayerId());
|
||||||
|
|
@ -1205,9 +1207,11 @@ public class GameController implements GameCallback {
|
||||||
sb.append("<br>Active player has left");
|
sb.append("<br>Active player has left");
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append("<br>getChoosingPlayerId: ");
|
// fix lost choosing dialog
|
||||||
|
sb.append("<br>Checking choosing player: " + getName(game.getPlayer(state.getChoosingPlayerId())));
|
||||||
if (state.getChoosingPlayerId() != null) {
|
if (state.getChoosingPlayerId() != null) {
|
||||||
if (game.getPlayer(state.getChoosingPlayerId()).hasLeft()) {
|
if (game.getPlayer(state.getChoosingPlayerId()).hasLeft()) {
|
||||||
|
sb.append("<br>Found disconnected player! Concede...");
|
||||||
Player p = game.getPlayer(state.getChoosingPlayerId());
|
Player p = game.getPlayer(state.getChoosingPlayerId());
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
p.concede(game);
|
p.concede(game);
|
||||||
|
|
@ -1224,9 +1228,11 @@ public class GameController implements GameCallback {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append("<br><font color=orange>Player with Priority is: ");
|
// fix lost priority
|
||||||
|
sb.append("<br>Checking priority player: " + getName(game.getPlayer(state.getPriorityPlayerId())));
|
||||||
if (state.getPriorityPlayerId() != null) {
|
if (state.getPriorityPlayerId() != null) {
|
||||||
if (game.getPlayer(state.getPriorityPlayerId()).hasLeft()) {
|
if (game.getPlayer(state.getPriorityPlayerId()).hasLeft()) {
|
||||||
|
sb.append("<br>Found disconnected player! Concede...");
|
||||||
Player p = game.getPlayer(state.getPriorityPlayerId());
|
Player p = game.getPlayer(state.getPriorityPlayerId());
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
p.concede(game);
|
p.concede(game);
|
||||||
|
|
@ -1242,7 +1248,8 @@ public class GameController implements GameCallback {
|
||||||
sb.append("</font>");
|
sb.append("</font>");
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append("<br>Future Timeout:");
|
// fix timeout
|
||||||
|
sb.append("<br>Checking Future Timeout: ");
|
||||||
if (futureTimeout != null) {
|
if (futureTimeout != null) {
|
||||||
sb.append("Cancelled?=");
|
sb.append("Cancelled?=");
|
||||||
sb.append(futureTimeout.isCancelled());
|
sb.append(futureTimeout.isCancelled());
|
||||||
|
|
@ -1251,6 +1258,7 @@ public class GameController implements GameCallback {
|
||||||
sb.append(",,,GetDelay?=");
|
sb.append(",,,GetDelay?=");
|
||||||
sb.append((int) futureTimeout.getDelay(TimeUnit.SECONDS));
|
sb.append((int) futureTimeout.getDelay(TimeUnit.SECONDS));
|
||||||
if ((int) futureTimeout.getDelay(TimeUnit.SECONDS) < 25) {
|
if ((int) futureTimeout.getDelay(TimeUnit.SECONDS) < 25) {
|
||||||
|
PassAbility pass = new PassAbility();
|
||||||
game.endTurn(pass);
|
game.endTurn(pass);
|
||||||
sb.append("<br>Forcibly passing the turn!");
|
sb.append("<br>Forcibly passing the turn!");
|
||||||
}
|
}
|
||||||
|
|
@ -1260,5 +1268,4 @@ public class GameController implements GameCallback {
|
||||||
sb.append("</font>");
|
sb.append("</font>");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue