forked from External/mage
* UI: ignore list improved:
* Added support of usernames with spaces (#6305); * Increased max limit from 50 to 100; * Added list size info on connection or command usage;
This commit is contained in:
parent
299be53e7a
commit
f50bc8f36f
7 changed files with 62 additions and 47 deletions
|
|
@ -7,18 +7,25 @@ import mage.interfaces.callback.ClientCallback;
|
|||
import mage.interfaces.callback.ClientCallbackMethod;
|
||||
import mage.view.ChatMessage;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
public final class LocalCommands {
|
||||
|
||||
|
||||
private LocalCommands(){}
|
||||
private LocalCommands() {
|
||||
}
|
||||
|
||||
private static String getRemainingTokens(StringTokenizer st) {
|
||||
List<String> list = new ArrayList<>();
|
||||
while (st.hasMoreTokens()) {
|
||||
list.add(st.nextToken());
|
||||
}
|
||||
return String.join(" ", list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for commands that do not require server interaction, i.e settings etc
|
||||
*
|
||||
* @param chatId
|
||||
* @param text
|
||||
* @return true if the command was handled locally, else false
|
||||
|
|
@ -33,15 +40,16 @@ public final class LocalCommands {
|
|||
final String serverAddress = SessionHandler.getSession().getServerHostname().orElseGet(() -> "");
|
||||
Optional<String> response = Optional.empty();
|
||||
|
||||
switch (st.nextToken()) {
|
||||
String command = st.nextToken();
|
||||
switch (command) {
|
||||
case "/ignore":
|
||||
case "\\ignore":
|
||||
final String ignoreTarget = tokens > 1 ? st.nextToken() : "";
|
||||
final String ignoreTarget = getRemainingTokens(st);
|
||||
response = Optional.of(IgnoreList.ignore(serverAddress, ignoreTarget));
|
||||
break;
|
||||
case "/unignore":
|
||||
case "\\unignore":
|
||||
final String unignoreTarget = tokens > 1 ? st.nextToken() : "";
|
||||
final String unignoreTarget = getRemainingTokens(st);
|
||||
response = Optional.of(IgnoreList.unignore(serverAddress, unignoreTarget));
|
||||
break;
|
||||
// TODO: move profanity settings to here
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue