mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
Merge pull request #2887 from aastrand/ignorelist
Add client-side user ignore list
This commit is contained in:
commit
d4415e2eff
22 changed files with 443 additions and 18 deletions
|
|
@ -30,7 +30,9 @@ package mage.game;
|
|||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.cards.decks.DeckValidator;
|
||||
import mage.constants.TableState;
|
||||
|
|
@ -63,6 +65,7 @@ public class Table implements Serializable {
|
|||
private Match match;
|
||||
private Tournament tournament;
|
||||
private TableRecorder recorder;
|
||||
private Set<String> bannedUsernames;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface TableRecorder {
|
||||
|
|
@ -71,21 +74,21 @@ public class Table implements Serializable {
|
|||
|
||||
protected TableEventSource tableEventSource = new TableEventSource();
|
||||
|
||||
public Table(UUID roomId, String gameType, String name, String controllerName, DeckValidator validator, List<String> playerTypes, TableRecorder recorder, Tournament tournament) {
|
||||
this(roomId, gameType, name, controllerName, validator, playerTypes, recorder);
|
||||
public Table(UUID roomId, String gameType, String name, String controllerName, DeckValidator validator, List<String> playerTypes, TableRecorder recorder, Tournament tournament, Set<String> bannedUsernames) {
|
||||
this(roomId, gameType, name, controllerName, validator, playerTypes, recorder, bannedUsernames);
|
||||
this.tournament = tournament;
|
||||
this.isTournament = true;
|
||||
setState(TableState.WAITING);
|
||||
}
|
||||
|
||||
public Table(UUID roomId, String gameType, String name, String controllerName, DeckValidator validator, List<String> playerTypes, TableRecorder recorder, Match match) {
|
||||
this(roomId, gameType, name, controllerName, validator, playerTypes, recorder);
|
||||
public Table(UUID roomId, String gameType, String name, String controllerName, DeckValidator validator, List<String> playerTypes, TableRecorder recorder, Match match, Set<String> bannedUsernames) {
|
||||
this(roomId, gameType, name, controllerName, validator, playerTypes, recorder, bannedUsernames);
|
||||
this.match = match;
|
||||
this.isTournament = false;
|
||||
setState(TableState.WAITING);
|
||||
}
|
||||
|
||||
protected Table(UUID roomId, String gameType, String name, String controllerName, DeckValidator validator, List<String> playerTypes, TableRecorder recorder) {
|
||||
protected Table(UUID roomId, String gameType, String name, String controllerName, DeckValidator validator, List<String> playerTypes, TableRecorder recorder, Set<String> bannedUsernames) {
|
||||
tableId = UUID.randomUUID();
|
||||
this.roomId = roomId;
|
||||
this.numSeats = playerTypes.size();
|
||||
|
|
@ -96,6 +99,7 @@ public class Table implements Serializable {
|
|||
createSeats(playerTypes);
|
||||
this.validator = validator;
|
||||
this.recorder = recorder;
|
||||
this.bannedUsernames = new HashSet<>(bannedUsernames);
|
||||
}
|
||||
|
||||
private void createSeats(List<String> playerTypes) {
|
||||
|
|
@ -308,6 +312,10 @@ public class Table implements Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean userIsBanned(String username) {
|
||||
return bannedUsernames.contains(username);
|
||||
}
|
||||
|
||||
public TableProto toProto() {
|
||||
TableProto.Builder builder = TableProto.newBuilder();
|
||||
if (this.isTournament()) {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,9 @@ package mage.game.match;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import mage.constants.MatchTimeLimit;
|
||||
import mage.constants.MultiplayerAttackOption;
|
||||
import mage.constants.RangeOfInfluence;
|
||||
|
|
@ -61,6 +63,7 @@ public class MatchOptions implements Serializable {
|
|||
protected int edhPowerLevel;
|
||||
protected boolean rated;
|
||||
protected int numSeatsForMatch;
|
||||
protected Set<String> bannedUsers = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Time each player has during the game to play using his\her priority.
|
||||
|
|
@ -226,6 +229,14 @@ public class MatchOptions implements Serializable {
|
|||
this.rated = rated;
|
||||
}
|
||||
|
||||
public Set<String> getBannedUsers() {
|
||||
return bannedUsers;
|
||||
}
|
||||
|
||||
public void setBannedUsers(Set<String> bannedUsers) {
|
||||
this.bannedUsers = bannedUsers;
|
||||
}
|
||||
|
||||
public ResultProtos.MatchOptionsProto toProto() {
|
||||
ResultProtos.MatchOptionsProto.Builder builder = ResultProtos.MatchOptionsProto.newBuilder()
|
||||
.setName(this.getName())
|
||||
|
|
|
|||
|
|
@ -3067,7 +3067,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
|
||||
@Override
|
||||
public boolean canJoinTable(Table table) {
|
||||
return true;
|
||||
return !table.userIsBanned(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue