after sleeping, what the FUCK was I doing

This commit is contained in:
yourfriendoss 2024-04-01 10:48:59 +03:00
parent 9b29920612
commit 8b33abd7e2

View file

@ -17,31 +17,19 @@ import lv.pi.animalrp.util.Mood;
import net.kyori.adventure.audience.Audience; import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextColor;
import lv.pi.animalrp.AnimalRP; import lv.pi.animalrp.AnimalRP;
class CustomChatRenderer implements ChatRenderer { class CustomChatRenderer implements ChatRenderer {
Animal animal; String message;
String name;
public CustomChatRenderer(Animal animal, String name) { public CustomChatRenderer(String message) {
this.animal = animal; this.message = message;
this.name = name;
} }
@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 msg = message; return AnimalRP.mm.deserialize(this.message);
if(animal != null) {
msg = AnimalRP.mm.deserialize(animal.chatTransformations(AnimalRP.mm.serialize(message)));
}
return AnimalRP.mm.deserialize(this.name)
.append(Component.text(":"))
.appendSpace()
.append(msg);
} }
}; };
@ -66,28 +54,17 @@ public class PlayerChat implements Listener {
} }
} }
String name = event.getPlayer().getName(); String format = "%prefix%teamColor%animalColor%name%suffix: %message";
if(team != null) { String message = format;
name = "<"+team.color().asHexString()+">"+name;
}
if(animal != null) { message = message.replaceAll("%prefix", AnimalRP.vaultChat.getPlayerPrefix(event.getPlayer()));
name = "<"+animal.color+">"+name; message = message.replaceAll("%suffix", AnimalRP.vaultChat.getPlayerSuffix(event.getPlayer()));
} message = message.replaceAll("%teamColor", team == null ? "" : "<" + team.color().asHexString() + ">");
message = message.replaceAll("%animalColor", (animal != null && !chatModOff) ? "<" + animal.color + ">" : "");
message = message.replaceAll("%name", event.getPlayer().getName());
message = message.replaceAll("%message", (animal != null && !chatModOff) ? animal.chatTransformations(AnimalRP.mm.serialize(event.message())) : AnimalRP.mm.serialize(event.message()));
if(AnimalRP.vaultChat != null) { event.renderer(new CustomChatRenderer(message));
String suffix = AnimalRP.vaultChat.getPlayerSuffix(event.getPlayer());
if(suffix != null) {
name = name + suffix;
}
String prefix = AnimalRP.vaultChat.getPlayerPrefix(event.getPlayer());
if(prefix != null) {
name = prefix + name;
}
}
event.renderer(new CustomChatRenderer(chatModOff ? null : animal, name + "<reset>"));
} }
} }