Merge branch 'PlayersCouncil:master' into master
This commit is contained in:
@@ -154,5 +154,14 @@ var PCCards = {
|
||||
//August 2021
|
||||
'1_366': 'https://i.lotrtcgpc.net/promos/2021/08/PCPROMO_FA_01298.jpg',
|
||||
'1_367': 'https://i.lotrtcgpc.net/promos/2021/08/PCPROMO_FA_01349.jpg',
|
||||
//September 2021
|
||||
'9_53': 'https://i.lotrtcgpc.net/promos/2021/09/PCPROMO_FA_09033.jpg',
|
||||
'10_123':'https://i.lotrtcgpc.net/promos/2021/09/PCPROMO_FA_10123.jpg',
|
||||
//October 2021
|
||||
'1_368':'https://i.lotrtcgpc.net/promos/2021/10/PCPROMO_FA_01083.jpg',
|
||||
'1_369':'https://i.lotrtcgpc.net/promos/2021/10/PCPROMO_FA_01127.jpg',
|
||||
//November 2021
|
||||
'8_123':'https://i.lotrtcgpc.net/promos/2021/11/PCPROMO_FA_08102.jpg',
|
||||
'9_54':'https://i.lotrtcgpc.net/promos/2021/11/PCPROMO_FA_09014.jpg',
|
||||
}
|
||||
|
||||
|
||||
@@ -233,7 +233,19 @@ gl_theOneRing,1_2
|
||||
11_267,11_54
|
||||
#The Witch-king, Captain of the Nine Riders
|
||||
11_268,11_226
|
||||
#Hobbit Stealth
|
||||
#Hobbit Stealth - 2021/08
|
||||
1_366,1_298
|
||||
#Bridge of Khazad-dum
|
||||
#Bridge of Khazad-dum - 2021/08
|
||||
1_367,1_349
|
||||
#Isildur, Bearer of Heirlooms - 2021/09
|
||||
9_53,9_33
|
||||
#Shelob, Her Ladyship - 2021/09
|
||||
10_123,10_23
|
||||
#Servant of the Secret Flame - 2021/10
|
||||
1_368,1_83
|
||||
#Lurtz, Servant of Isengard - 2021/10
|
||||
1_369,1_127
|
||||
#Galadriel, Bearer of Wisdom - 2021/11
|
||||
9_54,9_14
|
||||
#Great Hill Troll - 2021/11
|
||||
8_123,8_102
|
||||
|
||||
@@ -89,7 +89,8 @@ public class ServerBuilder {
|
||||
extract(objectMap, CardSets.class)));
|
||||
|
||||
objectMap.put(ChatServer.class, new ChatServer(
|
||||
extract(objectMap, IgnoreDAO.class)));
|
||||
extract(objectMap, IgnoreDAO.class),
|
||||
extract(objectMap, PlayerDAO.class)));
|
||||
|
||||
objectMap.put(LotroServer.class,
|
||||
new LotroServer(
|
||||
|
||||
@@ -3,15 +3,18 @@ package com.gempukku.lotro.chat;
|
||||
import com.gempukku.lotro.PrivateInformationException;
|
||||
import com.gempukku.lotro.SubscriptionExpiredException;
|
||||
import com.gempukku.lotro.db.IgnoreDAO;
|
||||
import com.gempukku.lotro.db.PlayerDAO;
|
||||
import com.gempukku.lotro.game.ChatCommunicationChannel;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
public class ChatRoomMediator {
|
||||
private IgnoreDAO ignoreDAO;
|
||||
private PlayerDAO playerDAO;
|
||||
private Logger _logger;
|
||||
private ChatRoom _chatRoom;
|
||||
|
||||
@@ -25,14 +28,15 @@ public class ChatRoomMediator {
|
||||
private Map<String, ChatCommandCallback> _chatCommandCallbacks = new HashMap<String, ChatCommandCallback>();
|
||||
private String welcomeMessage;
|
||||
|
||||
public ChatRoomMediator(IgnoreDAO ignoreDAO, String roomName, boolean muteJoinPartMessages, int secondsTimeoutPeriod, boolean allowIncognito, String welcomeMessage) {
|
||||
this(ignoreDAO, roomName, muteJoinPartMessages, secondsTimeoutPeriod, null, allowIncognito);
|
||||
public ChatRoomMediator(IgnoreDAO ignoreDAO, PlayerDAO playerDAO, String roomName, boolean muteJoinPartMessages, int secondsTimeoutPeriod, boolean allowIncognito, String welcomeMessage) {
|
||||
this(ignoreDAO, playerDAO, roomName, muteJoinPartMessages, secondsTimeoutPeriod, null, allowIncognito);
|
||||
this.welcomeMessage = welcomeMessage;
|
||||
}
|
||||
|
||||
public ChatRoomMediator(IgnoreDAO ignoreDAO, String roomName, boolean muteJoinPartMessages, int secondsTimeoutPeriod, Set<String> allowedPlayers,
|
||||
public ChatRoomMediator(IgnoreDAO ignoreDAO, PlayerDAO playerDAO, String roomName, boolean muteJoinPartMessages, int secondsTimeoutPeriod, Set<String> allowedPlayers,
|
||||
boolean allowIncognito) {
|
||||
this.ignoreDAO = ignoreDAO;
|
||||
this.playerDAO = playerDAO;
|
||||
_logger = Logger.getLogger("chat."+roomName);
|
||||
_allowedPlayers = allowedPlayers;
|
||||
_channelInactivityTimeoutPeriod = 1000 * secondsTimeoutPeriod;
|
||||
@@ -43,13 +47,15 @@ public class ChatRoomMediator {
|
||||
_chatCommandCallbacks.put(command.toLowerCase(), callback);
|
||||
}
|
||||
|
||||
public List<ChatMessage> joinUser(String playerId, boolean admin) throws PrivateInformationException {
|
||||
public List<ChatMessage> joinUser(String playerId, boolean admin) throws PrivateInformationException, SQLException {
|
||||
_lock.writeLock().lock();
|
||||
try {
|
||||
if (!admin && _allowedPlayers != null && !_allowedPlayers.contains(playerId))
|
||||
throw new PrivateInformationException();
|
||||
|
||||
ChatCommunicationChannel value = new ChatCommunicationChannel(ignoreDAO.getIgnoredUsers(playerId));
|
||||
Set<String> usersToIgnore = playerDAO.getBannedUsernames();
|
||||
usersToIgnore.addAll(ignoreDAO.getIgnoredUsers(playerId));
|
||||
ChatCommunicationChannel value = new ChatCommunicationChannel(usersToIgnore);
|
||||
_listeners.put(playerId, value);
|
||||
_chatRoom.joinChatRoom(playerId, value);
|
||||
final List<ChatMessage> chatMessages = value.consumeMessages();
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.gempukku.lotro.chat;
|
||||
import com.gempukku.lotro.AbstractServer;
|
||||
import com.gempukku.lotro.PrivateInformationException;
|
||||
import com.gempukku.lotro.db.IgnoreDAO;
|
||||
import com.gempukku.lotro.db.PlayerDAO;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -10,14 +11,16 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class ChatServer extends AbstractServer {
|
||||
private IgnoreDAO ignoreDAO;
|
||||
private PlayerDAO playerDAO;
|
||||
private Map<String, ChatRoomMediator> _chatRooms = new ConcurrentHashMap<String, ChatRoomMediator>();
|
||||
|
||||
public ChatServer(IgnoreDAO ignoreDAO) {
|
||||
public ChatServer(IgnoreDAO ignoreDAO, PlayerDAO playerDAO) {
|
||||
this.ignoreDAO = ignoreDAO;
|
||||
this.playerDAO = playerDAO;
|
||||
}
|
||||
|
||||
public ChatRoomMediator createChatRoom(String name, boolean muteJoinPartMessages, int secondsTimeoutPeriod, boolean allowIncognito, String welcomeMessage) {
|
||||
ChatRoomMediator chatRoom = new ChatRoomMediator(ignoreDAO, name, muteJoinPartMessages, secondsTimeoutPeriod, allowIncognito, welcomeMessage);
|
||||
ChatRoomMediator chatRoom = new ChatRoomMediator(ignoreDAO, playerDAO, name, muteJoinPartMessages, secondsTimeoutPeriod, allowIncognito, welcomeMessage);
|
||||
try {
|
||||
chatRoom.sendMessage("System", "Welcome to room: " + name, true);
|
||||
} catch (PrivateInformationException exp) {
|
||||
@@ -30,7 +33,7 @@ public class ChatServer extends AbstractServer {
|
||||
}
|
||||
|
||||
public ChatRoomMediator createPrivateChatRoom(String name, boolean muteJoinPartMessages, Set<String> allowedUsers, int secondsTimeoutPeriod) {
|
||||
ChatRoomMediator chatRoom = new ChatRoomMediator(ignoreDAO, name, muteJoinPartMessages, secondsTimeoutPeriod, allowedUsers, false);
|
||||
ChatRoomMediator chatRoom = new ChatRoomMediator(ignoreDAO, playerDAO, name, muteJoinPartMessages, secondsTimeoutPeriod, allowedUsers, false);
|
||||
try {
|
||||
chatRoom.sendMessage("System", "Welcome to private room: " + name, true);
|
||||
} catch (PrivateInformationException exp) {
|
||||
|
||||
@@ -59,10 +59,22 @@ public class CollectionSerializer {
|
||||
//April 2021 PC Promos
|
||||
_singleByteCountItems.add("11_267");
|
||||
_singleByteCountItems.add("11_268");
|
||||
|
||||
|
||||
//August 2021 PC Promos
|
||||
_singleByteCountItems.add("1_366");
|
||||
_singleByteCountItems.add("1_367");
|
||||
|
||||
//September 2021 PC Promos
|
||||
_singleByteCountItems.add("9_53");
|
||||
_singleByteCountItems.add("10_123");
|
||||
|
||||
//October 2021 PC Promos
|
||||
_singleByteCountItems.add("1_368");
|
||||
_singleByteCountItems.add("1_369");
|
||||
|
||||
//November 2021 PC Promos
|
||||
_singleByteCountItems.add("8_123");
|
||||
_singleByteCountItems.add("9_54");
|
||||
}
|
||||
|
||||
private void fillDoubleByteItems() throws IOException {
|
||||
|
||||
@@ -5,14 +5,13 @@ import com.gempukku.lotro.game.Player;
|
||||
import org.apache.commons.collections.map.LRUMap;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
public class CachedPlayerDAO implements PlayerDAO, Cached {
|
||||
private PlayerDAO _delegate;
|
||||
private Map<Integer, Player> _playerById = Collections.synchronizedMap(new LRUMap(500));
|
||||
private Map<String, Player> _playerByName = Collections.synchronizedMap(new LRUMap(500));
|
||||
private Set<String> _bannedUsernames = new HashSet<>();
|
||||
|
||||
public CachedPlayerDAO(PlayerDAO delegate) {
|
||||
_delegate = delegate;
|
||||
@@ -22,6 +21,7 @@ public class CachedPlayerDAO implements PlayerDAO, Cached {
|
||||
public void clearCache() {
|
||||
_playerById.clear();
|
||||
_playerByName.clear();
|
||||
_bannedUsernames.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,6 +74,13 @@ public class CachedPlayerDAO implements PlayerDAO, Cached {
|
||||
return _delegate.findSimilarAccounts(login);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getBannedUsernames() throws SQLException {
|
||||
if(_bannedUsernames.isEmpty())
|
||||
_bannedUsernames = _delegate.getBannedUsernames();
|
||||
return new HashSet<>(_bannedUsernames);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer(int id) {
|
||||
Player player = (Player) _playerById.get(id);
|
||||
|
||||
@@ -7,9 +7,7 @@ import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
public class DbPlayerDAO implements PlayerDAO {
|
||||
private final String validLoginChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_";
|
||||
@@ -75,6 +73,26 @@ public class DbPlayerDAO implements PlayerDAO {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getBannedUsernames() throws SQLException {
|
||||
try {
|
||||
try (Connection connection = _dbAccess.getDataSource().getConnection()) {
|
||||
try (PreparedStatement statement = connection.prepareStatement("SELECT name FROM player WHERE type = '' ORDER BY ID DESC LIMIT 50")) {
|
||||
|
||||
try (ResultSet resultSet = statement.executeQuery()) {
|
||||
TreeSet<String> users = new TreeSet<String>();
|
||||
while (resultSet.next()) {
|
||||
users.add(resultSet.getString(1));
|
||||
}
|
||||
return users;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SQLException exp) {
|
||||
throw new RuntimeException("Unable to get banned users", exp);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean banPlayerPermanently(String login) throws SQLException {
|
||||
try (Connection conn = _dbAccess.getDataSource().getConnection()) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.gempukku.lotro.game.Player;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface PlayerDAO {
|
||||
public Player getPlayer(int id);
|
||||
@@ -20,6 +21,7 @@ public interface PlayerDAO {
|
||||
public boolean removePlayerFlag(String login, String flag) throws SQLException;
|
||||
|
||||
public List<Player> findSimilarAccounts(String login) throws SQLException;
|
||||
public Set<String> getBannedUsernames() throws SQLException;
|
||||
|
||||
public Player loginUser(String login, String password) throws SQLException;
|
||||
|
||||
|
||||
@@ -55,6 +55,14 @@
|
||||
"4_304":"54_304", "7_49":"57_49", "7_96":"57_96", "8_1":"58_1", "10_2":"60_2", "10_11":"60_11", "10_91":"60_91",
|
||||
"11_31":"61_31", "11_100":"61_100", "11_114":"61_114", "11_132":"61_132", "13_188":"63_188", "15_64":"65_64"}
|
||||
},
|
||||
{
|
||||
"name":"Pre-Hunters Expanded",
|
||||
"code":"pre-hunters_expanded",
|
||||
"sites":"SHADOWS",
|
||||
"banned":["1_45", "1_138", "1_234", "1_311", "1_313", "1_316", "2_121", "3_17", "3_38", "3_42", "3_67", "3_68", "3_108", "3_113", "4_73", "7_49", "8_1", "10_2", "10_11", "10_91", "11_31", "11_100", "11_132"],
|
||||
"restricted":["1_40", "1_80", "1_108", "1_139", "1_195", "1_248", "2_32", "2_75", "3_106", "4_276", "4_304"],
|
||||
"set":[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
|
||||
},
|
||||
{
|
||||
"name":"Fellowship block - Set 1",
|
||||
"code":"fotr1_block",
|
||||
@@ -127,6 +135,15 @@
|
||||
"banned":["1_40", "1_45", "1_80", "1_108", "1_139", "1_234", "1_248", "1_313", "2_32", "2_101", "2_108", "3_38", "3_42", "3_68", "4_192"],
|
||||
"set":[1, 2, 3, 4, 5, 6]
|
||||
},
|
||||
{
|
||||
"name":"Enhanced Towers Standard",
|
||||
"code":"ts_reflections",
|
||||
"sites":"TWO_TOWERS",
|
||||
"cancelRingBearerSkirmish":false,
|
||||
"banned":["1_40", "1_45", "1_80", "1_108", "1_139", "1_234", "1_248", "1_313", "2_32", "2_101", "2_108", "3_38", "3_42", "3_68", "4_192"],
|
||||
"set":[1, 2, 3, 4, 5, 6, 9, 14, 16],
|
||||
"hall":true
|
||||
},
|
||||
{
|
||||
"name": "Anything goes",
|
||||
"code":"rev_tow_sta",
|
||||
@@ -161,15 +178,6 @@
|
||||
"set":[2, 3, 4, 5, 6],
|
||||
"hall":false
|
||||
},
|
||||
{
|
||||
"name":"Towers standard - Sets 1-6,9,14,16",
|
||||
"code":"ts_reflections",
|
||||
"sites":"TWO_TOWERS",
|
||||
"cancelRingBearerSkirmish":false,
|
||||
"banned":["1_40", "1_45", "1_80", "1_108", "1_139", "1_234", "1_248", "1_313", "2_32", "2_101", "2_108", "3_38", "3_42", "3_68", "4_192"],
|
||||
"set":[1, 2, 3, 4, 5, 6, 9, 14, 16],
|
||||
"hall":false
|
||||
},
|
||||
{
|
||||
"name":"King Standard",
|
||||
"code":"rotk_sta",
|
||||
|
||||
Reference in New Issue
Block a user