Search in sources :

Example 1 with ISoliniaFaction

use of com.solinia.solinia.Interfaces.ISoliniaFaction in project solinia3-core by mixxit.

the class CommandCreateFaction method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player) && !(sender instanceof CommandSender))
        return false;
    try {
        if (sender instanceof Player) {
            Player player = (Player) sender;
            if (!player.isOp() && !player.hasPermission("solinia.createfaction")) {
                player.sendMessage("You do not have permission to access this command");
                return false;
            }
        }
        if (args.length < 2) {
            sender.sendMessage("Insufficient arguments: basestandingvalue name");
            return false;
        }
        // args
        // defaultnpcid
        // spawngroupname
        int base = Integer.parseInt(args[0]);
        String factionname = "";
        int count = 0;
        for (String entry : args) {
            if (count == 0) {
                count++;
                continue;
            }
            factionname += entry;
            count++;
        }
        if (factionname.equals("")) {
            sender.sendMessage("Blank name not allowed when creating faction");
            return false;
        }
        factionname = factionname.replace(" ", "_").toUpperCase();
        if (StateManager.getInstance().getConfigurationManager().getFaction(factionname) != null) {
            sender.sendMessage("Faction already exists");
            return true;
        }
        ISoliniaFaction faction = SoliniaFactionFactory.CreateFaction(factionname, base, sender.isOp());
        sender.sendMessage("Created faction: " + faction.getId());
        return true;
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        sender.sendMessage(e.getMessage());
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) ISoliniaFaction(com.solinia.solinia.Interfaces.ISoliniaFaction) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) CommandSender(org.bukkit.command.CommandSender) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender)

Example 2 with ISoliniaFaction

use of com.solinia.solinia.Interfaces.ISoliniaFaction in project solinia3-core by mixxit.

the class CommandEditFaction method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player) && !(sender instanceof CommandSender))
        return false;
    if (sender instanceof Player) {
        Player player = (Player) sender;
        if (!player.isOp() && !player.hasPermission("solinia.editfaction")) {
            player.sendMessage("You do not have permission to access this command");
            return false;
        }
    }
    if (args.length == 0) {
        return false;
    }
    int factionid = Integer.parseInt(args[0]);
    if (args.length == 1) {
        try {
            ISoliniaFaction solfaction = StateManager.getInstance().getConfigurationManager().getFaction(factionid);
            if (solfaction != null) {
                solfaction.sendFactionSettingsToSender(sender);
            } else {
                sender.sendMessage("FACTION ID doesnt exist");
            }
            return true;
        } catch (CoreStateInitException e) {
            sender.sendMessage(e.getMessage());
        }
    }
    if (args.length < 3) {
        sender.sendMessage("Insufficient arguments: factionid setting value");
        return false;
    }
    String setting = args[1];
    String value = args[2];
    // a string
    if (args.length > 3 && (setting.toLowerCase().contains("description") || setting.toLowerCase().contains("factionentry") || setting.toLowerCase().contains("allygrants") || setting.toLowerCase().contains("title"))) {
        value = "";
        int current = 0;
        for (String entry : args) {
            current++;
            if (current <= 2)
                continue;
            value = value + entry + " ";
        }
        value = value.trim();
    }
    if (factionid < 1) {
        sender.sendMessage("Invalid faction id");
        return false;
    }
    try {
        if (StateManager.getInstance().getConfigurationManager().getFaction(factionid) == null) {
            sender.sendMessage("Cannot locate faction id: " + factionid);
            return false;
        }
        if (StateManager.getInstance().getConfigurationManager().getFaction(factionid).isOperatorCreated() && !sender.isOp()) {
            sender.sendMessage("This faction was op created and you are not an op. Only ops can faction op items");
            return false;
        }
        StateManager.getInstance().getConfigurationManager().editFaction(factionid, setting, value);
        sender.sendMessage("Updating setting on faction");
    } catch (InvalidFactionSettingException ne) {
        sender.sendMessage("Invalid faction setting: " + ne.getMessage());
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        sender.sendMessage(e.getMessage());
    } catch (NumberFormatException e) {
        // TODO Auto-generated catch block
        sender.sendMessage(e.getMessage());
    } catch (IOException e) {
        // TODO Auto-generated catch block
        sender.sendMessage(e.getMessage());
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) ISoliniaFaction(com.solinia.solinia.Interfaces.ISoliniaFaction) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) CommandSender(org.bukkit.command.CommandSender) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender) InvalidFactionSettingException(com.solinia.solinia.Exceptions.InvalidFactionSettingException) IOException(java.io.IOException)

