reformatted project
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
package eu.mhsl.minenet.minigames.message.component;
|
||||
|
||||
|
||||
public class NamespacedTranslatable {
|
||||
private final String namespace;
|
||||
|
||||
public NamespacedTranslatable(String namespace) {
|
||||
this.namespace = namespace;
|
||||
}
|
||||
|
||||
public TranslatedComponent get(String mapId) {
|
||||
return TranslatedComponent.byId(namespace + mapId);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,10 @@ public class TranslatedComponent implements ComponentLike, Translatable {
|
||||
private NamedTextColor color;
|
||||
private int wrap = 0;
|
||||
|
||||
private TranslatedComponent(String mapId) {
|
||||
this.mapId = mapId;
|
||||
}
|
||||
|
||||
public static TranslatedComponent byId(String mapId) {
|
||||
return new TranslatedComponent(mapId);
|
||||
}
|
||||
@@ -26,20 +30,17 @@ public class TranslatedComponent implements ComponentLike, Translatable {
|
||||
return new TranslatedComponent(mapid).getAssembled(p);
|
||||
}
|
||||
|
||||
private TranslatedComponent(String mapId) {
|
||||
this.mapId = mapId;
|
||||
}
|
||||
|
||||
public void assemble(Player p) {
|
||||
result = Languages.getInstance().getLanguage(p).getEntry(mapId);
|
||||
if(wrap > 0) {
|
||||
result = WordUtils.wrap(result, wrap, "\n", false);
|
||||
this.result = Languages.getInstance().getLanguage(p).getEntry(this.mapId);
|
||||
if(this.wrap > 0) {
|
||||
this.result = WordUtils.wrap(this.result, this.wrap, "\n", false);
|
||||
}
|
||||
}
|
||||
|
||||
public TranslatedComponent addWrap() {
|
||||
return this.addWrap(30);
|
||||
}
|
||||
|
||||
public TranslatedComponent addWrap(int wrap) {
|
||||
this.wrap = wrap;
|
||||
return this;
|
||||
@@ -47,12 +48,12 @@ public class TranslatedComponent implements ComponentLike, Translatable {
|
||||
|
||||
public Component getAssembled(Player p) {
|
||||
this.assemble(p);
|
||||
return asComponent();
|
||||
return this.asComponent();
|
||||
}
|
||||
|
||||
public List<Component> getWrappedAssembled(Player p) {
|
||||
this.assemble(p);
|
||||
return asWrappedComponent();
|
||||
return this.asWrappedComponent();
|
||||
}
|
||||
|
||||
public TranslatedComponent setColor(NamedTextColor color) {
|
||||
@@ -62,16 +63,16 @@ public class TranslatedComponent implements ComponentLike, Translatable {
|
||||
|
||||
@Override
|
||||
public @NotNull Component asComponent() {
|
||||
return this.componentFromString(result);
|
||||
return this.componentFromString(this.result);
|
||||
}
|
||||
|
||||
public List<Component> asWrappedComponent() {
|
||||
return Arrays.stream(result.split("\n")).map(this::componentFromString).toList();
|
||||
return Arrays.stream(this.result.split("\n")).map(this::componentFromString).toList();
|
||||
}
|
||||
|
||||
private Component componentFromString(String data) {
|
||||
if(color != null)
|
||||
return Component.text(data, color);
|
||||
if(this.color != null)
|
||||
return Component.text(data, this.color);
|
||||
else
|
||||
return Component.text(data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user