Search in sources :

Example 1 with FancyMessage

use of de.Keyle.MyPet.api.util.chat.FancyMessage in project MyPet by xXKeyleXx.

the class Translation method toJson.

public JsonObject toJson() {
    JsonObject json = super.toJson();
    json.addProperty("translate", identifier);
    if (using != null) {
        JsonArray using = new JsonArray();
        for (Object o : this.using) {
            if (o instanceof MessagePart) {
                using.add(((MessagePart) o).toJson());
            } else if (o instanceof FancyMessage) {
                using.add(((FancyMessage) o).toJSON());
            } else {
                using.add(o.toString());
            }
        }
        json.add("with", using);
    }
    return json;
}
Also used : JsonArray(com.google.gson.JsonArray) JsonObject(com.google.gson.JsonObject) JsonObject(com.google.gson.JsonObject) FancyMessage(de.Keyle.MyPet.api.util.chat.FancyMessage)

Example 2 with FancyMessage

use of de.Keyle.MyPet.api.util.chat.FancyMessage in project MyPet by xXKeyleXx.

the class CommandOptionSwitch method onCommandOption.

@Override
public boolean onCommandOption(final CommandSender sender, String[] parameter) {
    boolean show = true;
    MyPetPlayer o = null;
    UUID petUUID = null;
    final String lang = MyPetApi.getPlatformHelper().getCommandSenderLanguage(sender);
    if (parameter.length == 0) {
        if (sender instanceof Player) {
            Player petOwner = (Player) sender;
            if (MyPetApi.getPlayerManager().isMyPetPlayer(petOwner)) {
                o = MyPetApi.getPlayerManager().getMyPetPlayer(petOwner);
            }
        } else {
            sender.sendMessage("You can't use this command from server console!");
            return true;
        }
    } else if (parameter.length == 1) {
        Player player = Bukkit.getPlayer(parameter[0]);
        if (player == null || !player.isOnline()) {
            sender.sendMessage("[" + ChatColor.AQUA + "MyPet" + ChatColor.RESET + "] " + Translation.getString("Message.No.PlayerOnline", lang));
            return true;
        }
        if (MyPetApi.getPlayerManager().isMyPetPlayer(player)) {
            o = MyPetApi.getPlayerManager().getMyPetPlayer(player);
        }
        if (o == null) {
            sender.sendMessage("[" + ChatColor.AQUA + "MyPet" + ChatColor.RESET + "] " + Util.formatText(Translation.getString("Message.No.UserHavePet", lang), player.getName()));
        }
    } else if (parameter.length == 2) {
        show = false;
        try {
            o = MyPetApi.getPlayerManager().getMyPetPlayer(UUID.fromString(parameter[0]));
            petUUID = UUID.fromString(parameter[1]);
        } catch (IllegalArgumentException ignored) {
        }
    }
    final MyPetPlayer owner = o;
    if (show && owner != null) {
        MyPetApi.getRepository().getMyPets(owner, new RepositoryCallback<List<StoredMyPet>>() {

            @Override
            public void callback(List<StoredMyPet> value) {
                sender.sendMessage("Select the MyPet you want the player to switch to:");
                if (sender instanceof Player) {
                    boolean doComma = false;
                    FancyMessage message = new FancyMessage("");
                    for (StoredMyPet mypet : value) {
                        if (doComma) {
                            message.then(", ");
                        }
                        message.then(mypet.getPetName()).color(ChatColor.AQUA).command("/petadmin switch " + owner.getInternalUUID() + " " + mypet.getUUID()).itemTooltip(Util.myPetToItemTooltip(mypet, lang));
                        if (!doComma) {
                            doComma = true;
                        }
                    }
                    MyPetApi.getPlatformHelper().sendMessageRaw((Player) sender, message.toJSONString());
                } else {
                    for (StoredMyPet mypet : value) {
                        sender.sendMessage(mypet.getPetName() + "(" + mypet.getPetType().name() + ") -> /petadmin switch " + owner.getInternalUUID() + " " + mypet.getUUID());
                    }
                }
            }
        });
    } else if (!show && owner != null && petUUID != null) {
        MyPetApi.getRepository().getMyPet(petUUID, new RepositoryCallback<StoredMyPet>() {

            @Override
            public void callback(StoredMyPet newPet) {
                if (newPet != null) {
                    if (owner.hasMyPet()) {
                        MyPetApi.getMyPetManager().deactivateMyPet(owner, true);
                    }
                    Optional<MyPet> myPet = MyPetApi.getMyPetManager().activateMyPet(newPet);
                    sender.sendMessage(Translation.getString("Message.Command.Success", sender));
                    if (myPet.isPresent()) {
                        WorldGroup worldGroup = WorldGroup.getGroupByWorld(owner.getPlayer().getWorld().getName());
                        newPet.setWorldGroup(worldGroup.getName());
                        newPet.getOwner().setMyPetForWorldGroup(worldGroup, newPet.getUUID());
                        owner.sendMessage(Util.formatText(Translation.getString("Message.MultiWorld.NowActivePet", owner), myPet.get().getPetName()));
                        switch(myPet.get().createEntity()) {
                            case Success:
                                sender.sendMessage(Util.formatText(Translation.getString("Message.Command.Call.Success", owner), myPet.get().getPetName()));
                                break;
                            case Canceled:
                                sender.sendMessage(Util.formatText(Translation.getString("Message.Spawn.Prevent", owner), myPet.get().getPetName()));
                                break;
                            case NoSpace:
                                sender.sendMessage(Util.formatText(Translation.getString("Message.Spawn.NoSpace", owner), myPet.get().getPetName()));
                                break;
                            case NotAllowed:
                                sender.sendMessage(Util.formatText(Translation.getString("Message.No.AllowedHere", owner), myPet.get().getPetName()));
                                break;
                            case Dead:
                                if (Configuration.Respawn.DISABLE_AUTO_RESPAWN) {
                                    sender.sendMessage(Util.formatText(Translation.getString("Message.Call.Dead", owner), myPet.get().getPetName()));
                                } else {
                                    sender.sendMessage(Util.formatText(Translation.getString("Message.Call.Dead.Respawn", owner), myPet.get().getPetName(), myPet.get().getRespawnTime()));
                                }
                                break;
                            case Flying:
                                sender.sendMessage(Util.formatText(Translation.getString("Message.Spawn.Flying", owner), myPet.get().getPetName()));
                                break;
                        }
                    }
                }
            }
        });
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) MyPet(de.Keyle.MyPet.api.entity.MyPet) StoredMyPet(de.Keyle.MyPet.api.entity.StoredMyPet) WorldGroup(de.Keyle.MyPet.api.WorldGroup) FancyMessage(de.Keyle.MyPet.api.util.chat.FancyMessage) RepositoryCallback(de.Keyle.MyPet.api.repository.RepositoryCallback) List(java.util.List) UUID(java.util.UUID) StoredMyPet(de.Keyle.MyPet.api.entity.StoredMyPet)

Example 3 with FancyMessage

use of de.Keyle.MyPet.api.util.chat.FancyMessage in project MyPet by xXKeyleXx.

the class CommandList method onCommand.

public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) {
    final String lang;
    if (sender instanceof Player) {
        lang = MyPetApi.getPlatformHelper().getPlayerLanguage((Player) sender);
    } else {
        lang = "en";
    }
    final Player petOwner;
    if (args.length <= 0) {
        if (sender instanceof Player) {
            petOwner = (Player) sender;
        } else {
            sender.sendMessage("You can't use this command from server console!");
            return true;
        }
    } else {
        if (sender instanceof Player) {
            if (Permissions.has((Player) sender, "MyPet.admin", false)) {
                petOwner = Bukkit.getPlayer(args[0]);
            } else {
                petOwner = (Player) sender;
            }
        } else {
            sender.sendMessage("You can't use this command from server console!");
            return true;
        }
    }
    if (petOwner == null || !petOwner.isOnline()) {
        sender.sendMessage(Translation.getString("Message.No.PlayerOnline", lang));
        return true;
    }
    final MyPetPlayer owner;
    if (MyPetApi.getPlayerManager().isMyPetPlayer(petOwner)) {
        owner = MyPetApi.getPlayerManager().getMyPetPlayer(petOwner);
    } else {
        sender.sendMessage(Util.formatText(Translation.getString("Message.No.UserHavePet", lang), petOwner.getName()));
        return true;
    }
    if (owner != null) {
        MyPetApi.getRepository().getMyPets(owner, new RepositoryCallback<List<StoredMyPet>>() {

            @Override
            public void callback(List<StoredMyPet> value) {
                if (petOwner == sender) {
                    sender.sendMessage(Util.formatText(Translation.getString("Message.Command.List.Yours", lang), owner.getName()));
                } else {
                    sender.sendMessage(Util.formatText(Translation.getString("Message.Command.List.Player", lang), owner.getName()));
                }
                boolean doComma = false;
                FancyMessage message = new FancyMessage("");
                for (StoredMyPet mypet : value) {
                    if (doComma) {
                        message.then(", ");
                    }
                    message.then(mypet.getPetName()).color(ChatColor.AQUA).itemTooltip(Util.myPetToItemTooltip(mypet, lang));
                    if (!doComma) {
                        doComma = true;
                    }
                }
                MyPetApi.getPlatformHelper().sendMessageRaw((Player) sender, message.toJSONString());
            }
        });
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) List(java.util.List) FancyMessage(de.Keyle.MyPet.api.util.chat.FancyMessage) StoredMyPet(de.Keyle.MyPet.api.entity.StoredMyPet)

Example 4 with FancyMessage

use of de.Keyle.MyPet.api.util.chat.FancyMessage in project MyPet by xXKeyleXx.

the class MyPetEntityListener method onMyPet.

@EventHandler
public void onMyPet(final EntityDamageByEntityEvent event) {
    // noinspection ConstantConditions
    if (event.getEntity() == null) {
        // catch invalid events (i.e. EnchantmentAPI)
        return;
    }
    if (WorldGroup.getGroupByWorld(event.getEntity().getWorld()).isDisabled()) {
        return;
    }
    if (event.getEntity() instanceof MyPetBukkitEntity) {
        MyPetBukkitEntity craftMyPet = (MyPetBukkitEntity) event.getEntity();
        MyPet myPet = craftMyPet.getMyPet();
        if (event.getDamager() instanceof Player || (event.getDamager() instanceof Projectile && ((Projectile) event.getDamager()).getShooter() instanceof Player)) {
            Player damager;
            if (event.getDamager() instanceof Projectile) {
                damager = (Player) ((Projectile) event.getDamager()).getShooter();
            } else {
                damager = (Player) event.getDamager();
            }
            ItemStack leashItem;
            if (MyPetApi.getCompatUtil().compareWithMinecraftVersion("1.9") >= 0) {
                leashItem = damager.getEquipment().getItemInMainHand();
            } else {
                leashItem = damager.getItemInHand();
            }
            if (MyPetApi.getMyPetInfo().getLeashItem(myPet.getPetType()).compare(leashItem)) {
                boolean infoShown = false;
                if (CommandInfo.canSee(PetInfoDisplay.Name.adminOnly, damager, myPet)) {
                    damager.sendMessage(ChatColor.AQUA + myPet.getPetName() + ChatColor.RESET + ":");
                    infoShown = true;
                }
                if (CommandInfo.canSee(PetInfoDisplay.Owner.adminOnly, damager, myPet) && myPet.getOwner().getPlayer() != damager) {
                    damager.sendMessage("   " + Translation.getString("Name.Owner", damager) + ": " + myPet.getOwner().getName());
                    infoShown = true;
                }
                if (CommandInfo.canSee(PetInfoDisplay.HP.adminOnly, damager, myPet)) {
                    String msg;
                    double health = myPet.getHealth();
                    double maxHealth = myPet.getMaxHealth();
                    if (health > maxHealth / 3 * 2) {
                        msg = "" + ChatColor.GREEN;
                    } else if (health > maxHealth / 3) {
                        msg = "" + ChatColor.YELLOW;
                    } else {
                        msg = "" + ChatColor.RED;
                    }
                    msg += String.format("%1.2f", health) + ChatColor.WHITE + "/" + String.format("%1.2f", maxHealth);
                    damager.sendMessage("   " + Translation.getString("Name.HP", damager) + ": " + msg);
                    infoShown = true;
                }
                if (myPet.getStatus() == PetState.Dead && CommandInfo.canSee(PetInfoDisplay.RespawnTime.adminOnly, damager, myPet)) {
                    damager.sendMessage("   " + Translation.getString("Name.Respawntime", damager) + ": " + myPet.getRespawnTime());
                    infoShown = true;
                }
                if (myPet.getDamage() > 0 && CommandInfo.canSee(PetInfoDisplay.Damage.adminOnly, damager, myPet)) {
                    damager.sendMessage("   " + Translation.getString("Name.Damage", damager) + ": " + String.format("%1.2f", myPet.getDamage()));
                    infoShown = true;
                }
                if (myPet.getRangedDamage() > 0 && CommandInfo.canSee(PetInfoDisplay.RangedDamage.adminOnly, damager, myPet)) {
                    damager.sendMessage("   " + Translation.getString("Name.RangedDamage", damager) + ": " + String.format("%1.2f", myPet.getRangedDamage()));
                    infoShown = true;
                }
                if (Configuration.HungerSystem.USE_HUNGER_SYSTEM && CommandInfo.canSee(PetInfoDisplay.Hunger.adminOnly, damager, myPet)) {
                    damager.sendMessage("   " + Translation.getString("Name.Hunger", damager) + ": " + Math.round(myPet.getSaturation()));
                    FancyMessage m = new FancyMessage("   " + Translation.getString("Name.Food", damager) + ": ");
                    boolean comma = false;
                    for (ConfigItem material : MyPetApi.getMyPetInfo().getFood(myPet.getPetType())) {
                        ItemStack is = material.getItem();
                        if (is == null) {
                            continue;
                        }
                        if (comma) {
                            m.then(", ");
                        }
                        if (is.hasItemMeta() && is.getItemMeta().hasDisplayName()) {
                            m.then(is.getItemMeta().getDisplayName());
                        } else {
                            try {
                                m.thenTranslate(MyPetApi.getPlatformHelper().getVanillaName(is));
                            } catch (Exception e) {
                                MyPetApi.getLogger().warning("A food item for \"" + myPet.getPetType().name() + "\" caused an error. If you think this is a bug please report it to the MyPet developer.");
                                MyPetApi.getLogger().warning(is.toString());
                                e.printStackTrace();
                                continue;
                            }
                        }
                        m.color(ChatColor.GOLD);
                        ItemTooltip it = new ItemTooltip();
                        it.setMaterial(is.getType());
                        if (is.hasItemMeta()) {
                            if (is.getItemMeta().hasDisplayName()) {
                                it.setTitle(is.getItemMeta().getDisplayName());
                            }
                            if (is.getItemMeta().hasLore()) {
                                it.setLore(is.getItemMeta().getLore().toArray(new String[0]));
                            }
                        }
                        m.itemTooltip(it);
                        comma = true;
                    }
                    MyPetApi.getPlatformHelper().sendMessageRaw(damager, m.toJSONString());
                    infoShown = true;
                }
                if (myPet.getSkills().has(Behavior.class) && CommandInfo.canSee(PetInfoDisplay.Behavior.adminOnly, damager, myPet)) {
                    Behavior behavior = myPet.getSkills().get(Behavior.class);
                    damager.sendMessage("   " + Translation.getString("Name.Skill.Behavior", damager) + ": " + Translation.getString("Name." + behavior.getBehavior().name(), damager));
                    infoShown = true;
                }
                if (CommandInfo.canSee(PetInfoDisplay.Skilltree.adminOnly, damager, myPet) && myPet.getSkilltree() != null) {
                    damager.sendMessage("   " + Translation.getString("Name.Skilltree", damager) + ": " + Colorizer.setColors(myPet.getSkilltree().getDisplayName()));
                    infoShown = true;
                }
                if (CommandInfo.canSee(PetInfoDisplay.Level.adminOnly, damager, myPet)) {
                    int lvl = myPet.getExperience().getLevel();
                    damager.sendMessage("   " + Translation.getString("Name.Level", damager) + ": " + lvl);
                    infoShown = true;
                }
                int maxLevel = myPet.getSkilltree() != null ? myPet.getSkilltree().getMaxLevel() : Configuration.LevelSystem.Experience.LEVEL_CAP;
                if (CommandInfo.canSee(PetInfoDisplay.Exp.adminOnly, damager, myPet) && myPet.getExperience().getLevel() < maxLevel) {
                    double exp = myPet.getExperience().getCurrentExp();
                    double reqEXP = myPet.getExperience().getRequiredExp();
                    damager.sendMessage("   " + Translation.getString("Name.Exp", damager) + ": " + String.format("%1.2f", exp) + "/" + String.format("%1.2f", reqEXP));
                    infoShown = true;
                }
                if (myPet.getOwner().getDonationRank() != DonateCheck.DonationRank.None) {
                    infoShown = true;
                    String donationMessage = "" + ChatColor.GOLD;
                    donationMessage += myPet.getOwner().getDonationRank().getDefaultIcon();
                    donationMessage += " " + Translation.getString("Name.Title." + myPet.getOwner().getDonationRank().name(), damager) + " ";
                    donationMessage += myPet.getOwner().getDonationRank().getDefaultIcon();
                    damager.sendMessage("   " + donationMessage);
                }
                if (!infoShown) {
                    damager.sendMessage(Translation.getString("Message.No.NothingToSeeHere", myPet.getOwner()));
                }
                event.setCancelled(true);
            } else if (myPet.getOwner().equals(damager) && (!Configuration.Misc.OWNER_CAN_ATTACK_PET)) {
                event.setCancelled(true);
            } else if (!myPet.getOwner().equals(damager) && !MyPetApi.getHookHelper().canHurt(damager, myPet.getOwner().getPlayer(), true)) {
                event.setCancelled(true);
            }
        }
        if (event.getDamager() instanceof CraftMyPetProjectile) {
            EntityMyPetProjectile projectile = ((CraftMyPetProjectile) event.getDamager()).getMyPetProjectile();
            if (projectile != null && projectile.getShooter() != null) {
                if (myPet == projectile.getShooter().getMyPet()) {
                    event.setCancelled(true);
                }
                if (!MyPetApi.getHookHelper().canHurt(projectile.getShooter().getOwner().getPlayer(), myPet.getOwner().getPlayer(), true)) {
                    event.setCancelled(true);
                }
            }
        }
        if (!event.isCancelled() && event.getDamager() instanceof LivingEntity) {
            LivingEntity damager = (LivingEntity) event.getDamager();
            if (damager instanceof Player) {
                if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), (Player) damager, true)) {
                    return;
                }
            }
            if (!isSkillActive) {
                for (Skill skill : myPet.getSkills().all()) {
                    if (skill instanceof OnDamageByEntitySkill) {
                        OnDamageByEntitySkill damageByEntitySkill = (OnDamageByEntitySkill) skill;
                        if (damageByEntitySkill.trigger()) {
                            isSkillActive = true;
                            damageByEntitySkill.apply(damager, event);
                            isSkillActive = false;
                        }
                    }
                }
            }
        }
    }
}
Also used : MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) EntityMyPetProjectile(de.Keyle.MyPet.api.entity.skill.ranged.EntityMyPetProjectile) ConfigItem(de.Keyle.MyPet.api.util.ConfigItem) FancyMessage(de.Keyle.MyPet.api.util.chat.FancyMessage) OnDamageByEntitySkill(de.Keyle.MyPet.api.skill.OnDamageByEntitySkill) EntityMyPetProjectile(de.Keyle.MyPet.api.entity.skill.ranged.EntityMyPetProjectile) CraftMyPetProjectile(de.Keyle.MyPet.api.entity.skill.ranged.CraftMyPetProjectile) ItemTooltip(de.Keyle.MyPet.api.util.chat.parts.ItemTooltip) OnDamageByEntitySkill(de.Keyle.MyPet.api.skill.OnDamageByEntitySkill) Skill(de.Keyle.MyPet.api.skill.skilltree.Skill) OnHitSkill(de.Keyle.MyPet.api.skill.OnHitSkill) CraftMyPetProjectile(de.Keyle.MyPet.api.entity.skill.ranged.CraftMyPetProjectile) Behavior(de.Keyle.MyPet.api.skill.skills.Behavior) ItemStack(org.bukkit.inventory.ItemStack) EventHandler(org.bukkit.event.EventHandler)

