mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-28 19:14:15 +00:00
adds support for vanish plugins
This commit is contained in:
parent
85605774cf
commit
315e16488b
7 changed files with 76 additions and 3 deletions
|
@ -34,6 +34,7 @@ subprojects {
|
||||||
url = uri("https://jitpack.io")
|
url = uri("https://jitpack.io")
|
||||||
content {
|
content {
|
||||||
includeGroup("com.github.MilkBowl")
|
includeGroup("com.github.MilkBowl")
|
||||||
|
includeGroup("com.github.LeonMangler")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,8 @@ dependencies {
|
||||||
implementation("org.bstats:bstats-base:3.0.2")
|
implementation("org.bstats:bstats-base:3.0.2")
|
||||||
implementation("org.bstats:bstats-bukkit:3.0.2")
|
implementation("org.bstats:bstats-bukkit:3.0.2")
|
||||||
|
|
||||||
|
implementation("com.github.LeonMangler:SuperVanish:6.2.18-3")
|
||||||
|
|
||||||
annotationProcessor("org.projectlombok:lombok:1.18.30")
|
annotationProcessor("org.projectlombok:lombok:1.18.30")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,10 +75,18 @@ paper {
|
||||||
required = false
|
required = false
|
||||||
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
|
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
|
||||||
}
|
}
|
||||||
|
register("PremiumVanish") {
|
||||||
|
required = false
|
||||||
|
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
|
||||||
|
}
|
||||||
register("SlimeWorldManager") {
|
register("SlimeWorldManager") {
|
||||||
required = false
|
required = false
|
||||||
load = PaperPluginDescription.RelativeLoadOrder.AFTER
|
load = PaperPluginDescription.RelativeLoadOrder.AFTER
|
||||||
}
|
}
|
||||||
|
register("SuperVanish") {
|
||||||
|
required = false
|
||||||
|
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
|
||||||
|
}
|
||||||
register("Vault") {
|
register("Vault") {
|
||||||
required = false
|
required = false
|
||||||
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
|
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
|
||||||
|
|
|
@ -5,6 +5,7 @@ import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.hook.VaultHook;
|
import dev.plex.hook.VaultHook;
|
||||||
|
import dev.plex.meta.PlayerMeta;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -24,6 +25,7 @@ public class ListCMD extends PlexCommand
|
||||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||||
{
|
{
|
||||||
List<Player> players = Lists.newArrayList(Bukkit.getOnlinePlayers());
|
List<Player> players = Lists.newArrayList(Bukkit.getOnlinePlayers());
|
||||||
|
players.removeIf(PlayerMeta::isVanished);
|
||||||
Component list = Component.empty();
|
Component list = Component.empty();
|
||||||
Component header = Component.text("There " + (players.size() == 1 ? "is" : "are") + " currently").color(NamedTextColor.GRAY)
|
Component header = Component.text("There " + (players.size() == 1 ? "is" : "are") + " currently").color(NamedTextColor.GRAY)
|
||||||
.append(Component.space())
|
.append(Component.space())
|
||||||
|
|
|
@ -19,7 +19,7 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
public class PlayerListener<T> extends PlexListener
|
public class PlayerListener extends PlexListener
|
||||||
{
|
{
|
||||||
// setting up a player's data
|
// setting up a player's data
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
@ -62,7 +62,7 @@ public class PlayerListener<T> extends PlexListener
|
||||||
}
|
}
|
||||||
|
|
||||||
String loginMessage = PlayerMeta.getLoginMessage(plexPlayer);
|
String loginMessage = PlayerMeta.getLoginMessage(plexPlayer);
|
||||||
if (!loginMessage.isEmpty())
|
if (!loginMessage.isEmpty() && !PlayerMeta.isVanished(player))
|
||||||
{
|
{
|
||||||
PlexUtils.broadcast(PlexUtils.stringToComponent(loginMessage));
|
PlexUtils.broadcast(PlexUtils.stringToComponent(loginMessage));
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package dev.plex.listener.impl;
|
||||||
|
|
||||||
|
import de.myzelyam.api.vanish.PlayerShowEvent;
|
||||||
|
import dev.plex.cache.DataUtils;
|
||||||
|
import dev.plex.listener.PlexListener;
|
||||||
|
import dev.plex.meta.PlayerMeta;
|
||||||
|
import dev.plex.player.PlexPlayer;
|
||||||
|
import dev.plex.util.PlexUtils;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
|
||||||
|
public class VanishListener extends PlexListener
|
||||||
|
{
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPlayerUnvanish(PlayerShowEvent event)
|
||||||
|
{
|
||||||
|
if (!PlexUtils.hasVanishPlugin())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (event.isSilent())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PlexPlayer plexPlayer = DataUtils.getPlayer(event.getPlayer().getUniqueId());
|
||||||
|
String loginMessage = PlayerMeta.getLoginMessage(plexPlayer);
|
||||||
|
if (!loginMessage.isEmpty())
|
||||||
|
{
|
||||||
|
PlexUtils.broadcast(PlexUtils.stringToComponent(loginMessage));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,9 +10,28 @@ import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.metadata.MetadataValue;
|
||||||
|
|
||||||
public class PlayerMeta
|
public class PlayerMeta
|
||||||
{
|
{
|
||||||
|
public static boolean isVanished(Player player)
|
||||||
|
{
|
||||||
|
for (MetadataValue meta : player.getMetadata("vanished"))
|
||||||
|
{
|
||||||
|
if (meta.asBoolean())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isVanished(PlexPlayer player)
|
||||||
|
{
|
||||||
|
return isVanished(player.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
public static Component getPrefix(PlexPlayer plexPlayer)
|
public static Component getPrefix(PlexPlayer plexPlayer)
|
||||||
{
|
{
|
||||||
if (plexPlayer.getPrefix() != null && !plexPlayer.getPrefix().isEmpty())
|
if (plexPlayer.getPrefix() != null && !plexPlayer.getPrefix().isEmpty())
|
||||||
|
|
|
@ -118,6 +118,15 @@ public class PlexUtils implements PlexBase
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean hasVanishPlugin()
|
||||||
|
{
|
||||||
|
if (Bukkit.getPluginManager().isPluginEnabled("SuperVanish") || Bukkit.getPluginManager().isPluginEnabled("PremiumVanish"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isPluginCMD(String cmd, String pluginName)
|
public static boolean isPluginCMD(String cmd, String pluginName)
|
||||||
{
|
{
|
||||||
Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin(pluginName);
|
Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin(pluginName);
|
||||||
|
@ -157,7 +166,7 @@ public class PlexUtils implements PlexBase
|
||||||
|
|
||||||
return LEGACY_FORMATTING_PATTERN.matcher(input).find() ?
|
return LEGACY_FORMATTING_PATTERN.matcher(input).find() ?
|
||||||
LegacyComponentSerializer.legacyAmpersand().deserialize(input.replaceAll("([§&]+)(k+)", "") // Ugly hack, but it tries to prevent &k and any attempts to bypass it.
|
LegacyComponentSerializer.legacyAmpersand().deserialize(input.replaceAll("([§&]+)(k+)", "") // Ugly hack, but it tries to prevent &k and any attempts to bypass it.
|
||||||
).decoration(TextDecoration.OBFUSCATED, TextDecoration.State.FALSE) :
|
).decoration(TextDecoration.OBFUSCATED, TextDecoration.State.FALSE) :
|
||||||
SafeMiniMessage.mmDeserializeWithoutEvents(input);
|
SafeMiniMessage.mmDeserializeWithoutEvents(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue