Skip to content

Commit

Permalink
Removed runTaskAsynchronously
Browse files Browse the repository at this point in the history
  • Loading branch information
Mowstyl committed Aug 20, 2024
1 parent db87f11 commit 2292da7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
package net.ess3.provider;

import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import org.jetbrains.annotations.NotNull;

import java.util.Set;

public class AbstractAsyncChatEvent extends Event {
public class AbstractAsyncChatEvent extends PlayerEvent {
private static final HandlerList handlers = new HandlerList();

private final Player player;
private final String legacyMessage;
private final Set<Player> playerRecipients;

public AbstractAsyncChatEvent(Player player, String message, Set<Player> recipients) {
super(true);
this.player = player;
public AbstractAsyncChatEvent(boolean async, Player sender, String message, Set<Player> recipients) {
super(sender, async);
this.legacyMessage = message;
this.playerRecipients = recipients;
}

public Player getPlayer() {
return player;
}

public String getMessage() {
return legacyMessage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,15 @@ public PaperAsyncChatListenerProvider(JavaPlugin plugin) {

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onAsyncChatEvent(final AsyncChatEvent event) {
Bukkit.getScheduler().runTaskAsynchronously(plugin, () ->
Bukkit.getPluginManager().callEvent(
new AbstractAsyncChatEvent(
event.getPlayer(),
serializer.serialize(event.message()),
event.viewers().stream()
.filter(v -> v instanceof Player)
.map(v -> (Player) v)
.collect(Collectors.toSet())
)
Bukkit.getPluginManager().callEvent(
new AbstractAsyncChatEvent(
event.isAsynchronous(),
event.getPlayer(),
serializer.serialize(event.message()),
event.viewers().stream()
.filter(v -> v instanceof Player)
.map(v -> (Player) v)
.collect(Collectors.toSet())
)
);
}
Expand Down

0 comments on commit 2292da7

Please sign in to comment.