Search in sources :

Example 21 with MyPetPlayer

use of de.Keyle.MyPet.api.player.MyPetPlayer in project MyPet by xXKeyleXx.

the class MobArenaHook method onJoinPvPArena.

@EventHandler
public void onJoinPvPArena(ArenaPlayerJoinEvent event) {
    if (!Configuration.Hooks.MobArena.ALLOW_PETS) {
        if (MyPetApi.getPlayerManager().isMyPetPlayer(event.getPlayer())) {
            MyPetPlayer player = MyPetApi.getPlayerManager().getMyPetPlayer(event.getPlayer());
            if (player.hasMyPet() && player.getMyPet().getStatus() == MyPet.PetState.Here) {
                player.getMyPet().removePet();
                player.getPlayer().sendMessage(Translation.getString("Message.No.AllowedHere", player.getPlayer()));
            }
        }
    }
}
Also used : MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) EventHandler(org.bukkit.event.EventHandler)

Example 22 with MyPetPlayer

use of de.Keyle.MyPet.api.player.MyPetPlayer in project MyPet by xXKeyleXx.

the class SkillApiHook method on.

@EventHandler
public void on(PlayerExperienceLostEvent event) {
    if (Configuration.Hooks.SkillAPI.GRANT_EXP) {
        Player player = event.getPlayerData().getPlayer();
        if (MyPetApi.getPlayerManager().isMyPetPlayer(player)) {
            MyPetPlayer petPlayer = MyPetApi.getPlayerManager().getMyPetPlayer(player);
            if (petPlayer.hasMyPet()) {
                MyPet myPet = petPlayer.getMyPet();
                if (Configuration.Skilltree.PREVENT_LEVELLING_WITHOUT_SKILLTREE && myPet.getSkilltree() == null) {
                    if (!myPet.autoAssignSkilltree()) {
                        return;
                    }
                }
                // TODO -> removeExp
                myPet.getExperience().removeCurrentExp(event.getExp() * Configuration.Hooks.SkillAPI.EXP_PERCENT / 100);
            }
        }
    }
}
Also used : MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) Player(org.bukkit.entity.Player) MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) MyPet(de.Keyle.MyPet.api.entity.MyPet) EventHandler(org.bukkit.event.EventHandler)

Example 23 with MyPetPlayer

use of de.Keyle.MyPet.api.player.MyPetPlayer in project MyPet by xXKeyleXx.

the class UltimateSurvivalGamesHook method onJoinPvPArena.

@EventHandler
public void onJoinPvPArena(UserLobbyJoinedEvent event) {
    if (MyPetApi.getPlayerManager().isMyPetPlayer(event.getUser().getPlayer())) {
        MyPetPlayer player = MyPetApi.getPlayerManager().getMyPetPlayer(event.getUser().getPlayer());
        if (player.hasMyPet() && player.getMyPet().getStatus() == MyPet.PetState.Here) {
            player.getMyPet().removePet();
            player.getPlayer().sendMessage(Translation.getString("Message.No.AllowedHere", player.getPlayer()));
        }
    }
}
Also used : MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) EventHandler(org.bukkit.event.EventHandler)

Example 24 with MyPetPlayer

use of de.Keyle.MyPet.api.player.MyPetPlayer in project MyPet by xXKeyleXx.

the class WorldGuardHook method on.

@EventHandler
public void on(PlayerMoveEvent event) {
    if (customFlags) {
        if (event.getFrom().getBlock() != event.getTo().getBlock()) {
            if (MyPetApi.getPlayerManager().isMyPetPlayer(event.getPlayer())) {
                MyPetPlayer player = MyPetApi.getPlayerManager().getMyPetPlayer(event.getPlayer());
                if (player.hasMyPet() && player.getMyPet().getStatus() == MyPet.PetState.Here) {
                    if (!isPetAllowed(player)) {
                        player.getMyPet().removePet(true);
                        player.getPlayer().sendMessage(Translation.getString("Message.No.AllowedHere", player.getPlayer()));
                    }
                }
            }
        }
    }
}
Also used : MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) EventHandler(org.bukkit.event.EventHandler)

Example 25 with MyPetPlayer

use of de.Keyle.MyPet.api.player.MyPetPlayer in project MyPet by xXKeyleXx.

the class WorldGuardHook method isPetAllowed.

@Override
public boolean isPetAllowed(MyPetPlayer player) {
    if (customFlags) {
        Player p = player.getPlayer();
        RegionManager mgr = wgp.getRegionManager(p.getWorld());
        ApplicableRegionSet regions = mgr.getApplicableRegions(p.getLocation());
        StateFlag.State s = regions.queryState(null, DENY_FLAG);
        return s == null || s == StateFlag.State.ALLOW;
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) RegionManager(com.sk89q.worldguard.protection.managers.RegionManager) StateFlag(com.sk89q.worldguard.protection.flags.StateFlag) ApplicableRegionSet(com.sk89q.worldguard.protection.ApplicableRegionSet)

Aggregations

MyPetPlayer (de.Keyle.MyPet.api.player.MyPetPlayer)46 EventHandler (org.bukkit.event.EventHandler)19 MyPet (de.Keyle.MyPet.api.entity.MyPet)17 Player (org.bukkit.entity.Player)16 StoredMyPet (de.Keyle.MyPet.api.entity.StoredMyPet)14 InactiveMyPet (de.Keyle.MyPet.entity.InactiveMyPet)8 WorldGroup (de.Keyle.MyPet.api.WorldGroup)7 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)6 TagCompound (de.keyle.knbt.TagCompound)5 List (java.util.List)5 UUID (java.util.UUID)4 Optional (com.google.common.base.Optional)3 RepositoryCallback (de.Keyle.MyPet.api.repository.RepositoryCallback)3 SkillTreeMobType (de.Keyle.MyPet.api.skill.skilltree.SkillTreeMobType)3 SqLiteRepository (de.Keyle.MyPet.repository.types.SqLiteRepository)3 MyPetPlayerImpl (de.Keyle.MyPet.util.player.MyPetPlayerImpl)3 FancyMessage (de.keyle.fanciful.FancyMessage)3 IOException (java.io.IOException)3 MyPetSaveEvent (de.Keyle.MyPet.api.event.MyPetSaveEvent)2 ConfigItem (de.Keyle.MyPet.api.util.ConfigItem)2