Example 5 with FancyMessage

use of de.Keyle.MyPet.api.util.chat.FancyMessage in project MyPet by xXKeyleXx.

the class MyPetEntityListener method sendDeathMessage.

@SuppressWarnings("RedundantCast")
private void sendDeathMessage(final EntityDeathEvent event) {
    if (event.getEntity() instanceof MyPetBukkitEntity && event.getEntity().getWorld().getGameRuleValue(GameRule.SHOW_DEATH_MESSAGES)) {
        MyPet myPet = ((MyPetBukkitEntity) event.getEntity()).getMyPet();
        String killer;
        if (event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
            EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event.getEntity().getLastDamageCause();
            if (e.getDamager().getType() == EntityType.PLAYER) {
                if (e.getDamager() == myPet.getOwner().getPlayer()) {
                    killer = Translation.getString("Name.You", myPet.getOwner());
                } else {
                    killer = ((Player) e.getDamager()).getName();
                }
            } else if (e.getDamager().getType() == EntityType.WOLF) {
                Wolf w = (Wolf) e.getDamager();
                killer = Translation.getString("Name.Wolf", myPet.getOwner());
                if (w.isTamed()) {
                    killer += " (" + w.getOwner().getName() + ')';
                }
            } else if (e.getDamager() instanceof MyPetBukkitEntity) {
                MyPetBukkitEntity craftMyPet = (MyPetBukkitEntity) e.getDamager();
                killer = ChatColor.AQUA + craftMyPet.getMyPet().getPetName() + ChatColor.RESET + " (" + craftMyPet.getOwner().getName() + ')';
            } else if (e.getDamager() instanceof Projectile) {
                Projectile projectile = (Projectile) e.getDamager();
                killer = Translation.getString("Name." + Util.capitalizeName(projectile.getType().name()), myPet.getOwner()) + " (";
                if (projectile.getShooter() instanceof Player) {
                    if (projectile.getShooter() == myPet.getOwner().getPlayer()) {
                        killer += Translation.getString("Name.You", myPet.getOwner());
                    } else {
                        killer += ((Player) projectile.getShooter()).getName();
                    }
                } else {
                    if (MyPetApi.getMyPetInfo().isLeashableEntityType(e.getDamager().getType())) {
                        killer += Translation.getString("Name." + Util.capitalizeName(MyPetType.byEntityTypeName(e.getDamager().getType().name()).name()), myPet.getOwner());
                    } else if (e.getDamager().getType().getName() != null) {
                        killer += Translation.getString("Name." + Util.capitalizeName(e.getDamager().getType().getName()), myPet.getOwner());
                    } else {
                        killer += Translation.getString("Name.Unknow", myPet.getOwner());
                    }
                }
                killer += ")";
            } else {
                if (MyPetApi.getMyPetInfo().isLeashableEntityType(e.getDamager().getType())) {
                    killer = Translation.getString("Name." + Util.capitalizeName(MyPetType.byEntityTypeName(e.getDamager().getType().name()).name()), myPet.getOwner());
                } else {
                    if (e.getDamager().getType().getName() != null) {
                        killer = Translation.getString("Name." + Util.capitalizeName(e.getDamager().getType().getName()), myPet.getOwner());
                    } else {
                        killer = Translation.getString("Name.Unknow", myPet.getOwner());
                    }
                }
            }
        } else {
            if (event.getEntity().getLastDamageCause() != null) {
                killer = Translation.getString("Name." + Util.capitalizeName(event.getEntity().getLastDamageCause().getCause().name()), myPet.getOwner());
            } else {
                killer = Translation.getString("Name.Unknow", myPet.getOwner());
            }
        }
        String deathMessageKey = MyPetApi.getPlatformHelper().getLastDamageSource(event.getEntity());
        if (deathMessageKey == null) {
            myPet.getOwner().sendMessage(Util.formatText(Translation.getString("Message.DeathMessage", myPet.getOwner()), myPet.getPetName(), killer));
            return;
        }
        FancyMessage message = new FancyMessage();
        if (event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
            message.translateUsing(deathMessageKey, ChatColor.AQUA + myPet.getPetName() + ChatColor.RESET, killer);
        } else {
            message.translateUsing(deathMessageKey, ChatColor.AQUA + myPet.getPetName() + ChatColor.RESET);
        }
        MyPetApi.getPlatformHelper().sendMessageRaw(myPet.getOwner().getPlayer(), message.toJSONString());
    }
}
Also used : MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) FancyMessage(de.Keyle.MyPet.api.util.chat.FancyMessage) EntityMyPetProjectile(de.Keyle.MyPet.api.entity.skill.ranged.EntityMyPetProjectile) CraftMyPetProjectile(de.Keyle.MyPet.api.entity.skill.ranged.CraftMyPetProjectile)

