diff --git a/plugin/src/main/java/org/battleplugins/arena/event/ArenaEventManager.java b/plugin/src/main/java/org/battleplugins/arena/event/ArenaEventManager.java index 4fe77673..7badc1bd 100644 --- a/plugin/src/main/java/org/battleplugins/arena/event/ArenaEventManager.java +++ b/plugin/src/main/java/org/battleplugins/arena/event/ArenaEventManager.java @@ -12,6 +12,7 @@ import org.battleplugins.arena.event.arena.ArenaLoseEvent; import org.battleplugins.arena.event.arena.ArenaVictoryEvent; import org.battleplugins.arena.event.player.ArenaPlayerEvent; +import org.battleplugins.arena.resolver.Resolver; import org.battleplugins.arena.util.PolymorphicHashMap; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -169,8 +170,12 @@ private void pollActions(T event, Competition } for (ArenaPlayer player : new HashSet<>(players)) { + // Resolve with ArenaPlayer context + Resolver.Builder resolver = player.resolve().toBuilder(); + event.resolve().mergeInto(resolver); + try { - action.call(player, event); + action.call(player, resolver.build()); } catch (Throwable e) { this.arena.getPlugin().warn("An error occurred calling event action {}", action, e); return; diff --git a/plugin/src/main/java/org/battleplugins/arena/event/action/types/BroadcastAction.java b/plugin/src/main/java/org/battleplugins/arena/event/action/types/BroadcastAction.java index 931f00e3..ec53c672 100644 --- a/plugin/src/main/java/org/battleplugins/arena/event/action/types/BroadcastAction.java +++ b/plugin/src/main/java/org/battleplugins/arena/event/action/types/BroadcastAction.java @@ -35,7 +35,7 @@ public void postProcess(Arena arena, Competition competition, Resolvable reso return; } - String message = this.get(MESSAGE_KEY); + String message = resolvable.resolve().resolveToString(this.get(MESSAGE_KEY)); MessageType messageType = MessageType.valueOf(this.getOrDefault(TYPE_KEY, MessageType.CHAT.name()) .toUpperCase(Locale.ROOT) ); diff --git a/plugin/src/main/java/org/battleplugins/arena/resolver/Resolver.java b/plugin/src/main/java/org/battleplugins/arena/resolver/Resolver.java index bc2820f3..165d5839 100644 --- a/plugin/src/main/java/org/battleplugins/arena/resolver/Resolver.java +++ b/plugin/src/main/java/org/battleplugins/arena/resolver/Resolver.java @@ -2,7 +2,7 @@ import net.kyori.adventure.text.Component; -public interface Resolver { +public interface Resolver extends Resolvable { String resolveToString(String string); @@ -16,6 +16,11 @@ public interface Resolver { Builder toBuilder(); + @Override + default Resolver resolve() { + return this; + } + static Builder builder() { return new ResolverImpl.BuilderImpl(); }