mirror of
https://github.com/HibiscusMC/HibiscusCommons.git
synced 2025-12-19 15:09:26 +00:00
feat: add hook ability to check invisibility
This commit is contained in:
@@ -6,6 +6,8 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a hook into other minecraft plugins
|
* Represents a hook into other minecraft plugins
|
||||||
*/
|
*/
|
||||||
@@ -150,4 +152,12 @@ public abstract class Hook implements Listener {
|
|||||||
public String getEntityString(@NotNull Entity entity) {
|
public String getEntityString(@NotNull Entity entity) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the entity is invisible (as defined by the hook)
|
||||||
|
* @return true if the entity is invisible, false otherwise (or if the hook does not support entity invisibility)
|
||||||
|
*/
|
||||||
|
public boolean isInvisible(UUID uuid) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -19,6 +19,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class Hooks {
|
public class Hooks {
|
||||||
|
|
||||||
@@ -158,4 +159,14 @@ public class Hooks {
|
|||||||
if (hook == null) return false;
|
if (hook == null) return false;
|
||||||
return hook.isActive();
|
return hook.isActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isInvisible(UUID uuid) {
|
||||||
|
boolean invisible = false;
|
||||||
|
for (Hook hook : HOOK_POOL.values()) {
|
||||||
|
if (hook.isActive()) {
|
||||||
|
if (hook.isInvisible(uuid)) invisible = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return invisible;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,19 @@
|
|||||||
package me.lojosho.hibiscuscommons.hooks.misc;
|
package me.lojosho.hibiscuscommons.hooks.misc;
|
||||||
|
|
||||||
|
import com.Zrips.CMI.CMI;
|
||||||
import com.Zrips.CMI.events.CMIPlayerUnVanishEvent;
|
import com.Zrips.CMI.events.CMIPlayerUnVanishEvent;
|
||||||
import com.Zrips.CMI.events.CMIPlayerVanishEvent;
|
import com.Zrips.CMI.events.CMIPlayerVanishEvent;
|
||||||
import me.lojosho.hibiscuscommons.api.events.HibiscusPlayerUnVanishEvent;
|
import me.lojosho.hibiscuscommons.api.events.HibiscusPlayerUnVanishEvent;
|
||||||
import me.lojosho.hibiscuscommons.api.events.HibiscusPlayerVanishEvent;
|
import me.lojosho.hibiscuscommons.api.events.HibiscusPlayerVanishEvent;
|
||||||
import me.lojosho.hibiscuscommons.hooks.Hook;
|
import me.lojosho.hibiscuscommons.hooks.Hook;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A hook that integrates the plugin {@link com.Zrips.CMI.CMI CMI}
|
* A hook that integrates the plugin {@link com.Zrips.CMI.CMI CMI}
|
||||||
*/
|
*/
|
||||||
@@ -30,4 +34,11 @@ public class HookCMI extends Hook {
|
|||||||
HibiscusPlayerUnVanishEvent newEvent = new HibiscusPlayerUnVanishEvent(this, event.getPlayer());
|
HibiscusPlayerUnVanishEvent newEvent = new HibiscusPlayerUnVanishEvent(this, event.getPlayer());
|
||||||
Bukkit.getPluginManager().callEvent(newEvent);
|
Bukkit.getPluginManager().callEvent(newEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isInvisible(UUID uuid) {
|
||||||
|
Player onlinePlayer = Bukkit.getPlayer(uuid);
|
||||||
|
if (onlinePlayer == null) return false;
|
||||||
|
return CMI.getInstance().getVanishManager().getAllVanished().contains(uuid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package me.lojosho.hibiscuscommons.hooks.misc;
|
package me.lojosho.hibiscuscommons.hooks.misc;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.events.DisguiseEvent;
|
import me.libraryaddict.disguise.events.DisguiseEvent;
|
||||||
import me.libraryaddict.disguise.events.UndisguiseEvent;
|
import me.libraryaddict.disguise.events.UndisguiseEvent;
|
||||||
import me.lojosho.hibiscuscommons.api.events.HibiscusPlayerUnVanishEvent;
|
import me.lojosho.hibiscuscommons.api.events.HibiscusPlayerUnVanishEvent;
|
||||||
@@ -11,6 +12,8 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class HookLibsDisguises extends Hook {
|
public class HookLibsDisguises extends Hook {
|
||||||
public HookLibsDisguises() {
|
public HookLibsDisguises() {
|
||||||
super("LibsDisguises");
|
super("LibsDisguises");
|
||||||
@@ -30,4 +33,11 @@ public class HookLibsDisguises extends Hook {
|
|||||||
HibiscusPlayerUnVanishEvent newEvent = new HibiscusPlayerUnVanishEvent(this, player);
|
HibiscusPlayerUnVanishEvent newEvent = new HibiscusPlayerUnVanishEvent(this, player);
|
||||||
Bukkit.getPluginManager().callEvent(newEvent);
|
Bukkit.getPluginManager().callEvent(newEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isInvisible(UUID uuid) {
|
||||||
|
Player onlinePlayer = Bukkit.getPlayer(uuid);
|
||||||
|
if (onlinePlayer == null) return false;
|
||||||
|
return DisguiseAPI.isDisguised(onlinePlayer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,19 @@ package me.lojosho.hibiscuscommons.hooks.misc;
|
|||||||
|
|
||||||
import de.myzelyam.api.vanish.PlayerHideEvent;
|
import de.myzelyam.api.vanish.PlayerHideEvent;
|
||||||
import de.myzelyam.api.vanish.PlayerShowEvent;
|
import de.myzelyam.api.vanish.PlayerShowEvent;
|
||||||
|
import de.myzelyam.api.vanish.VanishAPI;
|
||||||
import me.lojosho.hibiscuscommons.api.events.HibiscusPlayerUnVanishEvent;
|
import me.lojosho.hibiscuscommons.api.events.HibiscusPlayerUnVanishEvent;
|
||||||
import me.lojosho.hibiscuscommons.api.events.HibiscusPlayerVanishEvent;
|
import me.lojosho.hibiscuscommons.api.events.HibiscusPlayerVanishEvent;
|
||||||
import me.lojosho.hibiscuscommons.hooks.Hook;
|
import me.lojosho.hibiscuscommons.hooks.Hook;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A hook that integrates the plugin {@link de.myzelyam.api.vanish.VanishAPI Supervanish}
|
* A hook that integrates the plugin {@link de.myzelyam.api.vanish.VanishAPI Supervanish}
|
||||||
*
|
*
|
||||||
@@ -32,4 +37,15 @@ public class HookPremiumVanish extends Hook {
|
|||||||
HibiscusPlayerUnVanishEvent newEvent = new HibiscusPlayerUnVanishEvent(this, event.getPlayer());
|
HibiscusPlayerUnVanishEvent newEvent = new HibiscusPlayerUnVanishEvent(this, event.getPlayer());
|
||||||
Bukkit.getPluginManager().callEvent(newEvent);
|
Bukkit.getPluginManager().callEvent(newEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isInvisible(UUID uuid) {
|
||||||
|
OfflinePlayer player = Bukkit.getOfflinePlayer(uuid);
|
||||||
|
if (!player.isOnline()) {
|
||||||
|
return VanishAPI.isInvisibleOffline(uuid);
|
||||||
|
}
|
||||||
|
Player onlinePlayer = player.getPlayer();
|
||||||
|
if (onlinePlayer == null) return false;
|
||||||
|
return VanishAPI.isInvisible(onlinePlayer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,20 @@ package me.lojosho.hibiscuscommons.hooks.misc;
|
|||||||
|
|
||||||
import de.myzelyam.api.vanish.PlayerHideEvent;
|
import de.myzelyam.api.vanish.PlayerHideEvent;
|
||||||
import de.myzelyam.api.vanish.PlayerShowEvent;
|
import de.myzelyam.api.vanish.PlayerShowEvent;
|
||||||
|
import de.myzelyam.api.vanish.VanishAPI;
|
||||||
import me.lojosho.hibiscuscommons.api.events.HibiscusPlayerUnVanishEvent;
|
import me.lojosho.hibiscuscommons.api.events.HibiscusPlayerUnVanishEvent;
|
||||||
import me.lojosho.hibiscuscommons.api.events.HibiscusPlayerVanishEvent;
|
import me.lojosho.hibiscuscommons.api.events.HibiscusPlayerVanishEvent;
|
||||||
import me.lojosho.hibiscuscommons.hooks.Hook;
|
import me.lojosho.hibiscuscommons.hooks.Hook;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A hook that integrates the plugin {@link de.myzelyam.api.vanish.VanishAPI Supervanish}
|
* A hook that integrates the plugin {@link de.myzelyam.api.vanish.VanishAPI Supervanish}
|
||||||
*
|
*
|
||||||
@@ -32,4 +38,15 @@ public class HookSuperVanish extends Hook {
|
|||||||
HibiscusPlayerUnVanishEvent newEvent = new HibiscusPlayerUnVanishEvent(this, event.getPlayer());
|
HibiscusPlayerUnVanishEvent newEvent = new HibiscusPlayerUnVanishEvent(this, event.getPlayer());
|
||||||
Bukkit.getPluginManager().callEvent(newEvent);
|
Bukkit.getPluginManager().callEvent(newEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isInvisible(UUID uuid) {
|
||||||
|
OfflinePlayer player = Bukkit.getOfflinePlayer(uuid);
|
||||||
|
if (!player.isOnline()) {
|
||||||
|
return VanishAPI.isInvisibleOffline(uuid);
|
||||||
|
}
|
||||||
|
Player onlinePlayer = player.getPlayer();
|
||||||
|
if (onlinePlayer == null) return false;
|
||||||
|
return VanishAPI.isInvisible(onlinePlayer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user