Did some refactoring of code; also added support for name color changes of operators

This commit is contained in:
BlueFox 2024-05-21 14:50:11 +02:00
parent eb429dfaed
commit 25a99b8a3c
2 changed files with 26 additions and 9 deletions

View File

@ -6,7 +6,7 @@
<groupId>de.privacynerd</groupId>
<artifactId>ChatBeautifier</artifactId>
<version>0.2.3</version>
<version>0.2.4</version>
<packaging>jar</packaging>
<name>ChatBeautifier</name>

View File

@ -94,14 +94,19 @@ public class ChatColorCommand implements CommandExecutor {
ArrayList<String> colorNames = ChatColorUtils.getChooseColorStrings();
// now compose the message containing all possible color args
Component message = Component.text("Mögliche Farben: ").decoration(TextDecoration.BOLD, true);
Component message = Component.text("Mögliche Farben: ")
.decoration(TextDecoration.BOLD, true);
String newMessageItem = colorNames.get(0).toLowerCase().replace(" ", "-") + ", ";
message = message.append(Component.text(newMessageItem, NamedTextColor.GRAY).decoration(TextDecoration.BOLD, true));
String newMessageItem = colorNames.get(0).toLowerCase().replace(" ", "-");
message = message.append(Component.text(newMessageItem, NamedTextColor.GRAY)
.decoration(TextDecoration.BOLD, false)
.decoration(TextDecoration.ITALIC, true));
for (int i=1; i<colorNames.toArray().length; i++) {
newMessageItem = colorNames.get(i).toLowerCase().replace(" ", "-") + ", ";
message = message.append(Component.text(newMessageItem, NamedTextColor.GRAY).decoration(TextDecoration.BOLD, true));
newMessageItem = ", " + colorNames.get(i).toLowerCase().replace(" ", "-");
message = message.append(Component.text(newMessageItem, NamedTextColor.GRAY)
.decoration(TextDecoration.BOLD, false)
.decoration(TextDecoration.ITALIC, true));
}
// and send it
@ -117,13 +122,25 @@ public class ChatColorCommand implements CommandExecutor {
return true;
}
newDisplayName = player.displayName()
.color(ChatColorUtils.getChooseColorCodes().get(colorCodesListIndex));
if(player.isOp()) {
newDisplayName = Component.text("[OP] ")
.color(NamedTextColor.RED)
.decoration(TextDecoration.BOLD, true)
.append(Component.text(player.getName())
.color(ChatColorUtils.getChooseColorCodes().get(colorCodesListIndex))
.decoration(TextDecoration.BOLD, false)
);
} else {
newDisplayName = player.displayName()
.color(ChatColorUtils.getChooseColorCodes().get(colorCodesListIndex));
}
player.displayName(newDisplayName);
player.playerListName(newDisplayName);
ChatBeautifier.INSTANCE.log("Got valid color " + validArgument);
ChatBeautifier.INSTANCE.tellPlayer("Name temporär " + validArgument + " gefärbt. Dieses Feature ist aktuell noch in der Mache, dauerhaft coming soon.", player);
ChatBeautifier.INSTANCE.tellPlayer(Component.text("Dein neuer Name: ")
.append(player.displayName()
), player);
return true;
} else if (args.length > 1) { // print a help string if more than one argument is given
ChatBeautifier.INSTANCE.tellPlayer("Verwendung: /" + alias + " [<color>, list, gui]", player);