Merge pull request #16 from PhallenCassidy/gameHall
Minor changes to game hall
This commit is contained in:
@@ -90,8 +90,10 @@ public class ChatRoomMediator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(String playerId, String message, boolean admin) throws PrivateInformationException, ChatCommandErrorException {
|
public void sendMessage(String playerId, String message, boolean admin) throws PrivateInformationException, ChatCommandErrorException {
|
||||||
if (processIfKnownCommand(playerId, message, admin))
|
if (message.startsWith("/")) {
|
||||||
|
processIfKnownCommand(playerId, message.substring(1), admin);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_lock.writeLock().lock();
|
_lock.writeLock().lock();
|
||||||
try {
|
try {
|
||||||
@@ -123,26 +125,23 @@ public class ChatRoomMediator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean processIfKnownCommand(String playerId, String message, boolean admin) throws ChatCommandErrorException {
|
private void processIfKnownCommand(String playerId, String commandString, boolean admin) throws ChatCommandErrorException {
|
||||||
if (message.startsWith("/")) {
|
int spaceIndex = commandString.indexOf(" ");
|
||||||
// Maybe it's a known command
|
String commandName;
|
||||||
String commandString = message.substring(1);
|
String commandParameters="";
|
||||||
int spaceIndex = commandString.indexOf(" ");
|
if (spaceIndex>-1) {
|
||||||
String commandName;
|
commandName = commandString.substring(0, spaceIndex);
|
||||||
String commandParameters="";
|
commandParameters = commandString.substring(spaceIndex+1);
|
||||||
if (spaceIndex>-1) {
|
} else {
|
||||||
commandName = commandString.substring(0, spaceIndex);
|
commandName = commandString;
|
||||||
commandParameters = commandString.substring(spaceIndex+1);
|
}
|
||||||
} else {
|
final ChatCommandCallback callbackForCommand = _chatCommandCallbacks.get(commandName.toLowerCase());
|
||||||
commandName = commandString;
|
if (callbackForCommand != null) {
|
||||||
}
|
callbackForCommand.commandReceived(playerId, commandParameters, admin);
|
||||||
final ChatCommandCallback callbackForCommand = _chatCommandCallbacks.get(commandName.toLowerCase());
|
} else {
|
||||||
if (callbackForCommand != null) {
|
ChatCommandCallback callbackForNoCommand = _chatCommandCallbacks.get("nocommand");
|
||||||
callbackForCommand.commandReceived(playerId, commandParameters, admin);
|
callbackForNoCommand.commandReceived(playerId, commandString, false);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanup() {
|
public void cleanup() {
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ public class HallServer extends AbstractServer {
|
|||||||
|
|
||||||
tableHolder = new TableHolder(leagueService, ignoreDAO);
|
tableHolder = new TableHolder(leagueService, ignoreDAO);
|
||||||
|
|
||||||
_hallChat = _chatServer.createChatRoom("Game Hall", true, 15, true,
|
_hallChat = _chatServer.createChatRoom("Game Hall", true, 300, true,
|
||||||
"You're now in the Game Hall, use /help to get a list of available commands.<br>Don't forget to check out the new Discord chat integration! Click the 'Switch to Discord' button in the lower right ---->");
|
"You're now in the Game Hall, use /help to get a list of available commands.<br>Don't forget to check out the new Discord chat integration! Click the 'Switch to Discord' button in the lower right ---->");
|
||||||
_hallChat.addChatCommandCallback("ban",
|
_hallChat.addChatCommandCallback("ban",
|
||||||
new ChatCommandCallback() {
|
new ChatCommandCallback() {
|
||||||
@@ -132,9 +132,33 @@ public class HallServer extends AbstractServer {
|
|||||||
final String playerName = parameters.trim();
|
final String playerName = parameters.trim();
|
||||||
if (playerName.length() >= 2 && playerName.length() <= 10) {
|
if (playerName.length() >= 2 && playerName.length() <= 10) {
|
||||||
if (!from.equals(playerName) && ignoreDAO.addIgnoredUser(from, playerName)) {
|
if (!from.equals(playerName) && ignoreDAO.addIgnoredUser(from, playerName)) {
|
||||||
_hallChat.sendToUser(from, from, "/ignore " + playerName);
|
|
||||||
_hallChat.sendToUser("System", from, "User " + playerName + " added to ignore list");
|
_hallChat.sendToUser("System", from, "User " + playerName + " added to ignore list");
|
||||||
|
} else if (from.equals(playerName)) {
|
||||||
|
_hallChat.sendToUser(from, from, "You don't have any friends. Nobody likes you.");
|
||||||
|
_hallChat.sendToUser(from, from, "Not listening. Not listening!");
|
||||||
|
_hallChat.sendToUser(from, from, "You're a liar and a thief.");
|
||||||
|
_hallChat.sendToUser(from, from, "Nope.");
|
||||||
|
_hallChat.sendToUser(from, from, "Murderer!");
|
||||||
|
_hallChat.sendToUser(from, from, "Go away. Go away!");
|
||||||
|
_hallChat.sendToUser(from, from, "Hahahaha!");
|
||||||
|
_hallChat.sendToUser(from, from, "I hate you, I hate you.");
|
||||||
|
_hallChat.sendToUser(from, from, "Where would you be without me? Gollum, Gollum. I saved us. It was me. We survived because of me!");
|
||||||
|
_hallChat.sendToUser(from, from, "Not anymore.");
|
||||||
|
_hallChat.sendToUser(from, from, "What did you say?");
|
||||||
|
_hallChat.sendToUser(from, from, "Master looks after us now. We don't need you.");
|
||||||
|
_hallChat.sendToUser(from, from, "What?");
|
||||||
|
_hallChat.sendToUser(from, from, "Leave now and never come back.");
|
||||||
|
_hallChat.sendToUser(from, from, "No!");
|
||||||
|
_hallChat.sendToUser(from, from, "Leave now and never come back!");
|
||||||
|
_hallChat.sendToUser(from, from, "Argh!");
|
||||||
|
_hallChat.sendToUser(from, from, "Leave NOW and NEVER COME BACK!");
|
||||||
|
_hallChat.sendToUser(from, from, "...");
|
||||||
|
_hallChat.sendToUser(from, from, "We... We told him to go away! And away he goes, preciouss! Gone, gone, gone! Smeagol is free!");
|
||||||
|
} else {
|
||||||
|
_hallChat.sendToUser("System", from, "User " + playerName + " is already on your ignore list");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
_hallChat.sendToUser("System", from, playerName + " is not a valid username");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -145,9 +169,12 @@ public class HallServer extends AbstractServer {
|
|||||||
final String playerName = parameters.trim();
|
final String playerName = parameters.trim();
|
||||||
if (playerName.length() >= 2 && playerName.length() <= 10) {
|
if (playerName.length() >= 2 && playerName.length() <= 10) {
|
||||||
if (ignoreDAO.removeIgnoredUser(from, playerName)) {
|
if (ignoreDAO.removeIgnoredUser(from, playerName)) {
|
||||||
_hallChat.sendToUser(from, from, "/unignore " + playerName);
|
|
||||||
_hallChat.sendToUser("System", from, "User " + playerName + " removed from ignore list");
|
_hallChat.sendToUser("System", from, "User " + playerName + " removed from ignore list");
|
||||||
|
} else {
|
||||||
|
_hallChat.sendToUser("System", from, "User " + playerName + " wasn't on your ignore list. Try ignoring them first.");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
_hallChat.sendToUser("System", from, playerName + " is not a valid username");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -156,7 +183,6 @@ public class HallServer extends AbstractServer {
|
|||||||
@Override
|
@Override
|
||||||
public void commandReceived(String from, String parameters, boolean admin) throws ChatCommandErrorException {
|
public void commandReceived(String from, String parameters, boolean admin) throws ChatCommandErrorException {
|
||||||
final Set<String> ignoredUsers = ignoreDAO.getIgnoredUsers(from);
|
final Set<String> ignoredUsers = ignoreDAO.getIgnoredUsers(from);
|
||||||
_hallChat.sendToUser(from, from, "/listIgnores");
|
|
||||||
_hallChat.sendToUser("System", from, "Your ignores: " + Arrays.toString(ignoredUsers.toArray(new String[0])));
|
_hallChat.sendToUser("System", from, "Your ignores: " + Arrays.toString(ignoredUsers.toArray(new String[0])));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -165,7 +191,6 @@ public class HallServer extends AbstractServer {
|
|||||||
@Override
|
@Override
|
||||||
public void commandReceived(String from, String parameters, boolean admin) throws ChatCommandErrorException {
|
public void commandReceived(String from, String parameters, boolean admin) throws ChatCommandErrorException {
|
||||||
_hallChat.setIncognito(from, true);
|
_hallChat.setIncognito(from, true);
|
||||||
_hallChat.sendToUser(from, from, "/incognito");
|
|
||||||
_hallChat.sendToUser("System", from, "You are now incognito (do not appear in user list)");
|
_hallChat.sendToUser("System", from, "You are now incognito (do not appear in user list)");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -174,7 +199,6 @@ public class HallServer extends AbstractServer {
|
|||||||
@Override
|
@Override
|
||||||
public void commandReceived(String from, String parameters, boolean admin) throws ChatCommandErrorException {
|
public void commandReceived(String from, String parameters, boolean admin) throws ChatCommandErrorException {
|
||||||
_hallChat.setIncognito(from, false);
|
_hallChat.setIncognito(from, false);
|
||||||
_hallChat.sendToUser(from, from, "/endIncognito");
|
|
||||||
_hallChat.sendToUser("System", from, "You are no longer incognito");
|
_hallChat.sendToUser("System", from, "You are no longer incognito");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -196,6 +220,13 @@ public class HallServer extends AbstractServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
_hallChat.addChatCommandCallback("nocommand",
|
||||||
|
new ChatCommandCallback() {
|
||||||
|
@Override
|
||||||
|
public void commandReceived(String from, String parameters, boolean admin) throws ChatCommandErrorException {
|
||||||
|
_hallChat.sendToUser("System", from, "\"" + parameters + "\" is not a recognized command.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
_tournamentQueues.put("fotr_queue", new ImmediateRecurringQueue(1500, "fotr_block",
|
_tournamentQueues.put("fotr_queue", new ImmediateRecurringQueue(1500, "fotr_block",
|
||||||
CollectionType.ALL_CARDS, "fotrQueue-", "Fellowship Block", 4,
|
CollectionType.ALL_CARDS, "fotrQueue-", "Fellowship Block", 4,
|
||||||
|
|||||||
Reference in New Issue
Block a user