当前位置: 首页>>代码示例>>Java>>正文


Java MyPetApi类代码示例

本文整理汇总了Java中de.Keyle.MyPet.MyPetApi的典型用法代码示例。如果您正苦于以下问题:Java MyPetApi类的具体用法?Java MyPetApi怎么用?Java MyPetApi使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MyPetApi类属于de.Keyle.MyPet包,在下文中一共展示了MyPetApi类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: syncPlayer

import de.Keyle.MyPet.MyPetApi; //导入依赖的package包/类
private static void syncPlayer(MyPetPlayer mpPlayer) {
    Slot petSlot = getMyPetSlot();
    if (mpPlayer.isOnline() && mpPlayer.hasMyPet()) {
        Player player = mpPlayer.getPlayer();

        if (!InventoryManager.playerIsLoaded(player)) {
            return;
        }

        Inventory inventory = InventoryManager.get(player).getInventory();
        ItemStack currentPet = inventory.getItem(petSlot.getSlotId());
        if (isMyPetItem(currentPet)) {
            MyPet pet = mpPlayer.getMyPet();
            UUID petUUID = UUID.fromString(ItemUtils.getTag(currentPet, MYPET_TAG));
            if (petUUID.equals(pet.getUUID())) {
                return;
            }
        } else {
            inventory.setItem(petSlot.getSlotId(), petSlot.getCup());
        }

        MyPetApi.getMyPetManager().deactivateMyPet(mpPlayer, false);
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:25,代码来源:MyPetManager.java

示例2: onMyPetCall

import de.Keyle.MyPet.MyPetApi; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onMyPetCall(MyPetCallEvent event) {
    Player player = event.getOwner().getPlayer();
    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    Inventory inventory = InventoryManager.get(player).getInventory();
    ItemStack currentPet = inventory.getItem(getMyPetSlot().getSlotId());
    boolean keepPet = true;

    if (!isMyPetItem(currentPet)) {
        keepPet = false;
    } else {
        UUID petUUID = UUID.fromString(ItemUtils.getTag(currentPet, MYPET_TAG));
        if (!petUUID.equals(event.getMyPet().getUUID())) {
            keepPet = false;
        }
    }

    if (!keepPet) {
        event.setCancelled(true);
        MyPetApi.getMyPetManager().deactivateMyPet(event.getOwner(), true);
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:26,代码来源:MyPetManager.java

示例3: init

import de.Keyle.MyPet.MyPetApi; //导入依赖的package包/类
public static boolean init(RPGInventory instance) {
    if (MyPetManager.getMyPetSlot() == null) {
        instance.getLogger().warning("MyPet found, but slot for MyPet not configured!");
        return false;
    }

    for (MyPetPlayer mpPlayer : MyPetApi.getPlayerManager().getMyPetPlayers()) {
        syncPlayer(mpPlayer);
    }

    instance.getServer().getPluginManager().registerEvents(new MyPetManager(), instance);
    return true;
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:14,代码来源:MyPetManager.java

示例4: deactivateMyPet

import de.Keyle.MyPet.MyPetApi; //导入依赖的package包/类
private static void deactivateMyPet(final Player player) {
    if (!MyPetApi.getPlayerManager().isMyPetPlayer(player)) {
        return;
    }

    final MyPetPlayer user = MyPetApi.getPlayerManager().getMyPetPlayer(player);

    if (user.hasMyPet()) {
        MyPetApi.getMyPetManager().deactivateMyPet(user, true);
        user.setMyPetForWorldGroup(WorldGroup.getGroupByWorld(player.getWorld().getName()).getName(), null);
        MyPetApi.getRepository().updateMyPetPlayer(user, null);
    }

}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:15,代码来源:MyPetManager.java

示例5: onPlayerInventoryLoaded

import de.Keyle.MyPet.MyPetApi; //导入依赖的package包/类
@EventHandler
public void onPlayerInventoryLoaded(PlayerInventoryLoadEvent.Post event) {
    Player player = event.getPlayer();
    PlayerManager playerManager = MyPetApi.getPlayerManager();
    if (playerManager.isMyPetPlayer(player)) {
        syncPlayer(playerManager.getMyPetPlayer(player));
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:9,代码来源:MyPetManager.java

示例6: register

import de.Keyle.MyPet.MyPetApi; //导入依赖的package包/类
@Override
public void register() {
    register("pet_level").scoreSupply(player -> {
        MyPetPlayer myPetPlayer = MyPetApi.getPlayerManager().getMyPetPlayer(player);
        return myPetPlayer.getMyPet().getExperience().getLevel();
    }).eventScore(MyPetLevelUpEvent.class, MyPetLevelUpEvent::getLevel);
}
 
开发者ID:games647,项目名称:ScoreboardStats,代码行数:8,代码来源:MyPetVariables.java

示例7: activateMyPet

import de.Keyle.MyPet.MyPetApi; //导入依赖的package包/类
private static void activateMyPet(final Player player, UUID petUUID) {
    final MyPetPlayer user;
    if (MyPetApi.getPlayerManager().isMyPetPlayer(player)) {
        user = MyPetApi.getPlayerManager().getMyPetPlayer(player);
    } else {
        user = MyPetApi.getPlayerManager().createMyPetPlayer(player);
    }

    if (user.hasMyPet()) {
        MyPetApi.getMyPetManager().deactivateMyPet(user, true);
    }

    final WorldGroup wg = WorldGroup.getGroupByWorld(player.getWorld().getName());
    MyPetApi.getRepository().getMyPet(petUUID, new RepositoryCallback<StoredMyPet>() {
        @Override
        public void callback(StoredMyPet storedMyPet) {
            if (!storedMyPet.getWorldGroup().equals(wg.getName())) {
                PlayerUtils.sendMessage(player, "This pet doesn't belong into this world.");
                return;
            }

            boolean savePet = storedMyPet.getOwner().getInternalUUID().equals(user.getInternalUUID());
            storedMyPet.setOwner(user);
            String worldName = player.getWorld().getName();
            user.setMyPetForWorldGroup(WorldGroup.getGroupByWorld(worldName).getName(), storedMyPet.getUUID());
            Optional<MyPet> pet = MyPetApi.getMyPetManager().activateMyPet(storedMyPet);
            if (pet.isPresent()) {
                MyPet myPet = pet.get();
                if (myPet.getStatus() != MyPet.PetState.Dead) {
                    pet.get().setStatus(MyPet.PetState.Here);
                }
            }

            if (savePet) {
                MyPetApi.getRepository().updateMyPet(storedMyPet, null);
            }

            MyPetApi.getRepository().updateMyPetPlayer(user, null);
        }
    });
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:42,代码来源:MyPetManager.java


注:本文中的de.Keyle.MyPet.MyPetApi类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。