Better prespace system for chatmessages

This commit is contained in:
Elias Müller 2023-10-01 01:40:31 +02:00
parent 8304b6a105
commit de79433c32
5 changed files with 20 additions and 12 deletions
build/tmp/compileJava
src/main/java/eu/mhsl/minenet/minigames
Main.java
command/privileged
message/type
score

@ -15,7 +15,6 @@ import java.util.logging.Logger;
public class Main {
/**
* Starts minenet minigames services
* @param args startflags
*/
private final static Logger logger = Logger.getGlobal();
public static void main(String[] args) {
@ -24,7 +23,7 @@ public class Main {
MinecraftServer server = MinecraftServer.init();
PvpExtension.init();
MinecraftServer.setBrandName("minenet");
MinecraftServer.setBrandName("mhsl.eu - minenet - credits to minestom");
MinecraftServer.setCompressionThreshold(0);
System.setProperty("minestom.chunk-view-distance", "12");

@ -26,7 +26,7 @@ public class DebugCommand extends Command {
add("Test");
}
};
new ChatMessage(Icon.STAR)
new ChatMessage(Icon.STAR, true)
.appendTranslated("score#result")
.newLine()
.indent()

@ -5,16 +5,25 @@ import eu.mhsl.minenet.minigames.message.TranslatableMessage;
import net.minestom.server.entity.Player;
public class ChatMessage extends TranslatableMessage {
public ChatMessage(Icon icon) {
super.appendStatic(" ");
pipe();
super.appendStatic("\n");
appendStatic(icon.getComponent());
pipe();
public ChatMessage() {
construct(Icon.CHAT, false);
}
public ChatMessage() {
appendStatic(Icon.CHAT.getComponent());
public ChatMessage(Icon icon) {
construct(icon, false);
}
public ChatMessage(Icon icon, boolean preSpace) {
construct(icon, preSpace);
}
private void construct(Icon icon, boolean preSpace) {
if(preSpace) {
super.appendStatic(" ");
pipe();
super.appendStatic("\n");
}
appendStatic(icon.getComponent());
pipe();
}

@ -31,7 +31,7 @@ public abstract class Score {
public void setDone() {
isDone = true;
new ChatMessage(Icon.STAR)
new ChatMessage(Icon.STAR, true)
.appendTranslated("score#result")
.newLine()
.indent()