Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
Fix helpop showing the vanilla prefix when it shouldn't
Browse files Browse the repository at this point in the history
  • Loading branch information
dualspiral committed Oct 2, 2020
1 parent aa260ef commit 638aa7e
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.spongepowered.api.event.message.MessageEvent;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.channel.MessageReceiver;
import org.spongepowered.api.text.serializer.TextSerializers;

import java.util.Collection;
import java.util.List;
Expand All @@ -39,7 +40,17 @@ public boolean willFormat() {
@Override
public void formatMessageEvent(CommandSource source, MessageEvent.MessageFormatter formatters) {
if (this.prefix != null) {
formatters.setHeader(Text.of(formatters.getHeader(), this.prefix.getForCommandSource(source)));
if (TextSerializers.PLAIN.serialize(formatters.getHeader().toText()).contains("<" + source.getName() + ">")) {
// Remove it.
Text p = formatters.getHeader().toText().replace("<" + source.getName() + ">", Text.of(), true);
if (p.toPlain().trim().isEmpty()) {
formatters.setHeader(this.prefix.getForCommandSource(source));
} else {
formatters.setHeader(Text.of(p, this.prefix.getForCommandSource(source)));
}
} else {
formatters.setHeader(Text.of(formatters.getHeader(), this.prefix.getForCommandSource(source)));
}
}

ITextStyleService.TextFormat format = this.textStyleService.getLastColourAndStyle(formatters.getHeader(), null);
Expand Down

0 comments on commit 638aa7e

Please sign in to comment.