1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-03-13 01:09:53 -09:00

Fixed possible NPE, improved server timeout

This commit is contained in:
Oleg Agafonov 2023-04-14 19:07:08 +04:00
parent bc5c381fef
commit 517ee16a60
3 changed files with 9 additions and 4 deletions
Mage.Server/src/main/java/mage/server
Mage.Sets/src/mage/cards/s

View file

@ -178,6 +178,7 @@ public class MageServerImpl implements MageServer {
throw new MageException("Wrong client version " + version + ", expecting version " + Main.getVersion());
}
if (!adminPassword.equals(this.adminPassword)) {
Thread.sleep(3000);
throw new MageException("Wrong password");
}
return managerFactory.sessionManager().connectAdmin(sessionId);

View file

@ -203,6 +203,12 @@ public class Session {
}
returnMessage = connectUserHandling(userName, password);
if (returnMessage != null) {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
logger.fatal("waiting of error message had failed", e);
Thread.currentThread().interrupt();
}
sendErrorMessageToClient(returnMessage);
}
return returnMessage;

View file

@ -83,8 +83,6 @@ class ChooseNumberEffect extends OneShotEffect {
class SanctumPrelateReplacementEffect extends ContinuousRuleModifyingEffectImpl {
Integer choiceValue;
public SanctumPrelateReplacementEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
staticText = "Noncreature spells with mana value equal to the chosen number can't be cast";
@ -120,10 +118,10 @@ class SanctumPrelateReplacementEffect extends ContinuousRuleModifyingEffectImpl
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
choiceValue = (Integer) game.getState().getValue(source.getSourceId().toString());
Integer choiceValue = (Integer) game.getState().getValue(source.getSourceId().toString());
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell != null && !spell.isCreature(game)) {
if (spell != null && !spell.isCreature(game) && choiceValue != null) {
return spell.getManaValue() == choiceValue;
}
return false;