Skip to content
This repository has been archived by the owner on Jul 27, 2019. It is now read-only.

Commit

Permalink
Add SuperVanish hook
Browse files Browse the repository at this point in the history
  • Loading branch information
cnaude committed Dec 18, 2014
1 parent f18a339 commit e12dbd2
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 11 deletions.
6 changes: 6 additions & 0 deletions dependency-reduced-pom.xml
Expand Up @@ -295,6 +295,12 @@
<version>2.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.cnaude.supervanish</groupId>
<artifactId>SuperVanish</artifactId>
<version>5.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
7 changes: 7 additions & 0 deletions pom.xml
Expand Up @@ -277,6 +277,13 @@
<artifactId>AdminPrivateChat</artifactId>
<version>2.1</version>
</dependency>

<!-- SuperVanish -->
<dependency>
<groupId>com.cnaude.supervanish</groupId>
<artifactId>SuperVanish</artifactId>
<version>5.0.1</version>
</dependency>

<!-- Testing only -->
<dependency>
Expand Down
55 changes: 55 additions & 0 deletions src/main/java/com/cnaude/purpleirc/Hooks/SuperVanishHook.java
@@ -0,0 +1,55 @@
/*
* Copyright (C) 2014 cnaude
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Hooks;

import com.cnaude.purpleirc.PurpleIRC;
import java.util.List;
import me.MyzelYam.SuperVanish.api.SVAPI;
import org.bukkit.entity.Player;

/**
*
* @author cnaude
*/
public class SuperVanishHook {

final PurpleIRC plugin;

/**
*
* @param plugin
*/
public SuperVanishHook(PurpleIRC plugin) {
this.plugin = plugin;
}

/**
*
* @param player
* @return
*/
public boolean isVanished(Player player) {
List<String> invisiblePlayers = SVAPI.getInvisiblePlayers();
for (String uuid : invisiblePlayers) {
if (uuid.equalsIgnoreCase(player.getUniqueId().toString())) {
plugin.logDebug("Player " + player.getName() + " is vanished.");
return true;
}
}
return false;
}
}
28 changes: 17 additions & 11 deletions src/main/java/com/cnaude/purpleirc/Hooks/VanishHook.java
Expand Up @@ -25,9 +25,9 @@
* @author cnaude
*/
public class VanishHook {

final PurpleIRC plugin;

/**
*
* @param plugin
Expand All @@ -42,17 +42,23 @@ public VanishHook(PurpleIRC plugin) {
* @return
*/
public boolean isVanished(Player player) {
if (player.hasMetadata("vanished")) {
plugin.logDebug("Player " + player.getName() + " has vanished metadata.");
MetadataValue md = player.getMetadata("vanished").get(0);
if (md.asBoolean()) {
plugin.logDebug("Player " + player.getName() + " is vanished.");
return true;
// Try SuperVanish first
if (plugin.superVanishHook != null) {
return plugin.superVanishHook.isVanished(player);
} else {
// Fallback to other Vanish
if (player.hasMetadata("vanished")) {
plugin.logDebug("Player " + player.getName() + " has vanished metadata.");
MetadataValue md = player.getMetadata("vanished").get(0);
if (md.asBoolean()) {
plugin.logDebug("Player " + player.getName() + " is vanished.");
return true;
} else {
plugin.logDebug("Player " + player.getName() + " is NOT vanished.");
}
} else {
plugin.logDebug("Player " + player.getName() + " is NOT vanished.");
plugin.logDebug("Player " + player.getName() + " has NO vanished metadata.");
}
} else {
plugin.logDebug("Player " + player.getName() + " has NO vanished metadata.");
}
return false;
}
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/cnaude/purpleirc/PurpleIRC.java
Expand Up @@ -45,6 +45,7 @@
import com.cnaude.purpleirc.Hooks.JobsHookOld;
import com.cnaude.purpleirc.Hooks.ReportRTSHook;
import com.cnaude.purpleirc.Hooks.ShortifyHook;
import com.cnaude.purpleirc.Hooks.SuperVanishHook;
import com.cnaude.purpleirc.Hooks.TownyChatHook;
import com.cnaude.purpleirc.Hooks.VanishHook;
import com.cnaude.purpleirc.Hooks.VaultHook;
Expand Down Expand Up @@ -176,6 +177,7 @@ public class PurpleIRC extends JavaPlugin {
private File heroConfigFile;
public VaultHook vaultHelpers;
public VanishHook vanishHook;
public SuperVanishHook superVanishHook;
private YamlConfiguration heroConfig;
private final File cacheFile;
private final File uuidCacheFile;
Expand Down Expand Up @@ -350,6 +352,12 @@ public void onEnable() {
logInfo("OreBroadcast not detected.");
}
vanishHook = new VanishHook(this);
if (isPluginEnabled("SuperVanish")) {
logInfo("Enabling SuperVanish support.");
superVanishHook = new SuperVanishHook(this);
} else {
logInfo("SuperVanish not detected.");
}
if (isPluginEnabled("ReportRTS")) {
logInfo("Enabling ReportRTS support.");
getServer().getPluginManager().registerEvents(new ReportRTSListener(this), this);
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/plugin.yml
Expand Up @@ -20,6 +20,7 @@ softdepend:
- OreBroadcast
- RedditStream
- AdminPrivateChat
- SuperVanish
commands:
irc:
description: Various irc commands
Expand Down

0 comments on commit e12dbd2

Please sign in to comment.