Aggregations

FancyMessage (de.Keyle.MyPet.api.util.chat.FancyMessage)8 MyPetPlayer (de.Keyle.MyPet.api.player.MyPetPlayer)6 Player (org.bukkit.entity.Player)5 MyPet (de.Keyle.MyPet.api.entity.MyPet)4 StoredMyPet (de.Keyle.MyPet.api.entity.StoredMyPet)4 ItemTooltip (de.Keyle.MyPet.api.util.chat.parts.ItemTooltip)3 List (java.util.List)3 WorldGroup (de.Keyle.MyPet.api.WorldGroup)2 CraftMyPetProjectile (de.Keyle.MyPet.api.entity.skill.ranged.CraftMyPetProjectile)2 EntityMyPetProjectile (de.Keyle.MyPet.api.entity.skill.ranged.EntityMyPetProjectile)2 ConfigItem (de.Keyle.MyPet.api.util.ConfigItem)2 ItemStack (org.bukkit.inventory.ItemStack)2 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 MyPetApi (de.Keyle.MyPet.MyPetApi)1 Configuration (de.Keyle.MyPet.api.Configuration)1 Util (de.Keyle.MyPet.api.Util)1 CommandTabCompleter (de.Keyle.MyPet.api.commands.CommandTabCompleter)1 PetState (de.Keyle.MyPet.api.entity.MyPet.PetState)1 MyPetEquipment (de.Keyle.MyPet.api.entity.MyPetEquipment)1