nus-yam/ex-repair huggingface dataset:
Program: 159016
Project: 159016
Buggy source:
@Override public boolean apply(Game game,Ability source){
  if (onCard) {
    Card card;
    if (affectedObjectsSet) {
      card=affectedObjectList.get(0).getCard(game);
    }
 else {
      card=game.getCard(source.getSourceId());
    }
    if (card != null) {
      card.addAbility(ability);
      discard();
      return true;
    }
  }
 else {
    Permanent permanent;
    if (affectedObjectsSet) {
      permanent=affectedObjectList.get(0).getPermanent(game);
    }
 else {
      permanent=game.getPermanent(source.getSourceId());
    }
    if (permanent != null) {
      permanent.addAbility(ability,source.getSourceId(),game);
      return true;
    }
  }
  if (duration.equals(Duration.Custom)) {
    this.discard();
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  if (onCard) {
    Card card;
    if (affectedObjectsSet) {
      card=affectedObjectList.get(0).getCard(game);
    }
 else {
      card=game.getCard(source.getSourceId());
    }
    if (card != null) {
      card.addAbility(ability);
      discard();
      return true;
    }
  }
 else {
    Permanent permanent;
    if (affectedObjectsSet) {
      permanent=affectedObjectList.get(0).getPermanent(game);
    }
 else {
      permanent=game.getPermanent(source.getSourceId());
    }
    if (permanent != null) {
      permanent.addAbility(ability,source.getSourceId(),game,false);
      return true;
    }
  }
  if (duration.equals(Duration.Custom)) {
    this.discard();
  }
  return true;
}
Program: 159017
Project: 159017
Buggy source:
public void addEffect(ContinuousEffect effect,UUID sourceId,Ability source){
  if (sourceId == null)   effects.addEffect(effect,source);
 else   effects.addEffect(effect,sourceId,source);
}

Fixed version (ground truth):
public void addEffect(ContinuousEffect effect,UUID sourceId,Ability source){
  if (sourceId == null) {
    effects.addEffect(effect,source);
  }
 else {
    effects.addEffect(effect,sourceId,source);
  }
}
Program: 159018
Project: 159018
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Spell spell=(Spell)this.getValue("String_Node_Str");
  if (spell != null) {
    CastSpellLastTurnWatcher watcher=(CastSpellLastTurnWatcher)game.getState().getWatchers().get("String_Node_Str");
    for (int i=0; i < watcher.getSpellOrder(spell) - 1; i++) {
      Spell copy=spell.copySpell();
      copy.setControllerId(source.getControllerId());
      copy.setCopiedSpell(true);
      game.getStack().push(copy);
      copy.chooseNewTargets(game,source.getControllerId());
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Spell spell=(Spell)this.getValue("String_Node_Str");
  if (spell != null) {
    CastSpellLastTurnWatcher watcher=(CastSpellLastTurnWatcher)game.getState().getWatchers().get("String_Node_Str");
    int stormCount=watcher.getSpellOrder(spell) - 1;
    if (stormCount > 0) {
      game.informPlayers("String_Node_Str" + spell.getName() + "String_Node_Str"+ stormCount+ "String_Node_Str"+ (stormCount > 1 ? "String_Node_Str" : "String_Node_Str"));
      for (int i=0; i < stormCount; i++) {
        Spell copy=spell.copySpell();
        copy.setControllerId(source.getControllerId());
        copy.setCopiedSpell(true);
        game.getStack().push(copy);
        copy.chooseNewTargets(game,source.getControllerId());
      }
    }
    return true;
  }
  return false;
}
Program: 159019
Project: 159019
Buggy source:
@Override public void watch(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.SPELL_CAST) {
    spellsCastThisTurnInOrder.add(event.getTargetId());
    UUID playerId=event.getPlayerId();
    if (playerId != null) {
      Integer amount=amountOfSpellsCastOnCurrentTurn.get(playerId);
      if (amount == null) {
        amount=1;
      }
 else {
        amount=amount + 1;
      }
      amountOfSpellsCastOnCurrentTurn.put(playerId,amount);
    }
  }
}

Fixed version (ground truth):
@Override public void watch(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.SPELL_CAST) {
    spellsCastThisTurnInOrder.add(new MageObjectReference(event.getSourceId(),game));
    UUID playerId=event.getPlayerId();
    if (playerId != null) {
      Integer amount=amountOfSpellsCastOnCurrentTurn.get(playerId);
      if (amount == null) {
        amount=1;
      }
 else {
        amount=amount + 1;
      }
      amountOfSpellsCastOnCurrentTurn.put(playerId,amount);
    }
  }
}
Program: 159020
Project: 159020
Buggy source:
public int getSpellOrder(Spell spell){
  int index=0;
  for (  UUID uuid : spellsCastThisTurnInOrder) {
    index++;
    if (spell.getId().equals(uuid)) {
      return index;
    }
  }
  return 0;
}

