Made system commands case insensitive and reworked /dabr mechanism

This commit is contained in:
delvh 2020-08-01 21:40:20 +02:00
parent 56bb00cd32
commit c3dfedc642
2 changed files with 21 additions and 5 deletions

View File

@ -37,7 +37,9 @@ public final class SystemCommandsMap {
* @see SystemCommandsMap#isValidKey(String) * @see SystemCommandsMap#isValidKey(String)
* @since Envoy Client v0.2-beta * @since Envoy Client v0.2-beta
*/ */
public void add(String command, SystemCommand systemCommand) { if (isValidKey(command)) systemCommands.put(command, systemCommand); } public void add(String command, SystemCommand systemCommand) {
if (isValidKey(command)) systemCommands.put(command.toLowerCase(), systemCommand);
}
/** /**
* This method checks if the input String is a key in the map and returns the * This method checks if the input String is a key in the map and returns the
@ -60,7 +62,7 @@ public final class SystemCommandsMap {
* @return the wrapped system command, if present * @return the wrapped system command, if present
* @since Envoy Client v0.2-beta * @since Envoy Client v0.2-beta
*/ */
public Optional<SystemCommand> get(String input) { return Optional.ofNullable(systemCommands.get(getCommand(input))); } public Optional<SystemCommand> get(String input) { return Optional.ofNullable(systemCommands.get(getCommand(input.toLowerCase()))); }
/** /**
* This method ensures that the "/" of a {@link SystemCommand} is stripped.<br> * This method ensures that the "/" of a {@link SystemCommand} is stripped.<br>

View File

@ -10,9 +10,11 @@ import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.Random; import java.util.Random;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.stream.Collectors;
import javafx.animation.RotateTransition; import javafx.animation.RotateTransition;
import javafx.application.Platform; import javafx.application.Platform;
@ -423,9 +425,21 @@ public final class ChatScene implements Restorable {
* @since Envoy Client v0.1-beta * @since Envoy Client v0.1-beta
*/ */
private void doABarrelRoll(int rotations, double animationTime) { private void doABarrelRoll(int rotations, double animationTime) {
// contains all Node objects in ChatScene in alphabetical order // Limiting the rotations and duration
final var rotatableNodes = new Node[] { attachmentButton, attachmentView, contactLabel, infoLabel, messageList, messageTextArea, postButton, rotations = Math.min(rotations, 100000);
remainingChars, rotateButton, scene, settingsButton, chatList, voiceButton }; rotations = Math.max(rotations, 1);
animationTime = Math.min(animationTime, 150);
animationTime = Math.max(animationTime, 0.25);
// contains all Node objects in ChatScene
final var rotatableNodes = Arrays.stream(ChatScene.class.getDeclaredFields()).map(field -> {
try {
return field.get(this);
} catch (IllegalArgumentException | IllegalAccessException e1) {
// In this case, this option can never be executed
return null;
}
}).filter(Node.class::isInstance).map(Node.class::cast).collect(Collectors.toList());
for (final var node : rotatableNodes) { for (final var node : rotatableNodes) {
// Sets the animation duration to {animationTime} // Sets the animation duration to {animationTime}
final var rotateTransition = new RotateTransition(Duration.seconds(animationTime), node); final var rotateTransition = new RotateTransition(Duration.seconds(animationTime), node);