use of com.comphenix.protocol.wrappers.WrappedChatComponent in project ProtocolStringReplacer by Rothes.
the class BossBar method process.
protected void process(PacketEvent packetEvent) {
PsrUser user = getEventUser(packetEvent);
if (user == null) {
return;
}
StructureModifier<WrappedChatComponent> wrappedChatComponentStructureModifier = packetEvent.getPacket().getChatComponents();
if (wrappedChatComponentStructureModifier.size() != 0) {
WrappedChatComponent wrappedChatComponent = wrappedChatComponentStructureModifier.read(0);
String json = wrappedChatComponent.getJson();
WrappedChatComponent replaced = getReplacedJsonWrappedComponent(packetEvent, user, listenType, json, filter);
if (replaced != null) {
wrappedChatComponentStructureModifier.write(0, replaced);
}
}
}
use of com.comphenix.protocol.wrappers.WrappedChatComponent in project ProtocolStringReplacer by Rothes.
the class ScoreBoardObjective method process.
protected void process(PacketEvent packetEvent) {
PsrUser user = getEventUser(packetEvent);
if (user == null) {
return;
}
PacketContainer packet = packetEvent.getPacket();
if (packet.getIntegers().read(0) != 1) {
if (ProtocolStringReplacer.getInstance().getServerMajorVersion() > 12) {
StructureModifier<WrappedChatComponent> wrappedChatComponentStructureModifier = packet.getChatComponents();
WrappedChatComponent wrappedChatComponent = wrappedChatComponentStructureModifier.read(0);
String replaced = getReplacedJson(packetEvent, user, listenType, wrappedChatComponent.getJson(), titleFilter);
if (replaced != null) {
wrappedChatComponentStructureModifier.write(0, wrappedChatComponent);
}
} else {
StructureModifier<String> strings = packet.getStrings();
String replaced = getReplacedText(packetEvent, user, listenType, strings.read(0), titleFilter);
if (replaced != null)
strings.write(0, replaced);
}
}
}
Aggregations