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 {
|
||||
if (processIfKnownCommand(playerId, message, admin))
|
||||
if (message.startsWith("/")) {
|
||||
processIfKnownCommand(playerId, message.substring(1), admin);
|
||||
return;
|
||||
}
|
||||
|
||||
_lock.writeLock().lock();
|
||||
try {
|
||||
@@ -123,26 +125,23 @@ public class ChatRoomMediator {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean processIfKnownCommand(String playerId, String message, boolean admin) throws ChatCommandErrorException {
|
||||
if (message.startsWith("/")) {
|
||||
// Maybe it's a known command
|
||||
String commandString = message.substring(1);
|
||||
int spaceIndex = commandString.indexOf(" ");
|
||||
String commandName;
|
||||
String commandParameters="";
|
||||
if (spaceIndex>-1) {
|
||||
commandName = commandString.substring(0, spaceIndex);
|
||||
commandParameters = commandString.substring(spaceIndex+1);
|
||||
} else {
|
||||
commandName = commandString;
|
||||
}
|
||||
final ChatCommandCallback callbackForCommand = _chatCommandCallbacks.get(commandName.toLowerCase());
|
||||
if (callbackForCommand != null) {
|
||||
callbackForCommand.commandReceived(playerId, commandParameters, admin);
|
||||
return true;
|
||||
}
|
||||
private void processIfKnownCommand(String playerId, String commandString, boolean admin) throws ChatCommandErrorException {
|
||||
int spaceIndex = commandString.indexOf(" ");
|
||||
String commandName;
|
||||
String commandParameters="";
|
||||
if (spaceIndex>-1) {
|
||||
commandName = commandString.substring(0, spaceIndex);
|
||||
commandParameters = commandString.substring(spaceIndex+1);
|
||||
} else {
|
||||
commandName = commandString;
|
||||
}
|
||||
final ChatCommandCallback callbackForCommand = _chatCommandCallbacks.get(commandName.toLowerCase());
|
||||
if (callbackForCommand != null) {
|
||||
callbackForCommand.commandReceived(playerId, commandParameters, admin);
|
||||
} else {
|
||||
ChatCommandCallback callbackForNoCommand = _chatCommandCallbacks.get("nocommand");
|
||||
callbackForNoCommand.commandReceived(playerId, commandString, false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void cleanup() {
|
||||
|
||||
@@ -90,7 +90,7 @@ public class HallServer extends AbstractServer {
|
||||
|
||||
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 ---->");
|
||||
_hallChat.addChatCommandCallback("ban",
|
||||
new ChatCommandCallback() {
|
||||
@@ -132,9 +132,33 @@ public class HallServer extends AbstractServer {
|
||||
final String playerName = parameters.trim();
|
||||
if (playerName.length() >= 2 && playerName.length() <= 10) {
|
||||
if (!from.equals(playerName) && ignoreDAO.addIgnoredUser(from, playerName)) {
|
||||
_hallChat.sendToUser(from, from, "/ignore " + playerName);
|
||||
_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();
|
||||
if (playerName.length() >= 2 && playerName.length() <= 10) {
|
||||
if (ignoreDAO.removeIgnoredUser(from, playerName)) {
|
||||
_hallChat.sendToUser(from, from, "/unignore " + playerName);
|
||||
_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
|
||||
public void commandReceived(String from, String parameters, boolean admin) throws ChatCommandErrorException {
|
||||
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])));
|
||||
}
|
||||
});
|
||||
@@ -165,7 +191,6 @@ public class HallServer extends AbstractServer {
|
||||
@Override
|
||||
public void commandReceived(String from, String parameters, boolean admin) throws ChatCommandErrorException {
|
||||
_hallChat.setIncognito(from, true);
|
||||
_hallChat.sendToUser(from, from, "/incognito");
|
||||
_hallChat.sendToUser("System", from, "You are now incognito (do not appear in user list)");
|
||||
}
|
||||
});
|
||||
@@ -174,7 +199,6 @@ public class HallServer extends AbstractServer {
|
||||
@Override
|
||||
public void commandReceived(String from, String parameters, boolean admin) throws ChatCommandErrorException {
|
||||
_hallChat.setIncognito(from, false);
|
||||
_hallChat.sendToUser(from, from, "/endIncognito");
|
||||
_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",
|
||||
CollectionType.ALL_CARDS, "fotrQueue-", "Fellowship Block", 4,
|
||||
|
||||
Reference in New Issue
Block a user