Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
modules/Plugin/src/main/java/de/Keyle/MyPet/util/hooks/SuperVanish.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ softdepend: | |
- PvPManager | ||
- Residence | ||
- SkillAPI | ||
- SuperVanish | ||
- SurvivalGames | ||
- Towny | ||
- Vault | ||
|