Refactored chat messaging api

This commit is contained in:
2023-09-30 23:31:36 +02:00
parent 3489800f28
commit cbe16a669c
9 changed files with 78 additions and 18 deletions

View File

@@ -6,6 +6,9 @@ import eu.mhsl.minenet.minigames.message.type.ChatMessage;
import eu.mhsl.minenet.minigames.message.type.TitleMessage;
import net.minestom.server.command.builder.Command;
import java.util.ArrayList;
import java.util.List;
public class DebugCommand extends Command {
public DebugCommand() {
super("debug");
@@ -16,6 +19,22 @@ public class DebugCommand extends Command {
new ChatMessage(Icon.CHAT).appendTranslated("sample").send(sender);
new ActionBarMessage().appendTranslated("sample").send(sender);
new TitleMessage().subtitle(subtitleMessage -> subtitleMessage.appendTranslated("sample")).appendTranslated("sample").send(sender);
List<String> testplayers = new ArrayList<>() {
{
add("MineTec");
add("Goldi187");
add("Test");
}
};
new ChatMessage(Icon.STAR)
.appendTranslated("score#result")
.newLine()
.appendStatic("Test")
.appendStatic("Test")
.indent()
.list(testplayers)
.appendTranslated("score#thanks")
.send(sender);
});
}

View File

@@ -25,9 +25,9 @@ public class GcCommand extends Command {
System.gc();
long after = Monitoring.getRamUsage();
new ChatMessage(Icon.SUCCESS).appendStatic("Garbage collector ran successfully!").indent(1).newLine()
new ChatMessage(Icon.SUCCESS).appendStatic("Garbage collector ran successfully!").newLine()
.appendStatic("before: ").appendStatic(String.valueOf(before)).appendStatic("MB").newLine()
.appendStatic("now: ").appendStatic(String.valueOf(after)).appendStatic("MB").indent(1).newLine()
.appendStatic("now: ").appendStatic(String.valueOf(after)).appendStatic("MB").newLine()
.appendStatic("difference: ").appendStatic(String.valueOf(before-after)).appendStatic("MB")
.send(sender);
});

View File

@@ -16,13 +16,13 @@ public class RoomCommand extends Command {
setCondition((sender, commandString) -> sender.hasPermission("admin"));
setDefaultExecutor((sender, context) -> {
TranslatableMessage out = new ChatMessage(Icon.SCIENCE).appendStatic("Rooms:").indent(1).newLine();
TranslatableMessage out = new ChatMessage(Icon.SCIENCE).appendStatic("Rooms:").newLine();
Room.getAllRooms().forEach((roomInstance) -> out
.newLine()
.appendStatic("Owner: ").appendStatic(roomInstance.getOwner().getUsername()).newLine()
.appendStatic("Players: ").appendStatic(String.valueOf(roomInstance.getAllMembers().size())).indent(1).newLine()
.list(roomInstance.getAllMembers().stream().map(Player::getUsername).collect(Collectors.toList())).indent(-1).newLine());
.appendStatic("Players: ").appendStatic(String.valueOf(roomInstance.getAllMembers().size())).newLine()
.list(roomInstance.getAllMembers().stream().map(Player::getUsername).collect(Collectors.toList())).newLine());
out.send(sender);
});