Add BroadcastEvent

This commit is contained in:
Telesphoreo 2024-01-25 17:00:59 -06:00
parent adb0d070a4
commit aab5083f78
2 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,30 @@
package dev.plex.event;
import lombok.Data;
import lombok.EqualsAndHashCode;
import net.kyori.adventure.text.Component;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
@EqualsAndHashCode(callSuper = false)
@Data
public class BroadcastEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private final Component message;
private final String string;
public static HandlerList getHandlerList()
{
return handlers;
}
@Override
public @NotNull HandlerList getHandlers()
{
return handlers;
}
}

View File

@ -4,6 +4,7 @@ import com.google.common.base.CharMatcher;
import com.google.common.collect.Lists;
import dev.plex.Plex;
import dev.plex.PlexBase;
import dev.plex.event.BroadcastEvent;
import dev.plex.listener.impl.ChatListener;
import dev.plex.storage.StorageType;
import net.kyori.adventure.text.Component;
@ -274,11 +275,13 @@ public class PlexUtils implements PlexBase
public static void broadcast(String s)
{
Bukkit.broadcast(MINI_MESSAGE.deserialize(s));
Bukkit.getServer().getPluginManager().callEvent(new BroadcastEvent(null, s));
}
public static void broadcast(Component component)
{
Bukkit.broadcast(component);
Bukkit.getServer().getPluginManager().callEvent(new BroadcastEvent(component, null));
}
public static void broadcastToAdmins(Component component, String permission)