Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Integrations: add SuperVanish support
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFaser committed Aug 2, 2023
1 parent 4ca5a45 commit 428c694
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 2 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,11 @@
<version>5.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.LeonMangler</groupId>
<artifactId>SuperVanish</artifactId>
<version>6.2.6-4</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
6 changes: 6 additions & 0 deletions src/main/java/net/flectone/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.flectone.custom.FTabCompleter;
import net.flectone.integrations.expansions.FExpansion;
import net.flectone.integrations.luckperms.FLuckPerms;
import net.flectone.integrations.supervanish.FSuperVanish;
import net.flectone.integrations.vault.FVault;
import net.flectone.integrations.voicechats.simplevoicechat.RegisterSimpleVoiceChat;
import net.flectone.managers.FPlayerManager;
Expand Down Expand Up @@ -136,6 +137,11 @@ private void hookPlugins() {
getLogger().info("\uD83D\uDD12 PlaceholderAPI detected and hooked");
new FExpansion().register();
}

if (Bukkit.getPluginManager().getPlugin("SuperVanish") != null) {
Bukkit.getPluginManager().registerEvents(new FSuperVanish(), this);
getLogger().info("\uD83D\uDD12 SuperVanish detected and hooked");
}
}

@Override
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/net/flectone/custom/FPlayer.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.flectone.custom;

import net.flectone.Main;
import net.flectone.integrations.supervanish.FSuperVanish;
import net.flectone.integrations.vault.FVault;
import net.flectone.managers.FPlayerManager;
import net.flectone.utils.ObjectUtil;
Expand Down Expand Up @@ -78,6 +79,8 @@ public void initialize(Player player) {
}

public boolean isOnline() {
if(player != null && FSuperVanish.isVanished(player)) return false;

return this.offlinePlayer.isOnline();
}

Expand Down Expand Up @@ -224,7 +227,7 @@ public void tempban(int time, String reason) {
setUpdated(true);
FPlayerManager.getBannedPlayers().add(this);

if (!(player != null && player.isOnline())) return;
if (!(player != null && isOnline())) return;

String localStringMessage = time == -1 ? "command.ban.local-message" : "command.tempban.local-message";

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/flectone/custom/FTabCompleter.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.flectone.custom;

import net.flectone.integrations.supervanish.FSuperVanish;
import net.flectone.managers.FPlayerManager;
import net.flectone.managers.FileManager;
import org.apache.commons.lang.StringUtils;
Expand Down Expand Up @@ -43,6 +44,7 @@ protected void isOfflinePlayer(String arg) {

protected void isOnlinePlayer(String arg) {
Bukkit.getOnlinePlayers().parallelStream()
.filter(player -> !FSuperVanish.isVanished(player))
.forEach(player -> isStartsWith(arg, player.getName()));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package net.flectone.integrations.supervanish;

import de.myzelyam.api.vanish.PlayerHideEvent;
import de.myzelyam.api.vanish.PlayerShowEvent;
import net.flectone.listeners.PlayerJoinListener;
import net.flectone.listeners.PlayerQuitListener;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.metadata.MetadataValue;

public class FSuperVanish implements Listener {

public static boolean isVanished(Player player) {
return player.getMetadata("vanished").parallelStream()
.anyMatch(MetadataValue::asBoolean);
}

@EventHandler
public void onHide(PlayerHideEvent e) {
if(e.isCancelled()) return;
PlayerQuitListener.sendQuitMessage(e.getPlayer());
}

@EventHandler
public void onShow(PlayerShowEvent e) {
if(e.isCancelled()) return;
PlayerJoinListener.sendJoinMessage(e.getPlayer());
}

}
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: '${project.version}'
main: net.flectone.Main
api-version: 1.16
authors: [ TheFaser, fxd ]
softdepend: [ Vault, PlaceHolderAPI, voicechat, plasmovoice, InteractiveChat, LuckPerms ]
softdepend: [ Vault, PlaceHolderAPI, voicechat, plasmovoice, InteractiveChat, LuckPerms, SuperVanish ]
commands:
ignore:
usage: /ignore <player>
Expand Down

0 comments on commit 428c694

Please sign in to comment.