mirror of
https://github.com/HibiscusMC/HibiscusCommons.git
synced 2025-12-19 15:09:26 +00:00
feat: add abstract Emote Events from hooks
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
package me.lojosho.hibiscuscommons.api.events;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.lojosho.hibiscuscommons.hooks.Hook;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public class HibiscusPlayerEmoteEndEvent extends HibiscusHookPlayerEvent {
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
@Getter
|
||||||
|
private final String emoteName;
|
||||||
|
|
||||||
|
public HibiscusPlayerEmoteEndEvent(Hook hook, Player player, @Nullable String emoteName) {
|
||||||
|
super(hook, player);
|
||||||
|
this.emoteName = emoteName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package me.lojosho.hibiscuscommons.api.events;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.lojosho.hibiscuscommons.hooks.Hook;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public class HibiscusPlayerEmotePlayEvent extends HibiscusHookPlayerEvent implements Cancellable {
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
private boolean cancel = false;
|
||||||
|
@Getter
|
||||||
|
private final String emoteName;
|
||||||
|
|
||||||
|
public HibiscusPlayerEmotePlayEvent(Hook hook, Player player, @Nullable String emoteName) {
|
||||||
|
super(hook, player);
|
||||||
|
this.emoteName = emoteName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,7 +2,10 @@ package me.lojosho.hibiscuscommons.hooks.items;
|
|||||||
|
|
||||||
import dev.lone.itemsadder.api.CustomStack;
|
import dev.lone.itemsadder.api.CustomStack;
|
||||||
import dev.lone.itemsadder.api.Events.ItemsAdderLoadDataEvent;
|
import dev.lone.itemsadder.api.Events.ItemsAdderLoadDataEvent;
|
||||||
|
import dev.lone.itemsadder.api.Events.PlayerEmoteEndEvent;
|
||||||
|
import dev.lone.itemsadder.api.Events.PlayerEmotePlayEvent;
|
||||||
import me.lojosho.hibiscuscommons.api.events.HibiscusHookReload;
|
import me.lojosho.hibiscuscommons.api.events.HibiscusHookReload;
|
||||||
|
import me.lojosho.hibiscuscommons.api.events.HibiscusPlayerEmotePlayEvent;
|
||||||
import me.lojosho.hibiscuscommons.hooks.Hook;
|
import me.lojosho.hibiscuscommons.hooks.Hook;
|
||||||
import me.lojosho.hibiscuscommons.hooks.HookFlag;
|
import me.lojosho.hibiscuscommons.hooks.HookFlag;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -45,6 +48,19 @@ public class HookItemAdder extends Hook {
|
|||||||
Bukkit.getPluginManager().callEvent(newEvent);
|
Bukkit.getPluginManager().callEvent(newEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPlayerEmotePlay(PlayerEmotePlayEvent event) {
|
||||||
|
HibiscusPlayerEmotePlayEvent newEvent = new HibiscusPlayerEmotePlayEvent(this, event.getPlayer(), event.getEmoteName());
|
||||||
|
Bukkit.getPluginManager().callEvent(newEvent);
|
||||||
|
if (newEvent.isCancelled()) event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerEmoteEnd(PlayerEmoteEndEvent event) {
|
||||||
|
HibiscusPlayerEmotePlayEvent newEvent = new HibiscusPlayerEmotePlayEvent(this, event.getPlayer(), event.getEmoteName());
|
||||||
|
Bukkit.getPluginManager().callEvent(newEvent);
|
||||||
|
}
|
||||||
|
|
||||||
public String getItemString(ItemStack itemStack) {
|
public String getItemString(ItemStack itemStack) {
|
||||||
if (itemStack == null) return null;
|
if (itemStack == null) return null;
|
||||||
if (!itemStack.hasItemMeta()) return null;
|
if (!itemStack.hasItemMeta()) return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user