Example 3 with ISoliniaFaction

use of com.solinia.solinia.Interfaces.ISoliniaFaction in project solinia3-core by mixxit.

the class Solinia3CoreEntityListener method onEntityDeath.

@EventHandler
public void onEntityDeath(EntityDeathEvent event) {
    if ((event.getEntity() instanceof ArmorStand)) {
        return;
    }
    if (!(event.getEntity() instanceof LivingEntity))
        return;
    if (event.getEntity() instanceof Player)
        return;
    if (!(event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent))
        return;
    if (event.getEntity() instanceof Animals && !Utils.isLivingEntityNPC((LivingEntity) event.getEntity()))
        return;
    EntityDamageByEntityEvent entitykiller = (EntityDamageByEntityEvent) event.getEntity().getLastDamageCause();
    Entity damager = entitykiller.getDamager();
    if (damager instanceof Projectile) {
        Projectile projectile = (Projectile) damager;
        damager = (Entity) projectile.getShooter();
    }
    if (!(damager instanceof LivingEntity))
        return;
    ISoliniaLivingEntity soldamagerentity = null;
    try {
        soldamagerentity = SoliniaLivingEntityAdapter.Adapt((LivingEntity) damager);
    } catch (CoreStateInitException e) {
    }
    // something
    if ((!(damager instanceof Player)) && Utils.isLivingEntityNPC((LivingEntity) damager)) {
        soldamagerentity.doSlayChat();
    }
    if (!(damager instanceof Player) && !soldamagerentity.isPet())
        return;
    try {
        ISoliniaLivingEntity livingEntity = SoliniaLivingEntityAdapter.Adapt(event.getEntity());
        ISoliniaPlayer player = null;
        if (damager instanceof Player) {
            player = SoliniaPlayerAdapter.Adapt((Player) damager);
        }
        if (soldamagerentity.isPet()) {
            if (damager instanceof Wolf) {
                Wolf w = (Wolf) damager;
                player = SoliniaPlayerAdapter.Adapt((Player) w.getOwner());
            }
        }
        if (player == null) {
            return;
        }
        Double experience = Utils.getExperienceRewardAverageForLevel(livingEntity.getLevel());
        // try to share with group
        ISoliniaGroup group = StateManager.getInstance().getGroupByMember(player.getUUID());
        if (group != null) {
            Integer dhighestlevel = 0;
            List<Integer> levelranges = new ArrayList<Integer>();
            for (UUID member : group.getMembers()) {
                ISoliniaPlayer playerchecked = SoliniaPlayerAdapter.Adapt(Bukkit.getPlayer(member));
                int checkedlevel = playerchecked.getLevel();
                levelranges.add(checkedlevel);
            }
            Collections.sort(levelranges);
            // get the highest person in the group
            dhighestlevel = levelranges.get(levelranges.size() - 1);
            int ihighlvl = (int) Math.floor(dhighestlevel);
            int ilowlvl = ihighlvl - 7;
            if (ilowlvl < 1) {
                ilowlvl = 1;
            }
            if (player.getLevel() < ilowlvl) {
                // as they are out of range of the group
                if (livingEntity.getLevel() >= player.getLevel() - 7) {
                    player.increasePlayerExperience(experience);
                    // Grant title for killing mob
                    if (livingEntity.getNpcid() > 0) {
                        ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(livingEntity.getNpcid());
                        if (npc != null && !npc.getDeathGrantsTitle().equals("")) {
                            player.grantTitle(npc.getDeathGrantsTitle());
                        }
                        if (npc.isBoss() || npc.isRaidboss()) {
                            player.grantTitle("the Vanquisher");
                        }
                    }
                } else {
                    player.getBukkitPlayer().sendMessage(ChatColor.GRAY + "* The npc was too low level to gain experience from");
                }
            } else {
                for (UUID member : group.getMembers()) {
                    Player tgtplayer = Bukkit.getPlayer(member);
                    if (tgtplayer != null) {
                        ISoliniaPlayer tgtsolplayer = SoliniaPlayerAdapter.Adapt(tgtplayer);
                        int tgtlevel = tgtsolplayer.getLevel();
                        if (tgtlevel < ilowlvl) {
                            tgtplayer.sendMessage("You were out of level range to gain experience in this group (Min: " + ilowlvl + " Max: " + ihighlvl + ")");
                            continue;
                        }
                        if (!tgtplayer.getWorld().equals(player.getBukkitPlayer().getWorld())) {
                            tgtplayer.sendMessage("You were out of range for shared group xp (world)");
                            continue;
                        }
                        if (tgtplayer.getLocation().distance(player.getBukkitPlayer().getLocation()) <= 100) {
                            if (livingEntity.getLevel() >= (tgtsolplayer.getLevel() - 7)) {
                                tgtsolplayer.increasePlayerExperience(experience);
                                // Grant title for killing mob
                                if (livingEntity.getNpcid() > 0) {
                                    ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(livingEntity.getNpcid());
                                    if (npc != null && !npc.getDeathGrantsTitle().equals("")) {
                                        tgtsolplayer.grantTitle(npc.getDeathGrantsTitle());
                                    }
                                    if (npc.isBoss() || npc.isRaidboss()) {
                                        tgtsolplayer.grantTitle("the Vanquisher");
                                    }
                                }
                            } else {
                                tgtplayer.sendMessage(ChatColor.GRAY + "* The npc was too low level to gain experience from");
                            }
                        } else {
                            tgtplayer.sendMessage("You were out of range for shared group xp (distance)");
                            continue;
                        }
                    }
                }
            }
        } else {
            if (livingEntity.getLevel() >= (player.getLevel() - 7)) {
                player.increasePlayerExperience(experience);
                // Grant title for killing mob
                if (livingEntity.getNpcid() > 0) {
                    ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(livingEntity.getNpcid());
                    if (npc != null && !npc.getDeathGrantsTitle().equals("")) {
                        player.grantTitle(npc.getDeathGrantsTitle());
                    }
                    if (npc.isBoss() || npc.isRaidboss()) {
                        player.grantTitle("the Vanquisher");
                    }
                }
            } else {
                player.getBukkitPlayer().sendMessage(ChatColor.GRAY + "* The npc was too low level to gain experience from");
            }
        }
        if (livingEntity.getNpcid() > 0) {
            ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(livingEntity.getNpcid());
            if (npc.getFactionid() > 0) {
                ISoliniaFaction faction = StateManager.getInstance().getConfigurationManager().getFaction(npc.getFactionid());
                player.decreaseFactionStanding(npc.getFactionid(), 50);
                for (FactionStandingEntry factionEntry : faction.getFactionEntries()) {
                    if (factionEntry.getValue() >= 1500) {
                        // If this is an ally of the faction, grant negative faction
                        player.decreaseFactionStanding(factionEntry.getFactionId(), 10);
                    }
                    if (factionEntry.getValue() <= -1500) {
                        // If this is an enemy of the faction, grant positive faction
                        player.increaseFactionStanding(factionEntry.getFactionId(), 1);
                    }
                }
            }
        }
        if (livingEntity.getNpcid() > 0) {
            ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(livingEntity.getNpcid());
            if (npc != null && !npc.getDeathGrantsTitle().equals("")) {
                player.grantTitle(npc.getDeathGrantsTitle());
            }
            if (npc.isBoss() || npc.isRaidboss()) {
                player.grantTitle("the Vanquisher");
            }
            if (npc.isBoss() || npc.isRaidboss()) {
                Bukkit.broadcastMessage(ChatColor.RED + "[VICTORY] The foundations of the earth shake following the destruction of " + npc.getName() + " at the hands of " + player.getFullNameWithTitle() + "!" + ChatColor.RESET);
            }
        }
        player.giveMoney(1);
        livingEntity.dropLoot();
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) ISoliniaGroup(com.solinia.solinia.Interfaces.ISoliniaGroup) FactionStandingEntry(com.solinia.solinia.Models.FactionStandingEntry) ISoliniaFaction(com.solinia.solinia.Interfaces.ISoliniaFaction) ArrayList(java.util.ArrayList) Projectile(org.bukkit.entity.Projectile) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) Animals(org.bukkit.entity.Animals) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) ArmorStand(org.bukkit.entity.ArmorStand) EntityDamageByEntityEvent(org.bukkit.event.entity.EntityDamageByEntityEvent) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) Wolf(org.bukkit.entity.Wolf) UUID(java.util.UUID) EventHandler(org.bukkit.event.EventHandler)

