rewrite suffix/prefix
This commit is contained in:
parent
97dd6ea316
commit
aa5c42761a
|
@ -22,39 +22,23 @@ import lv.pi.animalrp.AnimalRP;
|
||||||
|
|
||||||
class CustomChatRenderer implements ChatRenderer {
|
class CustomChatRenderer implements ChatRenderer {
|
||||||
Animal animal;
|
Animal animal;
|
||||||
Team team;
|
String name;
|
||||||
Component suffix;
|
|
||||||
Component prefix;
|
|
||||||
|
|
||||||
public CustomChatRenderer(Animal animal, Team team, Component suffix, Component prefix) {
|
public CustomChatRenderer(Animal animal, String name) {
|
||||||
this.animal = animal;
|
this.animal = animal;
|
||||||
this.team = team;
|
this.name = name;
|
||||||
this.suffix = suffix;
|
|
||||||
this.prefix = prefix;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Component render(@NotNull Player source, @NotNull Component sourceDisplayName, @NotNull Component message,
|
public @NotNull Component render(@NotNull Player source, @NotNull Component sourceDisplayName, @NotNull Component message,
|
||||||
@NotNull Audience viewer) {
|
@NotNull Audience viewer) {
|
||||||
Component name = sourceDisplayName;
|
|
||||||
|
|
||||||
if(team != null) {
|
|
||||||
name = name.color(team.color());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(animal != null) {
|
|
||||||
name = name.color(TextColor.fromHexString(animal.color));
|
|
||||||
}
|
|
||||||
|
|
||||||
Component msg = message;
|
Component msg = message;
|
||||||
|
|
||||||
if(animal != null) {
|
if(animal != null) {
|
||||||
msg = AnimalRP.mm.deserialize(animal.chatTransformations(AnimalRP.mm.serialize(message)));
|
msg = AnimalRP.mm.deserialize(animal.chatTransformations(AnimalRP.mm.serialize(message)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.prefix
|
return AnimalRP.mm.deserialize(this.name)
|
||||||
.append(name)
|
|
||||||
.append(this.suffix)
|
|
||||||
.append(Component.text(":"))
|
.append(Component.text(":"))
|
||||||
.appendSpace()
|
.appendSpace()
|
||||||
.append(msg);
|
.append(msg);
|
||||||
|
@ -82,23 +66,28 @@ public class PlayerChat implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component csuffix = Component.text("");
|
String name = event.getPlayer().getName();
|
||||||
Component cprefix = Component.text("");
|
if(team != null) {
|
||||||
|
name = "<"+team.color().asHexString()+">"+name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(animal != null) {
|
||||||
|
name = "<"+animal.color+">"+name;
|
||||||
|
}
|
||||||
|
|
||||||
if(AnimalRP.vaultChat != null) {
|
if(AnimalRP.vaultChat != null) {
|
||||||
String suffix = AnimalRP.vaultChat.getPlayerSuffix(event.getPlayer());
|
String suffix = AnimalRP.vaultChat.getPlayerSuffix(event.getPlayer());
|
||||||
String prefix = AnimalRP.vaultChat.getPlayerPrefix(event.getPlayer());
|
|
||||||
|
|
||||||
if(suffix != null) {
|
if(suffix != null) {
|
||||||
csuffix = AnimalRP.mm.deserialize(suffix);
|
name = name + suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String prefix = AnimalRP.vaultChat.getPlayerPrefix(event.getPlayer());
|
||||||
if(prefix != null) {
|
if(prefix != null) {
|
||||||
cprefix = AnimalRP.mm.deserialize(prefix);
|
name = prefix + name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event.renderer(new CustomChatRenderer(chatModOff ? null : animal, team, csuffix, cprefix));
|
event.renderer(new CustomChatRenderer(chatModOff ? null : animal, name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue