Added translation to all Components
This commit is contained in:
@ -30,7 +30,7 @@ public abstract class TranslatableMessage implements Sendable {
|
||||
}
|
||||
|
||||
public TranslatableMessage appendTranslated(String mapId) {
|
||||
chain.add(TranslatedComponent.raw(mapId));
|
||||
chain.add(TranslatedComponent.byId(mapId));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,6 @@ public class NamespacedTranslatable {
|
||||
}
|
||||
|
||||
public TranslatedComponent get(String mapId) {
|
||||
return TranslatedComponent.raw(namespace + mapId);
|
||||
return TranslatedComponent.byId(namespace + mapId);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package eu.mhsl.minenet.minigames.message.component;
|
||||
import eu.mhsl.minenet.minigames.lang.Languages;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.ComponentLike;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.minestom.server.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -10,10 +11,16 @@ public class TranslatedComponent implements ComponentLike, Translatable {
|
||||
private String mapId;
|
||||
private String result;
|
||||
|
||||
public static TranslatedComponent raw(String mapId) {
|
||||
private NamedTextColor color;
|
||||
|
||||
public static TranslatedComponent byId(String mapId) {
|
||||
return new TranslatedComponent(mapId);
|
||||
}
|
||||
|
||||
public static Component assemble(String mapid, Player p) {
|
||||
return new TranslatedComponent(mapid).getAssembled(p);
|
||||
}
|
||||
|
||||
private TranslatedComponent(String mapId) {
|
||||
this.mapId = mapId;
|
||||
}
|
||||
@ -31,9 +38,17 @@ public class TranslatedComponent implements ComponentLike, Translatable {
|
||||
return asComponent();
|
||||
}
|
||||
|
||||
public TranslatedComponent setColor(NamedTextColor color) {
|
||||
this.color = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Component asComponent() {
|
||||
assemble(Languages.getInstance().getLanguage(Languages.defaultLanguage).getEntry(mapId));
|
||||
return Component.text(result);
|
||||
//assemble(Languages.getInstance().getLanguage(Languages.defaultLanguage).getEntry(mapId));
|
||||
if(color != null)
|
||||
return Component.text(result, color);
|
||||
else
|
||||
return Component.text(result);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user