Example 4 with ISoliniaFaction

use of com.solinia.solinia.Interfaces.ISoliniaFaction in project solinia3-core by mixxit.

the class JsonFactionRepository method reload.

@Override
public void reload() {
    List<ISoliniaFaction> file = new ArrayList<ISoliniaFaction>();
    try {
        Gson gson = new Gson();
        BufferedReader br = new BufferedReader(new FileReader(filePath));
        file = gson.fromJson(br, new TypeToken<List<SoliniaFaction>>() {
        }.getType());
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    Factions.clear();
    for (ISoliniaFaction i : file) {
        Factions.put(i.getId(), i);
    }
    System.out.println("Reloaded " + Factions.size() + " Factions");
}
Also used : ISoliniaFaction(com.solinia.solinia.Interfaces.ISoliniaFaction) ArrayList(java.util.ArrayList) BufferedReader(java.io.BufferedReader) FileNotFoundException(java.io.FileNotFoundException) Gson(com.google.gson.Gson) FileReader(java.io.FileReader) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with ISoliniaFaction

use of com.solinia.solinia.Interfaces.ISoliniaFaction in project solinia3-core by mixxit.

the class MythicMobsNPCEntityProvider method createNpcFile.

public String createNpcFile(ISoliniaNPC npc) {
    String mob = "";
    String uniquename = "NPCID_" + npc.getId();
    if (npc.getMctype() == null)
        return "";
    mob = uniquename + ":\r\n";
    mob = mob + "  Type: " + npc.getMctype() + "\r\n";
    if (npc.isUpsidedown() == true) {
        mob = mob + "  Display: Dinnerbone\r\n";
    } else {
        mob = mob + "  Display: " + npc.getName() + "\r\n";
    }
    double hp = Utils.getStatMaxHP(npc.getClassObj(), npc.getLevel(), 75);
    double damage = Utils.getMaxDamage(npc.getLevel(), 75);
    if (npc.isHeroic()) {
        hp += (Utils.getHeroicHPMultiplier() * npc.getLevel());
        damage += (Utils.getHeroicDamageMultiplier() * npc.getLevel());
    }
    if (npc.isBoss()) {
        hp += (Utils.getBossHPMultiplier() * npc.getLevel());
        damage += (Utils.getBossDamageMultiplier() * npc.getLevel());
    }
    if (npc.isRaidheroic()) {
        hp += (Utils.getRaidHeroicHPMultiplier() * npc.getLevel());
        damage += (Utils.getRaidHeroicDamageMultiplier() * npc.getLevel());
    }
    if (npc.isRaidboss()) {
        hp += (Utils.getRaidBossHPMultiplier() * npc.getLevel());
        damage += (Utils.getRaidBossDamageMultiplier() * npc.getLevel());
    }
    float movementSpeed = 0.3f;
    if (npc.isHeroic()) {
        movementSpeed = Utils.getHeroicRunSpeed();
    }
    if (npc.isBoss()) {
        movementSpeed = Utils.getBossRunSpeed();
    }
    if (npc.isRaidheroic()) {
        movementSpeed = Utils.getRaidHeroicRunSpeed();
    }
    if (npc.isRaidboss()) {
        movementSpeed = Utils.getRaidBossRunSpeed();
    }
    mob = mob + "  Health: " + hp + "\r\n";
    mob = mob + "  Damage: " + damage + "\r\n";
    mob = mob + "  MaxCombatDistance: 25\r\n";
    mob = mob + "  PreventOtherDrops: true\r\n";
    mob = mob + "  PreventRandomEquipment: true\r\n";
    mob = mob + "  Options:\r\n";
    mob = mob + "    MovementSpeed: " + movementSpeed + "\r\n";
    mob = mob + "    KnockbackResistance: 0.75\r\n";
    mob = mob + "    PreventMobKillDrops: true\r\n";
    mob = mob + "    PreventOtherDrops: true\r\n";
    mob = mob + "    Silent: true\r\n";
    mob = mob + "    ShowHealth: true\r\n";
    mob = mob + "    PreventRenaming: true\r\n";
    mob = mob + "    PreventRandomEquipment: true\r\n";
    mob = mob + "    AlwaysShowName: true\r\n";
    mob = mob + "  Modules:\r\n";
    mob = mob + "    ThreatTable: false\r\n";
    if (npc.isPet()) {
        mob = mob + "  Faction: FACTIONID_-1\r\n";
    } else {
        mob = mob + "  Faction: FACTIONID_" + npc.getFactionid() + "\r\n";
    }
    // Act as normal mob if without faction
    if (npc.getFactionid() > 0 || npc.isPet()) {
        mob = mob + "  AIGoalSelectors:\r\n";
        mob = mob + "  - 0 clear\r\n";
        mob = mob + "  - 1 skeletonbowattack\r\n";
        mob = mob + "  - 2 meleeattack\r\n";
        mob = mob + "  - 3 lookatplayers\r\n";
        if (npc.isRoamer()) {
            mob = mob + "  - 4 randomstroll\r\n";
        }
        mob = mob + "  AITargetSelectors:\r\n";
        mob = mob + "  - 0 clear\r\n";
        mob = mob + "  - 1 attacker\r\n";
        // NPC attack players
        if (!npc.isPet()) {
            try {
                ISoliniaFaction npcfaction = StateManager.getInstance().getConfigurationManager().getFaction(npc.getFactionid());
                if (npcfaction.getBase() == -1500) {
                    mob = mob + "  - 2 players\r\n";
                }
            } catch (CoreStateInitException e) {
            // skip
            }
        }
        // NPC attack NPCs
        if (npc.isGuard() || npc.isPet()) {
            // Always attack mobs with factionid 0
            mob = mob + "  - 3 SpecificFaction FACTIONID_0\r\n";
            // Attack all mobs with -1500 faction
            try {
                int curnum = 4;
                for (ISoliniaFaction faction : StateManager.getInstance().getConfigurationManager().getFactions()) {
                    if (faction.getBase() == -1500 && faction.getId() != npc.getFactionid()) {
                        mob = mob + "  - " + curnum + " SpecificFaction FACTIONID_" + faction.getId() + "\r\n";
                        curnum++;
                    }
                }
            } catch (CoreStateInitException e) {
            // skip
            }
        }
    }
    // then go ahead and use it! Better than that crap we have right?
    if (npc.getLoottableid() > 0) {
        try {
            ISoliniaLootTable lootTable = StateManager.getInstance().getConfigurationManager().getLootTable(npc.getLoottableid());
            if (lootTable != null) {
                List<ISoliniaItem> potentialChestArmour = new ArrayList<ISoliniaItem>();
                List<ISoliniaItem> potentialLegsArmour = new ArrayList<ISoliniaItem>();
                List<ISoliniaItem> potentialFeetArmour = new ArrayList<ISoliniaItem>();
                List<ISoliniaItem> potentialWeapons = new ArrayList<ISoliniaItem>();
                List<ISoliniaItem> potentialBows = new ArrayList<ISoliniaItem>();
                List<ISoliniaItem> potentialShields = new ArrayList<ISoliniaItem>();
                for (ISoliniaLootTableEntry loottableentry : lootTable.getEntries()) {
                    ISoliniaLootDrop lootdrop = StateManager.getInstance().getConfigurationManager().getLootDrop(loottableentry.getLootdropid());
                    for (ISoliniaLootDropEntry lootdropentry : lootdrop.getEntries()) {
                        ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(lootdropentry.getItemid());
                        if (ConfigurationManager.ArmourMaterials.contains(item.getBasename().toUpperCase())) {
                            if (item.getAllowedClassNames().size() == 0) {
                                if (item.getBasename().contains("CHESTPLATE"))
                                    potentialChestArmour.add(item);
                                if (item.getBasename().contains("LEGGINGS"))
                                    potentialLegsArmour.add(item);
                                if (item.getBasename().contains("BOOTS"))
                                    potentialFeetArmour.add(item);
                                continue;
                            }
                            if (npc.getClassObj() != null) {
                                if (item.getAllowedClassNames().contains(npc.getClassObj().getName())) {
                                    if (item.getBasename().contains("CHESTPLATE"))
                                        potentialChestArmour.add(item);
                                    if (item.getBasename().contains("LEGGINGS"))
                                        potentialLegsArmour.add(item);
                                    if (item.getBasename().contains("BOOTS"))
                                        potentialFeetArmour.add(item);
                                    continue;
                                }
                            }
                        }
                        if (ConfigurationManager.WeaponMaterials.contains(item.getBasename().toUpperCase())) {
                            if (item.getAllowedClassNames().size() == 0) {
                                if (item.getBasename().contains("SHIELD"))
                                    potentialShields.add(item);
                                else if (item.getBasename().contains("BOW"))
                                    potentialBows.add(item);
                                else
                                    potentialWeapons.add(item);
                                continue;
                            }
                            if (npc.getClassObj() != null) {
                                if (item.getAllowedClassNames().contains(npc.getClassObj().getName())) {
                                    if (item.getBasename().contains("SHIELD"))
                                        potentialShields.add(item);
                                    else
                                        potentialWeapons.add(item);
                                    continue;
                                }
                            }
                        }
                        if (ConfigurationManager.HandMaterials.contains(item.getBasename().toUpperCase())) {
                            if (item.getAllowedClassNames().size() == 0) {
                                if (item.getBasename().contains("SHIELD"))
                                    potentialShields.add(item);
                                else if (item.getBasename().contains("BOW"))
                                    potentialBows.add(item);
                                else
                                    potentialWeapons.add(item);
                                continue;
                            }
                            if (npc.getClassObj() != null) {
                                if (item.getAllowedClassNames().contains(npc.getClassObj().getName())) {
                                    if (item.getBasename().contains("SHIELD"))
                                        potentialShields.add(item);
                                    else
                                        potentialWeapons.add(item);
                                    continue;
                                }
                            }
                        }
                    }
                    mob = mob + "  Equipment:\r\n";
                    if (potentialShields.size() > 0) {
                        Collections.sort(potentialShields, new Comparator<ISoliniaItem>() {

                            public int compare(ISoliniaItem o1, ISoliniaItem o2) {
                                if (o1.getMinLevel() == o2.getMinLevel())
                                    return 0;
                                return o1.getMinLevel() > o2.getMinLevel() ? -1 : 1;
                            }
                        });
                        Collections.reverse(potentialShields);
                        System.out.println("Found better shield in lootdrop (" + potentialWeapons.get(0).getDisplayname() + "), using as shield");
                        writeCustomItem("plugins/MythicMobs/Items/CUSTOMITEMID" + potentialWeapons.get(0).getId() + ".yml", potentialWeapons.get(0));
                        mob = mob + "  - " + "CUSTOMITEMID_" + potentialWeapons.get(0).getId() + ":5\r\n";
                    } else {
                        if (npc.getOffhanditem() != null)
                            mob = mob + "  - " + npc.getOffhanditem() + ":5\r\n";
                    }
                    if (npc.isCustomhead() == true) {
                        if (npc.getCustomheaddata() != null) {
                            mob = mob + "  - CUSTOMHEADNPCID_" + npc.getId() + ":4\r\n";
                        } else {
                            if (npc.getHeaditem() != null)
                                mob = mob + "  - " + npc.getHeaditem() + ":4\r\n";
                        }
                    } else {
                        if (npc.getHeaditem() != null)
                            mob = mob + "  - " + npc.getHeaditem() + ":4\r\n";
                    }
                    if (potentialChestArmour.size() > 0) {
                        Collections.sort(potentialChestArmour, new Comparator<ISoliniaItem>() {

                            public int compare(ISoliniaItem o1, ISoliniaItem o2) {
                                if (o1.getMinLevel() == o2.getMinLevel())
                                    return 0;
                                return o1.getMinLevel() > o2.getMinLevel() ? -1 : 1;
                            }
                        });
                        Collections.reverse(potentialChestArmour);
                        System.out.println("Found better chest in lootdrop (" + potentialChestArmour.get(0).getDisplayname() + "), using as chest");
                        writeCustomItem("plugins/MythicMobs/Items/CUSTOMITEMID" + potentialChestArmour.get(0).getId() + ".yml", potentialChestArmour.get(0));
                        mob = mob + "  - " + "CUSTOMITEMID_" + potentialChestArmour.get(0).getId() + ":3\r\n";
                    } else {
                        if (npc.getChestitem() != null)
                            mob = mob + "  - " + npc.getChestitem() + ":3\r\n";
                    }
                    if (potentialLegsArmour.size() > 0) {
                        Collections.sort(potentialLegsArmour, new Comparator<ISoliniaItem>() {

                            public int compare(ISoliniaItem o1, ISoliniaItem o2) {
                                if (o1.getMinLevel() == o2.getMinLevel())
                                    return 0;
                                return o1.getMinLevel() > o2.getMinLevel() ? -1 : 1;
                            }
                        });
                        Collections.reverse(potentialLegsArmour);
                        System.out.println("Found better legs in lootdrop (" + potentialLegsArmour.get(0).getDisplayname() + "), using as weapon");
                        writeCustomItem("plugins/MythicMobs/Items/CUSTOMITEMID" + potentialLegsArmour.get(0).getId() + ".yml", potentialLegsArmour.get(0));
                        mob = mob + "  - " + "CUSTOMITEMID_" + potentialLegsArmour.get(0).getId() + ":2\r\n";
                    } else {
                        if (npc.getLegsitem() != null)
                            mob = mob + "  - " + npc.getLegsitem() + ":2\r\n";
                    }
                    if (potentialFeetArmour.size() > 0) {
                        Collections.sort(potentialFeetArmour, new Comparator<ISoliniaItem>() {

                            public int compare(ISoliniaItem o1, ISoliniaItem o2) {
                                if (o1.getMinLevel() == o2.getMinLevel())
                                    return 0;
                                return o1.getMinLevel() > o2.getMinLevel() ? -1 : 1;
                            }
                        });
                        Collections.reverse(potentialFeetArmour);
                        System.out.println("Found better feet in lootdrop (" + potentialFeetArmour.get(0).getDisplayname() + "), using as feet");
                        writeCustomItem("plugins/MythicMobs/Items/CUSTOMITEMID" + potentialFeetArmour.get(0).getId() + ".yml", potentialFeetArmour.get(0));
                        mob = mob + "  - " + "CUSTOMITEMID_" + potentialFeetArmour.get(0).getId() + ":1\r\n";
                    } else {
                        if (npc.getFeetitem() != null)
                            mob = mob + "  - " + npc.getFeetitem() + ":1\r\n";
                    }
                    if (npc.getClassObj() != null && npc.getClassObj().getName().toUpperCase().equals("RANGER") && potentialBows.size() > 0) {
                        Collections.sort(potentialBows, new Comparator<ISoliniaItem>() {

                            public int compare(ISoliniaItem o1, ISoliniaItem o2) {
                                if (o1.getMinLevel() == o2.getMinLevel())
                                    return 0;
                                return o1.getMinLevel() > o2.getMinLevel() ? -1 : 1;
                            }
                        });
                        Collections.reverse(potentialBows);
                        System.out.println("Found better weapon (bow) in lootdrop (" + potentialBows.get(0).getDisplayname() + "), using as weapon");
                        writeCustomItem("plugins/MythicMobs/Items/CUSTOMITEMID" + potentialBows.get(0).getId() + ".yml", potentialBows.get(0));
                        mob = mob + "  - " + "CUSTOMITEMID_" + potentialBows.get(0).getId() + ":0\r\n";
                    } else {
                        if (potentialWeapons.size() > 0) {
                            Collections.sort(potentialWeapons, new Comparator<ISoliniaItem>() {

                                public int compare(ISoliniaItem o1, ISoliniaItem o2) {
                                    if (o1.getMinLevel() == o2.getMinLevel())
                                        return 0;
                                    return o1.getMinLevel() > o2.getMinLevel() ? -1 : 1;
                                }
                            });
                            Collections.reverse(potentialWeapons);
                            System.out.println("Found better weapon in lootdrop (" + potentialWeapons.get(0).getDisplayname() + "), using as weapon");
                            writeCustomItem("plugins/MythicMobs/Items/CUSTOMITEMID" + potentialWeapons.get(0).getId() + ".yml", potentialWeapons.get(0));
                            mob = mob + "  - " + "CUSTOMITEMID_" + potentialWeapons.get(0).getId() + ":0\r\n";
                        } else {
                            if (npc.getHanditem() != null)
                                mob = mob + "  - " + npc.getHanditem() + ":0\r\n";
                        }
                    }
                }
            }
        } catch (CoreStateInitException e) {
        // skip
        }
    } else {
        if (npc.getHeaditem() != null || npc.getChestitem() != null || npc.getLegsitem() != null || npc.getFeetitem() != null || npc.getHanditem() != null || npc.getOffhanditem() != null) {
            mob = mob + "  Equipment:\r\n";
            if (npc.getOffhanditem() != null)
                mob = mob + "  - " + npc.getOffhanditem() + ":5\r\n";
            if (npc.isCustomhead() == true) {
                if (npc.getCustomheaddata() != null) {
                    mob = mob + "  - CUSTOMHEADNPCID_" + npc.getId() + ":4\r\n";
                } else {
                    if (npc.getHeaditem() != null)
                        mob = mob + "  - " + npc.getHeaditem() + ":4\r\n";
                }
            } else {
                if (npc.getHeaditem() != null)
                    mob = mob + "  - " + npc.getHeaditem() + ":4\r\n";
            }
            if (npc.getChestitem() != null)
                mob = mob + "  - " + npc.getChestitem() + ":3\r\n";
            if (npc.getLegsitem() != null)
                mob = mob + "  - " + npc.getLegsitem() + ":2\r\n";
            if (npc.getFeetitem() != null)
                mob = mob + "  - " + npc.getFeetitem() + ":1\r\n";
            if (npc.getHanditem() != null)
                mob = mob + "  - " + npc.getHanditem() + ":0\r\n";
        }
    }
    if (npc.isUsedisguise() == true) {
        mob = mob + "  Disguise:\r\n";
        if (npc.getDisguisetype().toLowerCase().contains("player-")) {
            mob = mob + "    Type: player\r\n";
        } else {
            mob = mob + "    Type: " + npc.getDisguisetype() + "\r\n";
        }
        if (npc.isBurning() == true) {
            mob = mob + "    Burning: true\r\n";
        }
        if (npc.getDisguisetype().toLowerCase().contains("player-")) {
            String[] disguisedata = npc.getDisguisetype().split("-");
            mob = mob + "    Player: " + npc.getName() + "\r\n";
            mob = mob + "    Skin: '" + disguisedata[1] + "'\r\n";
        }
    }
    if (npc.isBoss() == true || npc.isRaidboss()) {
        /*
				mob = mob + "  BossBar:\r\n";
				mob = mob + "    Enabled: true\r\n";
				mob = mob + "    Title: " + npc.getName() + "\r\n";
				mob = mob + "    Range: 200\r\n";
				mob = mob + "    CreateFog: true\r\n";
				mob = mob + "    DarkenSky: true\r\n";
				mob = mob + "    PlayMusic: true\r\n";
			*/
        if (npc.getDisguisetype() != null)
            if (npc.getDisguisetype().toLowerCase().contains("player-")) {
                String[] disguisedata = npc.getDisguisetype().split("-");
                mob = mob + "    Player: " + npc.getName() + "\r\n";
                mob = mob + "    Skin: '" + disguisedata[1] + "'\r\n";
            }
    }
    mob = mob + "  Skills:\r\n";
    if (npc.isInvisible() == true) {
        mob = mob + "  - potion{t=INVISIBILITY;d=2147483647;l=1} @self ~onSpawn\r\n";
    }
    return mob;
}
Also used : ISoliniaItem(com.solinia.solinia.Interfaces.ISoliniaItem) ISoliniaLootTableEntry(com.solinia.solinia.Interfaces.ISoliniaLootTableEntry) ISoliniaFaction(com.solinia.solinia.Interfaces.ISoliniaFaction) ArrayList(java.util.ArrayList) ISoliniaLootTable(com.solinia.solinia.Interfaces.ISoliniaLootTable) ISoliniaLootDrop(com.solinia.solinia.Interfaces.ISoliniaLootDrop) ISoliniaLootDropEntry(com.solinia.solinia.Interfaces.ISoliniaLootDropEntry) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException)

