Skip to content

Commit

Permalink
add SuperVanish hook
Browse files Browse the repository at this point in the history
  • Loading branch information
scomans committed Nov 29, 2016
1 parent 2837186 commit 2ebcda5
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 0 deletions.
Expand Up @@ -401,6 +401,7 @@ private void registerHooks() {
pluginHookManager.registerHook(PvPManagerHook.class);
pluginHookManager.registerHook(ResidenceHook.class);
pluginHookManager.registerHook(SkillApiHook.class);
pluginHookManager.registerHook(SuperVanish.class);
pluginHookManager.registerHook(SurvivalGamesHook.class);
pluginHookManager.registerHook(TownyHook.class);
pluginHookManager.registerHook(UltimateSurvivalGamesHook.class);
Expand Down
@@ -0,0 +1,59 @@
package de.Keyle.MyPet.util.hooks;

import de.Keyle.MyPet.MyPetApi;
import de.Keyle.MyPet.api.entity.MyPet;
import de.Keyle.MyPet.api.event.MyPetCallEvent;
import de.Keyle.MyPet.api.player.MyPetPlayer;
import de.Keyle.MyPet.api.util.hooks.PluginHookName;
import de.Keyle.MyPet.util.PluginHook;
import de.myzelyam.api.vanish.PlayerHideEvent;
import de.myzelyam.api.vanish.PlayerShowEvent;
import de.myzelyam.api.vanish.VanishAPI;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;

@PluginHookName("SuperVanish")
public class SuperVanish extends PluginHook implements Listener {

@Override
public boolean onEnable() {
Bukkit.getPluginManager().registerEvents(this, MyPetApi.getPlugin());
return true;
}

@Override
public void onDisable() {
HandlerList.unregisterAll(this);
}

@EventHandler
public void on(MyPetCallEvent e) {
if (VanishAPI.isInvisible(e.getOwner().getPlayer())) {
e.setCancelled(true);
}
}

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void on(PlayerHideEvent e) {
if (MyPetApi.getPlayerManager().isMyPetPlayer(e.getPlayer())) {
MyPetPlayer player = MyPetApi.getPlayerManager().getMyPetPlayer(e.getPlayer());
if (player.hasMyPet() && player.getMyPet().getStatus() == MyPet.PetState.Here) {
player.getMyPet().removePet(true);
}
}
}


@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void on(PlayerShowEvent e) {
if (MyPetApi.getPlayerManager().isMyPetPlayer(e.getPlayer())) {
MyPetPlayer player = MyPetApi.getPlayerManager().getMyPetPlayer(e.getPlayer());
if (player.hasMyPet() && player.getMyPet().getStatus() == MyPet.PetState.Despawned && player.getMyPet().wantsToRespawn()) {
player.getMyPet().createEntity();
}
}
}
}
10 changes: 10 additions & 0 deletions pom.xml
Expand Up @@ -136,6 +136,9 @@
<!-- https://www.spigotmc.org/resources/nocheatplus2015-07-25.26/ -->
<nocheatplus.version>3.15.0-SNAPSHOT</nocheatplus.version>

<!-- https://www.spigotmc.org/resources/supervanish-be-invisible.1331/ -->
<supervanish.version>5.8.4</supervanish.version>

<knbt.version>0.0.3-SNAPSHOT</knbt.version>
<forms_rt.version>7.0.3</forms_rt.version>
<fanciful-chat.version>0.0.4</fanciful-chat.version>
Expand Down Expand Up @@ -413,6 +416,13 @@
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>de.myzelyam</groupId>
<artifactId>supervanish</artifactId>
<version>${supervanish.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.intellij</groupId>
<artifactId>forms_rt</artifactId>
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/plugin.yml
Expand Up @@ -26,6 +26,7 @@ softdepend:
- PvPManager
- Residence
- SkillAPI
- SuperVanish
- SurvivalGames
- Towny
- Vault
Expand Down

0 comments on commit 2ebcda5

Please sign in to comment.