mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-22 17:17:37 +00:00
Add BroadcastEvent
This commit is contained in:
parent
adb0d070a4
commit
aab5083f78
30
server/src/main/java/dev/plex/event/BroadcastEvent.java
Normal file
30
server/src/main/java/dev/plex/event/BroadcastEvent.java
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,7 @@ import com.google.common.base.CharMatcher;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
import dev.plex.PlexBase;
|
import dev.plex.PlexBase;
|
||||||
|
import dev.plex.event.BroadcastEvent;
|
||||||
import dev.plex.listener.impl.ChatListener;
|
import dev.plex.listener.impl.ChatListener;
|
||||||
import dev.plex.storage.StorageType;
|
import dev.plex.storage.StorageType;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@ -274,11 +275,13 @@ public class PlexUtils implements PlexBase
|
|||||||
public static void broadcast(String s)
|
public static void broadcast(String s)
|
||||||
{
|
{
|
||||||
Bukkit.broadcast(MINI_MESSAGE.deserialize(s));
|
Bukkit.broadcast(MINI_MESSAGE.deserialize(s));
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(new BroadcastEvent(null, s));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void broadcast(Component component)
|
public static void broadcast(Component component)
|
||||||
{
|
{
|
||||||
Bukkit.broadcast(component);
|
Bukkit.broadcast(component);
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(new BroadcastEvent(component, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void broadcastToAdmins(Component component, String permission)
|
public static void broadcastToAdmins(Component component, String permission)
|
||||||
|
Loading…
Reference in New Issue
Block a user