Aggregations

ISoliniaFaction (com.solinia.solinia.Interfaces.ISoliniaFaction)10 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)5 Player (org.bukkit.entity.Player)4 ISoliniaNPC (com.solinia.solinia.Interfaces.ISoliniaNPC)3 ArrayList (java.util.ArrayList)3 InvalidFactionSettingException (com.solinia.solinia.Exceptions.InvalidFactionSettingException)2 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)2 ISoliniaLootTable (com.solinia.solinia.Interfaces.ISoliniaLootTable)2 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)2 CommandSender (org.bukkit.command.CommandSender)2 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)2 Entity (org.bukkit.entity.Entity)2 LivingEntity (org.bukkit.entity.LivingEntity)2 Gson (com.google.gson.Gson)1 InvalidNpcSettingException (com.solinia.solinia.Exceptions.InvalidNpcSettingException)1 ISoliniaGroup (com.solinia.solinia.Interfaces.ISoliniaGroup)1 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)1 ISoliniaLootDrop (com.solinia.solinia.Interfaces.ISoliniaLootDrop)1 ISoliniaLootDropEntry (com.solinia.solinia.Interfaces.ISoliniaLootDropEntry)1 ISoliniaLootTableEntry (com.solinia.solinia.Interfaces.ISoliniaLootTableEntry)1