fix(velocity): Fixed placeholders provided audience

This commit is contained in:
Adrian committed 2023-04-13 19:09:58 -05:00
1 parent 5d028db601
commit 9b65480ab0
1 file changed
+8 -5
@@ -25,9 +25,9 @@ import io.github.miniplaceholders.api.MiniPlaceholders;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.Map;
import net.draycia.carbon.api.users.CarbonPlayer;
import net.draycia.carbon.api.util.SourcedAudience;
import net.draycia.carbon.common.config.ConfigFactory;
import net.draycia.carbon.velocity.users.CarbonPlayerVelocity;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
@@ -76,11 +76,14 @@ public class VelocityMessageRenderer<T extends Audience> implements IMessageRend
tagResolver.resolver(MiniPlaceholders.getGlobalPlaceholders());
if (receiver instanceof SourcedAudience sourced) {
if (sourced.sender() instanceof CarbonPlayer sender) {
if (sourced.recipient() instanceof CarbonPlayer recipient) {
tagResolver.resolver(MiniPlaceholders.getRelationalPlaceholders(sender, recipient));
if (sourced.sender() instanceof CarbonPlayerVelocity sender && sender.online()) {
if (sourced.recipient() instanceof CarbonPlayerVelocity recipient && recipient.online()) {
tagResolver.resolver(MiniPlaceholders.getRelationalPlaceholders(
sender.player().orElseThrow(),
recipient.player().orElseThrow()
));
} else {
tagResolver.resolver(MiniPlaceholders.getAudiencePlaceholders(sender));
tagResolver.resolver(MiniPlaceholders.getAudiencePlaceholders(sender.player().orElseThrow()));
}
}
}