Fixed version (ground truth):
public int getSpellOrder(Spell spell){
  int index=0;
  for (  MageObjectReference mor : spellsCastThisTurnInOrder) {
    index++;
    if (mor.refersTo(spell)) {
      return index;
    }
  }
  return 0;
}
Program: 159021
Project: 159021
Buggy source:
@Override public boolean apply(Game game,Ability source){
  for (  Permanent permanent : game.getBattlefield().getAllActivePermanents(CardType.CREATURE)) {
    if (permanent.getManaCost().convertedManaCost() <= source.getManaCostsToPay().getX()) {
      permanent.destroy(source.getSourceId(),game,false);
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  for (  Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(),source.getControllerId(),source.getSourceId(),game)) {
    if (permanent.getManaCost().convertedManaCost() <= source.getManaCostsToPay().getX()) {
      permanent.destroy(source.getSourceId(),game,false);
    }
  }
  return true;
}
Program: 159023
Project: 159023
Buggy source:
protected List<Permanent> threats(UUID playerId,UUID sourceId,FilterPermanent filter,Game game,List<UUID> targets){
  List<Permanent> threats=(playerId == null || sourceId == null) ? game.getBattlefield().getActivePermanents(filter,this.getId(),sourceId,game) : game.getBattlefield().getActivePermanents(filter,playerId,sourceId,game);
  Iterator<Permanent> it=threats.iterator();
  while (it.hasNext()) {
    Permanent test=it.next();
    if (targets.contains(test.getId()) || (playerId != null && !test.getControllerId().equals(playerId))) {
      it.remove();
    }
  }
  Collections.sort(threats,new PermanentComparator(game));
  Collections.reverse(threats);
  return threats;
}

Fixed version (ground truth):
protected List<Permanent> threats(UUID playerId,UUID sourceId,FilterPermanent filter,Game game,List<UUID> targets){
  List<Permanent> threats;
  if (playerId == null) {
    threats=game.getBattlefield().getActivePermanents(filter,this.getId(),sourceId,game);
  }
 else {
    FilterPermanent filterCopy=filter.copy();
    filterCopy.add(new PlayerIdPredicate(playerId));
    threats=game.getBattlefield().getActivePermanents(filter,this.getId(),sourceId,game);
  }
  Iterator<Permanent> it=threats.iterator();
  while (it.hasNext()) {
    Permanent test=it.next();
    if (targets.contains(test.getId()) || (playerId != null && !test.getControllerId().equals(playerId))) {
      it.remove();
    }
  }
  Collections.sort(threats,new PermanentComparator(game));
  Collections.reverse(threats);
  return threats;
}
Program: 159024
Project: 159024
Buggy source:
/** 
 * Checks that pro black can still be sacrificed
 */
@Test public void testSacrifice(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",4);
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str");
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  setStopAt(1,PhaseStep.BEGIN_COMBAT);
  execute();
  assertPermanentCount(playerB,0);
  assertPowerToughness(playerA,"String_Node_Str",3,3);
}

Fixed version (ground truth):
/** 
 * Checks that creature with protection black can still be sacrificed
 */
@Test public void testSacrifice(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",4);
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str");
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  setStopAt(1,PhaseStep.BEGIN_COMBAT);
  execute();
  assertPermanentCount(playerB,0);
  assertPowerToughness(playerA,"String_Node_Str",3,3);
}
Program: 159025
Project: 159025
Buggy source:
protected List<Permanent> threats(UUID playerId,UUID sourceId,FilterPermanent filter,Game game,List<UUID> targets){
  List<Permanent> threats;
  if (playerId == null) {
    threats=game.getBattlefield().getActivePermanents(filter,this.getId(),sourceId,game);
  }
 else {
    FilterPermanent filterCopy=filter.copy();
    filterCopy.add(new PlayerIdPredicate(playerId));
    threats=game.getBattlefield().getActivePermanents(filter,this.getId(),sourceId,game);
  }
  Iterator<Permanent> it=threats.iterator();
  while (it.hasNext()) {
    Permanent test=it.next();
    if (targets.contains(test.getId()) || (playerId != null && !test.getControllerId().equals(playerId))) {
      it.remove();
    }
  }
  Collections.sort(threats,new PermanentComparator(game));
  Collections.reverse(threats);
  return threats;
}

Fixed version (ground truth):
protected List<Permanent> threats(UUID playerId,UUID sourceId,FilterPermanent filter,Game game,List<UUID> targets){
  List<Permanent> threats;
  if (playerId == null) {
    threats=game.getBattlefield().getActivePermanents(filter,this.getId(),sourceId,game);
  }
 else {
    FilterPermanent filterCopy=filter.copy();
    filterCopy.add(new ControllerIdPredicate(playerId));
    threats=game.getBattlefield().getActivePermanents(filter,this.getId(),sourceId,game);
  }
  Iterator<Permanent> it=threats.iterator();
  while (it.hasNext()) {
    Permanent test=it.next();
    if (targets.contains(test.getId()) || (playerId != null && !test.getControllerId().equals(playerId))) {
      it.remove();
    }
  }
  Collections.sort(threats,new PermanentComparator(game));
  Collections.reverse(threats);
  return threats;
}
Program: 159027
Project: 159027
Buggy source:
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (event.getTargetId().equals(source.getSourceId())) {
    UUID targetId=(UUID)game.getState().getValue("String_Node_Str" + source.getSourceId());
    Logger.getLogger(UndyingReplacementEffect.class).info("String_Node_Str" + targetId + "String_Node_Str"+ event.getTargetId());
    if (targetId != null && targetId.equals(source.getSourceId())) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (event.getTargetId().equals(source.getSourceId())) {
    UUID targetId=(UUID)game.getState().getValue("String_Node_Str" + source.getSourceId());
    if (targetId != null && targetId.equals(source.getSourceId())) {
      return true;
    }
  }
  return false;
}
Program: 159028
Project: 159028
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (super.checkTrigger(event,game)) {
    Permanent permanent=(Permanent)game.getLastKnownInformation(event.getTargetId(),Zone.BATTLEFIELD);
    if (!permanent.getCounters().containsKey(CounterType.P1P1) || permanent.getCounters().getCount(CounterType.P1P1) == 0) {
      Logger.getLogger(UndyingAbility.class).info("String_Node_Str" + getSourceId());
      game.getState().setValue("String_Node_Str" + getSourceId(),permanent.getId());
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (super.checkTrigger(event,game)) {
    Permanent permanent=(Permanent)game.getLastKnownInformation(event.getTargetId(),Zone.BATTLEFIELD);
    if (!permanent.getCounters().containsKey(CounterType.P1P1) || permanent.getCounters().getCount(CounterType.P1P1) == 0) {
      game.getState().setValue("String_Node_Str" + getSourceId(),permanent.getId());
      return true;
    }
  }
  return false;
}
Program: 159029
Project: 159029
Buggy source:
@Override public boolean playMana(ManaCost unpaid,Game game){
  payManaMode=true;
  boolean result=playManaHandling(unpaid,game);
  payManaMode=false;
  return result;
}

Fixed version (ground truth):
@Override public boolean playMana(ManaCost unpaid,String promptText,Game game){
  payManaMode=true;
  boolean result=playManaHandling(unpaid,game);
  payManaMode=false;
  return result;
}
Program: 159030
Project: 159030
Buggy source:
protected boolean playManaHandling(ManaCost unpaid,Game game){
  updateGameStatePriority("String_Node_Str",game);
  game.firePlayManaEvent(playerId,"String_Node_Str" + unpaid.getText());
  waitForResponse(game);
  if (!this.isInGame()) {
    return false;
  }
  if (response.getBoolean() != null) {
    return false;
  }
 else   if (response.getUUID() != null) {
    playManaAbilities(unpaid,game);
  }
 else   if (response.getString() != null && response.getString().equals("String_Node_Str")) {
    if (unpaid instanceof ManaCostsImpl) {
      specialManaAction(unpaid,game);
      ManaCostsImpl<ManaCost> costs=(ManaCostsImpl<ManaCost>)unpaid;
      for (      ManaCost cost : costs.getUnpaid()) {
        if (cost instanceof PhyrexianManaCost) {
          PhyrexianManaCost ph=(PhyrexianManaCost)cost;
          if (ph.canPay(null,null,playerId,game)) {
            ((PhyrexianManaCost)cost).pay(null,game,null,playerId,false);
          }
          break;
        }
      }
    }
  }
 else   if (response.getManaType() != null) {
    if (response.getResponseManaTypePlayerId().equals(this.getId())) {
      this.getManaPool().unlockManaType(response.getManaType());
    }
  }
  return true;
}

Fixed version (ground truth):
protected boolean playManaHandling(ManaCost unpaid,String promptText,Game game){
  updateGameStatePriority("String_Node_Str",game);
  game.firePlayManaEvent(playerId,"String_Node_Str" + promptText);
  waitForResponse(game);
  if (!this.isInGame()) {
    return false;
  }
  if (response.getBoolean() != null) {
    return false;
  }
 else   if (response.getUUID() != null) {
    playManaAbilities(unpaid,game);
  }
 else   if (response.getString() != null && response.getString().equals("String_Node_Str")) {
    if (unpaid instanceof ManaCostsImpl) {
      specialManaAction(unpaid,game);
      ManaCostsImpl<ManaCost> costs=(ManaCostsImpl<ManaCost>)unpaid;
      for (      ManaCost cost : costs.getUnpaid()) {
        if (cost instanceof PhyrexianManaCost) {
          PhyrexianManaCost ph=(PhyrexianManaCost)cost;
          if (ph.canPay(null,null,playerId,game)) {
            ((PhyrexianManaCost)cost).pay(null,game,null,playerId,false);
          }
          break;
        }
      }
    }
  }
 else   if (response.getManaType() != null) {
    if (response.getResponseManaTypePlayerId().equals(this.getId())) {
      this.getManaPool().unlockManaType(response.getManaType());
    }
  }
  return true;
}
Program: 159031
Project: 159031
Buggy source:
@Override public boolean playMana(ManaCost unpaid,Game game){
  payManaMode=true;
  boolean result=playManaHandling(unpaid,game);
  payManaMode=false;
  return result;
}

Fixed version (ground truth):
@Override public boolean playMana(ManaCost unpaid,String promptText,Game game){
  payManaMode=true;
  boolean result=playManaHandling(unpaid,promptText,game);
  payManaMode=false;
  return result;
}
Program: 159032
Project: 159032
Buggy source:
@Override public boolean pay(Ability ability,Game game,UUID sourceId,UUID controllerId,boolean noMana){
  if (noMana) {
    setPaid();
    return true;
  }
  Player player=game.getPlayer(controllerId);
  assignPayment(game,ability,player.getManaPool());
  while (!isPaid()) {
    if (player.playMana(this,game)) {
      assignPayment(game,ability,player.getManaPool());
    }
 else {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean pay(Ability ability,Game game,UUID sourceId,UUID controllerId,boolean noMana){
  if (noMana) {
    setPaid();
    return true;
  }
  Player player=game.getPlayer(controllerId);
  assignPayment(game,ability,player.getManaPool());
  while (!isPaid()) {
    ManaCost unpaid=this.getUnpaid();
    String promptText=ManaUtil.addSpecialManaPayAbilities(ability,game,unpaid);
    if (player.playMana(unpaid,promptText,game)) {
      assignPayment(game,ability,player.getManaPool());
    }
 else {
      return false;
    }
    game.getState().getSpecialActions().removeManaActions();
  }
  return true;
}
Program: 159033
Project: 159033
Buggy source:
@Override public boolean pay(Ability ability,Game game,UUID sourceId,UUID controllerId,boolean noMana){
  if (this.size() == 0 || noMana) {
    setPaid();
    return true;
  }
  Player player=game.getPlayer(controllerId);
  assignPayment(game,ability,player.getManaPool());
  while (!isPaid()) {
    addSpecialManaPayAbilities(ability,game);
    if (player.playMana(this.getUnpaid(),game)) {
      assignPayment(game,ability,player.getManaPool());
    }
 else {
      return false;
    }
    game.getState().getSpecialActions().removeManaActions();
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean pay(Ability ability,Game game,UUID sourceId,UUID controllerId,boolean noMana){
  if (this.size() == 0 || noMana) {
    setPaid();
    return true;
  }
  Player player=game.getPlayer(controllerId);
  assignPayment(game,ability,player.getManaPool());
  while (!isPaid()) {
    ManaCost unpaid=this.getUnpaid();
    String promptText=ManaUtil.addSpecialManaPayAbilities(ability,game,unpaid);
    if (player.playMana(unpaid,promptText,game)) {
      assignPayment(game,ability,player.getManaPool());
    }
 else {
      return false;
    }
    game.getState().getSpecialActions().removeManaActions();
  }
  return true;
}
Program: 159034
Project: 159034
Buggy source:
boolean playMana(ManaCost unpaid,Game game);

Fixed version (ground truth):
boolean playMana(ManaCost unpaid,String promptText,Game game);
Program: 159035
Project: 159035
Buggy source:
@Override public boolean applies(GameEvent event,Ability source,Game game){
  MageObject mageObject=source.getSourceObject(game);
  return mageObject != null && mageObject.getCardType().contains(CardType.LAND);
}

Fixed version (ground truth):
@Override public boolean applies(GameEvent event,Ability source,Game game){
  MageObject mageObject=game.getObject(event.getSourceId());
  return mageObject != null && mageObject.getCardType().contains(CardType.LAND);
}
Program: 159036
Project: 159036
Buggy source:
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (event.getType() == EventType.ZONE_CHANGE) {
    ZoneChangeEvent zEvent=(ZoneChangeEvent)event;
    if (zEvent.getToZone() == Zone.GRAVEYARD && ((ZoneChangeEvent)event).getTargetId().equals(getTargetPointer().getFirst(game,source))) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(GameEvent event,Ability source,Game game){
  ZoneChangeEvent zEvent=(ZoneChangeEvent)event;
  if (zEvent.getToZone() == Zone.GRAVEYARD && ((ZoneChangeEvent)event).getTargetId().equals(getTargetPointer().getFirst(game,source))) {
    return true;
  }
  return false;
}
Program: 159037
Project: 159037
Buggy source:
@Override public void adjustTargets(Ability ability,Game game){
  if (ability instanceof EntersBattlefieldTriggeredAbility) {
    for (    UUID opponentId : game.getOpponents(ability.getControllerId())) {
      Player opponent=game.getPlayer(opponentId);
      if (opponent != null) {
        ability.getTargets().clear();
        FilterCard filter=new FilterCard(new StringBuilder("String_Node_Str").append(opponent.getName()).append("String_Node_Str").toString());
        filter.add(new OwnerIdPredicate(opponentId));
        filter.add(Predicates.or(new CardTypePredicate(CardType.INSTANT),new CardTypePredicate(CardType.SORCERY)));
        TargetCardInOpponentsGraveyard target=new TargetCardInOpponentsGraveyard(0,1,filter);
        ability.addTarget(target);
      }
    }
  }
}

Fixed version (ground truth):
@Override public void adjustTargets(Ability ability,Game game){
  if (ability instanceof EntersBattlefieldTriggeredAbility) {
    ability.getTargets().clear();
    for (    UUID opponentId : game.getOpponents(ability.getControllerId())) {
      Player opponent=game.getPlayer(opponentId);
      if (opponent != null) {
        FilterCard filter=new FilterCard(new StringBuilder("String_Node_Str").append(opponent.getName()).append("String_Node_Str").toString());
        filter.add(new OwnerIdPredicate(opponentId));
        filter.add(Predicates.or(new CardTypePredicate(CardType.INSTANT),new CardTypePredicate(CardType.SORCERY)));
        TargetCardInOpponentsGraveyard target=new TargetCardInOpponentsGraveyard(0,1,filter);
        ability.addTarget(target);
      }
    }
  }
}
Program: 159038
Project: 159038
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(targetPointer.getFirst(game,source));
  if (player != null) {
    boolean paid=false;
    Cost cost=new DiscardTargetCost(new TargetCardInHand());
    if (cost.canPay(source,player.getId(),player.getId(),game) && player.chooseUse(Outcome.Detriment,"String_Node_Str",game)) {
      paid=cost.pay(source,game,source.getSourceId(),player.getId(),false);
    }
    if (!paid) {
      player.loseLife(5,game);
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(targetPointer.getFirst(game,source));
  if (player != null) {
    boolean paid=false;
    Cost cost=new DiscardTargetCost(new TargetCardInHand());
    if (cost.canPay(source,source.getSourceId(),player.getId(),game) && player.chooseUse(Outcome.Detriment,"String_Node_Str",game)) {
      paid=cost.pay(source,game,source.getSourceId(),player.getId(),false);
    }
    if (!paid) {
      player.loseLife(5,game);
    }
    return true;
  }
  return false;
}
Program: 159039
Project: 159039
Buggy source:
public SoulflayerEffect(final SoulflayerEffect effect){
  super(effect);
  if (effect.abilitiesToAdd != null) {
    this.abilitiesToAdd=new HashSet<>();
    this.abilitiesToAdd.addAll(effect.abilitiesToAdd);
  }
}

Fixed version (ground truth):
public SoulflayerEffect(final SoulflayerEffect effect){
  super(effect);
  if (effect.abilitiesToAdd != null) {
    this.abilitiesToAdd=new HashSet<>();
    this.abilitiesToAdd.addAll(effect.abilitiesToAdd);
  }
  this.objectReference=effect.objectReference;
}
Program: 159041
Project: 159041
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  if (player != null) {
    player.loseLife(3,game);
    TargetCardInLibrary target=new TargetCardInLibrary();
    if (player.searchLibrary(target,game)) {
      for (      UUID cardId : target.getTargets()) {
        Card card=player.getLibrary().getCard(cardId,game);
        player.putInHand(card,game);
      }
    }
    player.shuffleLibrary(game);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  UUID activePlayerId=game.getActivePlayerId();
  Player player=game.getPlayer(activePlayerId);
  if (player != null) {
    player.loseLife(3,game);
    TargetCardInLibrary target=new TargetCardInLibrary();
    if (player.searchLibrary(target,game)) {
      for (      UUID cardId : target.getTargets()) {
        Card card=player.getLibrary().getCard(cardId,game);
        player.putInHand(card,game);
      }
    }
    player.shuffleLibrary(game);
    return true;
  }
  return false;
}
Program: 159042
Project: 159042
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.TAPPED_FOR_MANA && event.getSourceId().equals(getSourceId())) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  return event.getSourceId().equals(getSourceId());
}
Program: 159044
Project: 159044
Buggy source:
@Override public boolean canAttack(UUID defenderId,Ability source,Game game){
  UUID defendingPlayerId=null;
  Player player=game.getPlayer(defenderId);
  if (player == null) {
    Permanent permanent=game.getPermanent(defenderId);
    if (permanent != null) {
      defendingPlayerId=permanent.getControllerId();
    }
  }
 else {
    defendingPlayerId=defenderId;
  }
  if (defendingPlayerId != null && game.getBattlefield().countAll(filter,defendingPlayerId,game) == 0) {
    return true;
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean canAttack(UUID defenderId,Ability source,Game game){
  UUID defendingPlayerId;
  Player player=game.getPlayer(defenderId);
  if (player == null) {
    Permanent permanent=game.getPermanent(defenderId);
    if (permanent != null) {
      defendingPlayerId=permanent.getControllerId();
    }
 else {
      return false;
    }
  }
 else {
    defendingPlayerId=defenderId;
  }
  if (defendingPlayerId != null && game.getBattlefield().countAll(filter,defendingPlayerId,game) == 0) {
    return false;
  }
  return true;
}
Program: 159045
Project: 159045
Buggy source:
@Override public List<CardInfo> getCardsByRarity(Rarity rarity){
  if (rarity.equals(Rarity.COMMON)) {
    List<CardInfo> savedCardsInfos=savedCards.get(rarity);
    if (savedCardsInfos == null) {
      CardCriteria criteria=new CardCriteria();
      criteria.setCodes(this.code).notTypes(CardType.LAND);
      criteria.rarities(rarity).doubleFaced(false);
      if (maxCardNumberInBooster != Integer.MAX_VALUE) {
        criteria.maxCardNumber(maxCardNumberInBooster);
      }
      savedCardsInfos=CardRepository.instance.findCards(criteria);
      savedCards.put(rarity,savedCardsInfos);
    }
    return savedCardsInfos;
  }
 else {
    return super.getCardsByRarity(rarity);
  }
}

Fixed version (ground truth):
@Override public List<CardInfo> getCardsByRarity(Rarity rarity){
  if (rarity.equals(Rarity.COMMON)) {
    List<CardInfo> savedCardsInfos=savedCards.get(rarity);
    if (savedCardsInfos == null) {
      CardCriteria criteria=new CardCriteria();
      criteria.setCodes(this.code).notTypes(CardType.LAND);
      criteria.rarities(rarity).doubleFaced(false);
      if (maxCardNumberInBooster != Integer.MAX_VALUE) {
        criteria.maxCardNumber(maxCardNumberInBooster);
      }
      savedCardsInfos=CardRepository.instance.findCards(criteria);
      savedCards.put(rarity,savedCardsInfos);
    }
    List<CardInfo> cards=new ArrayList<>();
    cards.addAll(savedCardsInfos);
    return cards;
  }
 else {
    return super.getCardsByRarity(rarity);
  }
}
Program: 159046
Project: 159046
Buggy source:
public void subtractCostAddMana(Mana cost,Mana addMana,boolean onlyManaCosts){
  if (isEmpty()) {
    this.add(new Mana());
  }
  boolean repeatable=false;
  if (addMana.getAny() == 1 && addMana.count() == 1 && onlyManaCosts) {
  }
  for (  Mana mana : this) {
    while (mana.includesMana(cost)) {
      mana.subtractCost(cost);
      mana.add(addMana);
      if (!repeatable) {
        break;
      }
    }
  }
}

Fixed version (ground truth):
public void subtractCostAddMana(Mana cost,Mana addMana,boolean onlyManaCosts){
  if (isEmpty()) {
    this.add(new Mana());
  }
  boolean repeatable=false;
  if (addMana.getAny() == 1 && addMana.count() == 1 && onlyManaCosts) {
    repeatable=true;
  }
  for (  Mana mana : this) {
    while (mana.includesMana(cost)) {
      mana.subtractCost(cost);
      mana.add(addMana);
      if (!repeatable) {
        break;
      }
    }
  }
}
Program: 159048
Project: 159048
Buggy source:
public Mana computeMana(String color,Game game,Ability source){
  this.computedMana.clear();
  if (color != null && !color.isEmpty()) {
switch (color) {
case "String_Node_Str":
      computedMana.setRed(new DevotionCount(ColoredManaSymbol.R).calculate(game,source,this));
    break;
case "String_Node_Str":
  computedMana.setBlue(new DevotionCount(ColoredManaSymbol.U).calculate(game,source,this));
break;
case "String_Node_Str":
computedMana.setWhite(new DevotionCount(ColoredManaSymbol.W).calculate(game,source,this));
break;
case "String_Node_Str":
computedMana.setBlack(new DevotionCount(ColoredManaSymbol.B).calculate(game,source,this));
break;
case "String_Node_Str":
computedMana.setGreen(new DevotionCount(ColoredManaSymbol.G).calculate(game,source,this));
break;
}
}
return computedMana;
}

Fixed version (ground truth):
public Mana computeMana(String color,Game game,Ability source){
  this.computedMana.clear();
  if (color != null && !color.isEmpty()) {
switch (color) {
case "String_Node_Str":
      computedMana.setRed(new DevotionCount(ColoredManaSymbol.R).calculate(game,source,this));
    break;
case "String_Node_Str":
  computedMana.setBlue(new DevotionCount(ColoredManaSymbol.U).calculate(game,source,this));
break;
case "String_Node_Str":
computedMana.setWhite(new DevotionCount(ColoredManaSymbol.W).calculate(game,source,this));
break;
case "String_Node_Str":
computedMana.setBlack(new DevotionCount(ColoredManaSymbol.B).calculate(game,source,this));
break;
case "String_Node_Str":
computedMana.setGreen(new DevotionCount(ColoredManaSymbol.G).calculate(game,source,this));
break;
}
}
return computedMana.copy();
}
Program: 159050
Project: 159050
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    Map<UUID,Integer> playerAmount=new HashMap<UUID,Integer>();
    for (    UUID playerId : controller.getInRange()) {
      Player player=game.getPlayer(playerId);
      if (player != null) {
        int amount=0;
        for (        Permanent permanent : game.getBattlefield().getAllActivePermanents(filter,playerId,game)) {
          amount++;
          permanent.destroy(source.getSourceId(),game,false);
        }
        playerAmount.put(playerId,new Integer(amount));
      }
    }
    for (    Map.Entry<UUID,Integer> entry : playerAmount.entrySet()) {
      Player player=game.getPlayer(entry.getKey());
      if (player != null) {
        TargetCardInLibrary target=new TargetCardInLibrary(0,entry.getValue().intValue(),new FilterBasicLandCard());
        if (player.searchLibrary(target,game)) {
          if (target.getTargets().size() > 0) {
            for (            UUID cardId : (List<UUID>)target.getTargets()) {
              Card card=player.getLibrary().getCard(cardId,game);
              if (card != null) {
                card.putOntoBattlefield(game,Zone.LIBRARY,source.getSourceId(),player.getId(),false);
              }
            }
          }
        }
        player.shuffleLibrary(game);
      }
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    Map<UUID,Integer> playerAmount=new HashMap<>();
    for (    UUID playerId : controller.getInRange()) {
      Player player=game.getPlayer(playerId);
      if (player != null) {
        int amount=0;
        for (        Permanent permanent : game.getBattlefield().getAllActivePermanents(filter,playerId,game)) {
          amount++;
          permanent.destroy(source.getSourceId(),game,false);
        }
        playerAmount.put(playerId,amount);
      }
    }
    for (    Map.Entry<UUID,Integer> entry : playerAmount.entrySet()) {
      Player player=game.getPlayer(entry.getKey());
      if (player != null) {
        TargetCardInLibrary target=new TargetCardInLibrary(0,entry.getValue(),new FilterBasicLandCard());
        if (player.searchLibrary(target,game)) {
          if (target.getTargets().size() > 0) {
            for (            UUID cardId : target.getTargets()) {
              Card card=player.getLibrary().getCard(cardId,game);
              if (card != null) {
                card.putOntoBattlefield(game,Zone.LIBRARY,source.getSourceId(),player.getId(),false);
              }
            }
          }
        }
        player.shuffleLibrary(game);
      }
    }
    return true;
  }
  return false;
}
Program: 159051
Project: 159051
Buggy source:
@Override public Set<UUID> possibleTargets(UUID sourceControllerId,Game game){
  Set<UUID> possibleTargets=new HashSet<UUID>();
  for (  StackObject stackObject : game.getStack()) {
    Spell spell=game.getStack().getSpell(stackObject.getId());
    if (spell != null && filter.match(spell,null,sourceControllerId,game) && filter.match(spell,game)) {
      possibleTargets.add(spell.getId());
    }
  }
  for (  Permanent permanent : game.getBattlefield().getActivePermanents(filterPermanent,sourceControllerId,game)) {
    if (filter.match(permanent,null,sourceControllerId,game)) {
      possibleTargets.add(permanent.getId());
    }
  }
  return possibleTargets;
}

Fixed version (ground truth):
@Override public Set<UUID> possibleTargets(UUID sourceControllerId,Game game){
  Set<UUID> possibleTargets=new HashSet<>();
  for (  StackObject stackObject : game.getStack()) {
    Spell spell=game.getStack().getSpell(stackObject.getId());
    if (spell != null && filter.match(spell,null,sourceControllerId,game) && filter.match(spell,game)) {
      possibleTargets.add(spell.getId());
    }
  }
  for (  Permanent permanent : game.getBattlefield().getActivePermanents(filterPermanent,sourceControllerId,game)) {
    if (filter.match(permanent,null,sourceControllerId,game)) {
      possibleTargets.add(permanent.getId());
    }
  }
  return possibleTargets;
}
Program: 159052
Project: 159052
Buggy source:
/** 
 * Momentous Fall Instant {2}{G}{G} As an additional cost to cast Momentous Fall, sacrifice a creature. You draw cards equal to the sacrificed creature's power, then you gain life equal to its toughness.
 */
@Test public void testSacrificeCostAndLKI(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",4);
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  setStopAt(1,PhaseStep.BEGIN_COMBAT);
  execute();
  assertPermanentCount(playerA,"String_Node_Str",1);
  assertPowerToughness(playerA,"String_Node_Str",5,4);
  assertHandCount(playerA,4);
  assertLife(playerA,23);
}

Fixed version (ground truth):
/** 
 * Momentous Fall Instant {2}{G}{G} As an additional cost to cast Momentous Fall, sacrifice a creature. You draw cards equal to the sacrificed creature's power, then you gain life equal to its toughness.
 */
@Test public void testSacrificeCostAndLKI(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",4);
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  setStopAt(1,PhaseStep.BEGIN_COMBAT);
  execute();
  assertPermanentCount(playerA,"String_Node_Str",1);
  assertCounterCount("String_Node_Str",CounterType.P1P1,1);
  assertPowerToughness(playerA,"String_Node_Str",5,4);
  assertHandCount(playerA,4);
  assertLife(playerA,23);
}
Program: 159053
Project: 159053
Buggy source:
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (event.getTargetId().equals(source.getSourceId())) {
    UUID target=(UUID)game.getState().getValue("String_Node_Str" + source.getSourceId());
    if (target.equals(source.getSourceId())) {
      game.getState().setValue("String_Node_Str" + source.getSourceId(),null);
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (event.getTargetId().equals(source.getSourceId())) {
    UUID targetId=(UUID)game.getState().getValue("String_Node_Str" + source.getSourceId());
    Logger.getLogger(UndyingReplacementEffect.class).info("String_Node_Str" + targetId + "String_Node_Str"+ event.getTargetId());
    if (targetId != null && targetId.equals(source.getSourceId())) {
      return true;
    }
  }
  return false;
}
Program: 159054
Project: 159054
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (super.checkTrigger(event,game)) {
    Permanent permanent=(Permanent)game.getLastKnownInformation(event.getTargetId(),Zone.BATTLEFIELD);
    if (!permanent.getCounters().containsKey(CounterType.P1P1) || permanent.getCounters().getCount(CounterType.P1P1) == 0) {
      game.getState().setValue("String_Node_Str" + getSourceId(),permanent.getId());
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (super.checkTrigger(event,game)) {
    Permanent permanent=(Permanent)game.getLastKnownInformation(event.getTargetId(),Zone.BATTLEFIELD);
    if (!permanent.getCounters().containsKey(CounterType.P1P1) || permanent.getCounters().getCount(CounterType.P1P1) == 0) {
      Logger.getLogger(UndyingAbility.class).info("String_Node_Str" + getSourceId());
      game.getState().setValue("String_Node_Str" + getSourceId(),permanent.getId());
      return true;
    }
  }
  return false;
}
Program: 159055
Project: 159055
Buggy source:
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Permanent permanent=game.getPermanent(event.getTargetId());
  if (permanent != null) {
    permanent.addCounters(CounterType.P1P1.createInstance(),game);
  }
  used=true;
  return false;
}

Fixed version (ground truth):
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Permanent permanent=game.getPermanent(event.getTargetId());
  if (permanent != null) {
    game.getState().setValue("String_Node_Str" + source.getSourceId(),null);
    permanent.addCounters(CounterType.P1P1.createInstance(),game);
  }
  used=true;
  return false;
}
Program: 159056
Project: 159056
Buggy source:
private void addPopupMenuCardPanel(){
  JMenuItem menuItem;
  menuItem=new JMenuItem("String_Node_Str");
  popupMenuCardPanel.add(menuItem);
  menuItem.addActionListener(new ActionListener(){
    @Override public void actionPerformed(    ActionEvent e){
      cardsHidden.add(cardIdPopupMenu);
      pickedCardsShown.remove(cardIdPopupMenu);
      draftPicks.loadCards(CardsViewUtil.convertSimple(pickedCardsShown),bigCard,null);
    }
  }
);
}

Fixed version (ground truth):
private void addPopupMenuCardPanel(){
  JMenuItem menuItem;
  menuItem=new JMenuItem("String_Node_Str");
  popupMenuCardPanel.add(menuItem);
  menuItem.addActionListener(new ActionListener(){
    @Override public void actionPerformed(    ActionEvent e){
      hideThisCard(cardIdPopupMenu);
    }
  }
);
}
Program: 159057
Project: 159057
Buggy source:
private void showAgainAllHiddenCards(){
  cardsHidden.clear();
  draftPicks.loadCards(CardsViewUtil.convertSimple(pickedCards),bigCard,null);
}

Fixed version (ground truth):
private void showAgainAllHiddenCards(){
  for (  UUID card : cardsHidden) {
    pickedCardsShown.put(card,pickedCards.get(card));
  }
  cardsHidden.clear();
  draftPicks.loadCards(CardsViewUtil.convertSimple(pickedCardsShown),bigCard,null);
}
Program: 159058
Project: 159058
Buggy source:
@Override public void adjustTargets(Ability ability,Game game){
  for (  UUID modeId : ability.getModes().getSelectedModes()) {
    Mode mode=ability.getModes().get(modeId);
    for (    Effect effect : mode.getEffects()) {
      if (effect instanceof ReturnFromGraveyardToBattlefieldTargetEffect) {
        mode.getTargets().clear();
        int xValue=ability.getManaCostsToPay().getX();
        FilterCard filter=new FilterCreatureCard("String_Node_Str" + xValue + "String_Node_Str");
        filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan,xValue + 1));
        mode.getTargets().add(new TargetCardInYourGraveyard(filter));
      }
      if (effect instanceof GainAbilityTargetEffect) {
        mode.getTargets().clear();
        int xValue=ability.getManaCostsToPay().getX();
        FilterCreaturePermanent filter=new FilterCreaturePermanent("String_Node_Str");
        mode.getTargets().add(new TargetCreaturePermanent(0,xValue,filter,false));
      }
    }
  }
}

Fixed version (ground truth):
@Override public void adjustTargets(Ability ability,Game game){
  Mode mode=ability.getModes().getMode();
  for (  Effect effect : mode.getEffects()) {
    if (effect instanceof ReturnFromGraveyardToBattlefieldTargetEffect) {
      mode.getTargets().clear();
      int xValue=ability.getManaCostsToPay().getX();
      FilterCard filter=new FilterCreatureCard("String_Node_Str" + xValue + "String_Node_Str");
      filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan,xValue + 1));
      mode.getTargets().add(new TargetCardInYourGraveyard(filter));
    }
    if (effect instanceof GainAbilityTargetEffect) {
      mode.getTargets().clear();
      int xValue=ability.getManaCostsToPay().getX();
      FilterCreaturePermanent filter=new FilterCreaturePermanent("String_Node_Str");
      mode.getTargets().add(new TargetCreaturePermanent(0,xValue,filter,false));
    }
  }
}
Program: 159059
Project: 159059
Buggy source:
private boolean checkSpell(Spell spell,Game game){
  if (spell != null && (spell.getCardType().contains(CardType.INSTANT) || spell.getCardType().contains(CardType.SORCERY))) {
    UUID targetGolem=null;
    for (    SpellTargetAddress addr : SpellTargetAddress.walk(spell)) {
      Target targetInstance=addr.getTarget(spell);
      for (      UUID target : targetInstance.getTargets()) {
        Permanent permanent=game.getPermanent(target);
        if (permanent == null || !permanent.hasSubtype("String_Node_Str")) {
          return false;
        }
        if (targetGolem == null) {
          targetGolem=target;
        }
 else {
          if (!targetGolem.equals(target)) {
            return false;
          }
        }
      }
    }
    if (targetGolem != null) {
      getEffects().get(0).setTargetPointer(new FixedTarget(spell.getId()));
      getEffects().get(0).setValue("String_Node_Str",targetGolem);
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean checkSpell(Spell spell,Game game){
  if (spell != null && (spell.getCardType().contains(CardType.INSTANT) || spell.getCardType().contains(CardType.SORCERY))) {
    UUID targetGolem=null;
    for (    SpellTargetAddress addr : SpellTargetAddress.walk(spell)) {
      Target targetInstance=addr.getTarget(spell);
      for (      UUID target : targetInstance.getTargets()) {
        Permanent permanent=game.getPermanent(target);
        if (permanent == null || !permanent.hasSubtype("String_Node_Str")) {
          return false;
        }
        if (targetGolem == null) {
          targetGolem=target;
        }
 else {
          if (!targetGolem.equals(target)) {
            return false;
          }
        }
      }
    }
    if (targetGolem != null) {
      getEffects().get(0).setValue("String_Node_Str",spell);
      getEffects().get(0).setValue("String_Node_Str",targetGolem);
      return true;
    }
  }
  return false;
}
Program: 159061
Project: 159061
Buggy source:
@Override public boolean mustBlock(Game game){
  return true;
}

Fixed version (ground truth):
@Override public boolean mustBlock(Game game){
  return false;
}
Program: 159062
Project: 159062
Buggy source:
@Override public boolean mustAttack(Game game){
  return false;
}

Fixed version (ground truth):
@Override public boolean mustAttack(Game game){
  return true;
}
Program: 159063
Project: 159063
Buggy source:
@Override public boolean checksEventType(GameEvent event,Game game){
switch (event.getType()) {
case DAMAGED_CREATURE:
case DAMAGED_PLAYER:
case DAMAGE_PLANESWALKER:
    return true;
default :
  return false;
}
}

Fixed version (ground truth):
@Override public boolean checksEventType(GameEvent event,Game game){
switch (event.getType()) {
case DAMAGE_CREATURE:
case DAMAGE_PLAYER:
case DAMAGE_PLANESWALKER:
    return true;
default :
  return false;
}
}
Program: 159065
Project: 159065
Buggy source:
void cleanUp(){
  for (  Map.Entry<UUID,UUID> entry : userPlayerMap.entrySet()) {
    User user=UserManager.getInstance().getUser(entry.getKey());
    if (user != null) {
      user.removeTable(entry.getValue());
    }
  }
  ChatManager.getInstance().destroyChatSession(chatId);
}

Fixed version (ground truth):
void cleanUp(){
  if (!table.isTournamentSubTable()) {
    for (    Map.Entry<UUID,UUID> entry : userPlayerMap.entrySet()) {
      User user=UserManager.getInstance().getUser(entry.getKey());
      if (user != null) {
        user.removeTable(entry.getValue());
      }
    }
  }
  ChatManager.getInstance().destroyChatSession(chatId);
}
Program: 159066
Project: 159066
Buggy source:
private void matchEnd(){
  if (match != null) {
    for (    Entry<UUID,UUID> entry : userPlayerMap.entrySet()) {
      MatchPlayer matchPlayer=match.getPlayer(entry.getValue());
      if (matchPlayer != null) {
        if (!matchPlayer.hasQuit()) {
          User user=UserManager.getInstance().getUser(entry.getKey());
          if (user != null) {
            if (table.getState().equals(TableState.SIDEBOARDING)) {
              StringBuilder sb=new StringBuilder();
              if (table.isTournamentSubTable()) {
                sb.append("String_Node_Str");
                sb.append(table.getTournament().getRounds().size());
                sb.append("String_Node_Str");
              }
 else {
                sb.append("String_Node_Str").append(match.getName()).append("String_Node_Str");
              }
              if (match.getPlayers().size() > 2) {
                sb.append("String_Node_Str");
              }
 else {
                sb.append("String_Node_Str");
              }
              user.showUserMessage("String_Node_Str",sb.toString());
            }
            user.removeTable(entry.getValue());
          }
        }
      }
    }
    match.cleanUpOnMatchEnd(ConfigSettings.getInstance().isSaveGameActivated(),table.isTournament());
  }
}

Fixed version (ground truth):
private void matchEnd(){
  if (match != null) {
    for (    Entry<UUID,UUID> entry : userPlayerMap.entrySet()) {
      MatchPlayer matchPlayer=match.getPlayer(entry.getValue());
      if (matchPlayer != null) {
        if (!matchPlayer.hasQuit()) {
          User user=UserManager.getInstance().getUser(entry.getKey());
          if (user != null) {
            if (table.getState().equals(TableState.SIDEBOARDING)) {
              StringBuilder sb=new StringBuilder();
              if (table.isTournamentSubTable()) {
                sb.append("String_Node_Str");
                sb.append(table.getTournament().getRounds().size());
                sb.append("String_Node_Str");
              }
 else {
                sb.append("String_Node_Str").append(match.getName()).append("String_Node_Str");
              }
              if (match.getPlayers().size() > 2) {
                sb.append("String_Node_Str");
              }
 else {
                sb.append("String_Node_Str");
              }
              user.showUserMessage("String_Node_Str",sb.toString());
            }
            if (!table.isTournamentSubTable()) {
              user.removeTable(entry.getValue());
            }
          }
        }
      }
    }
    match.cleanUpOnMatchEnd(ConfigSettings.getInstance().isSaveGameActivated(),table.isTournament());
  }
}