Search in sources :

Example 16 with ISoliniaNPC

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

the class CommandEditNpcEvent 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.sendMessage("This is an operator only command");
            return false;
        }
    }
    if (args.length == 0) {
        return false;
    }
    int npcid = Integer.parseInt(args[0]);
    if (args.length == 1) {
        try {
            ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(npcid);
            if (npc != null) {
                npc.sendNPCEvents(sender);
            } else {
                sender.sendMessage("NPC ID doesnt exist");
            }
            return true;
        } catch (CoreStateInitException e) {
            sender.sendMessage(e.getMessage());
        }
    }
    String triggertext = args[1];
    if (args.length == 2) {
        try {
            ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(npcid);
            if (npc != null) {
                boolean found = false;
                for (ISoliniaNPCEventHandler handler : npc.getEventHandlers()) {
                    if (handler.getTriggerdata().toUpperCase().equals(triggertext.toUpperCase())) {
                        found = true;
                        npc.sendNPCEvent(sender, triggertext);
                    }
                }
                if (found == false) {
                    sender.sendMessage("Trigger event doesnt exist on npc");
                }
            } else {
                sender.sendMessage("NPC ID doesnt exist");
            }
            return true;
        } catch (CoreStateInitException e) {
            sender.sendMessage(e.getMessage());
        }
    }
    if (args.length < 4) {
        sender.sendMessage("Insufficient arguments: npcid triggertext setting value");
        return false;
    }
    String setting = args[2];
    String value = args[3];
    // for 'text' based npc settings like trigger texts etc, get the whole thing as a string
    if (args.length > 4 && (setting.toLowerCase().equals("chatresponse") || setting.toLowerCase().equals("title") || setting.toLowerCase().equals("randomisedgearsuffix"))) {
        value = "";
        int current = 0;
        for (String entry : args) {
            current++;
            if (current <= 3)
                continue;
            value = value + entry + " ";
        }
        value = value.trim();
    }
    if (npcid < 1) {
        sender.sendMessage("Invalid NPC id");
        return false;
    }
    try {
        ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(npcid);
        if (npc != null) {
            boolean found = false;
            for (ISoliniaNPCEventHandler handler : npc.getEventHandlers()) {
                if (handler.getTriggerdata().toUpperCase().equals(triggertext.toUpperCase())) {
                    found = true;
                }
            }
            if (found == false) {
                sender.sendMessage("Trigger event doesnt exist on npc");
                return false;
            }
        } else {
            sender.sendMessage("NPC ID doesnt exist");
            return false;
        }
        StateManager.getInstance().getConfigurationManager().editNpcTriggerEvent(npcid, triggertext, setting, value);
        sender.sendMessage("Updating setting on NPC Event");
    } catch (InvalidNPCEventSettingException ne) {
        sender.sendMessage("Invalid NPC Event Setting: " + ne.getMessage());
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        sender.sendMessage(e.getMessage());
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) ISoliniaNPCEventHandler(com.solinia.solinia.Interfaces.ISoliniaNPCEventHandler) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC) CommandSender(org.bukkit.command.CommandSender) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender) InvalidNPCEventSettingException(com.solinia.solinia.Exceptions.InvalidNPCEventSettingException)

Example 17 with ISoliniaNPC

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

the class SoliniaLivingEntity method getMaxHP.

@Override
public double getMaxHP() {
    if (getNpcid() < 1 && !isPlayer())
        return 1;
    double statHp = Utils.getStatMaxHP(getClassObj(), getLevel(), getStamina());
    double itemHp = getItemHp();
    double totalHp = statHp + itemHp;
    try {
        if (getNpcid() > 0) {
            ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
            if (npc == null)
                return totalHp;
            totalHp += Utils.getTotalEffectTotalHP(this.getBukkitLivingEntity());
            if (npc.isBoss()) {
                totalHp += (Utils.getBossHPMultiplier() * npc.getLevel());
            }
            if (npc.isHeroic()) {
                totalHp += (Utils.getHeroicHPMultiplier() * npc.getLevel());
            }
            if (npc.isRaidboss()) {
                totalHp += (Utils.getRaidBossHPMultiplier() * npc.getLevel());
            }
            if (npc.isRaidheroic()) {
                totalHp += (Utils.getRaidHeroicHPMultiplier() * npc.getLevel());
            }
            return totalHp;
        }
        if (isPlayer()) {
            ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getBukkitLivingEntity());
            if (solplayer == null)
                return totalHp;
            totalHp += Utils.getTotalEffectTotalHP(this.getBukkitLivingEntity());
            // get AA hp bonus
            totalHp += Utils.getTotalAAEffectMaxHp(this.getBukkitLivingEntity());
            return totalHp;
        }
    } catch (CoreStateInitException e) {
        return totalHp;
    }
    return totalHp;
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 18 with ISoliniaNPC

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

the class SoliniaLivingEntity method getWisdom.

@Override
public int getWisdom() {
    if (getNpcid() < 1 && !isPlayer())
        return 1;
    try {
        if (getNpcid() > 0) {
            ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
            if (npc == null)
                return 1;
            int stat = npc.getLevel() * 5;
            stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "WISDOM");
            if (stat > getMaxStat("WISDOM"))
                stat = getMaxStat("WISDOM");
            return stat;
        }
        if (isPlayer()) {
            ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getBukkitLivingEntity());
            if (solplayer == null)
                return 1;
            int stat = 1;
            if (solplayer.getRace() != null)
                stat += solplayer.getRace().getWisdom();
            stat += solplayer.getTotalItemStat("WISDOM");
            stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "WISDOM");
            stat += Utils.getTotalAAEffectStat(this.getBukkitLivingEntity(), "WISDOM");
            if (stat > getMaxStat("WISDOM"))
                stat = getMaxStat("WISDOM");
            return stat;
        }
    } catch (CoreStateInitException e) {
        return 1;
    }
    return 1;
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 19 with ISoliniaNPC

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

the class SoliniaLivingEntity method processInteractionEvent.

@Override
public void processInteractionEvent(LivingEntity triggerentity, InteractionType type, String data) {
    if (this.getNpcid() > 0) {
        ISoliniaNPC npc;
        try {
            npc = StateManager.getInstance().getConfigurationManager().getNPC(this.getNpcid());
            npc.processInteractionEvent(this, triggerentity, type, data);
        } catch (CoreStateInitException e) {
            e.printStackTrace();
        }
    }
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC)

Example 20 with ISoliniaNPC

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

the class SoliniaLivingEntity method getStamina.

@Override
public int getStamina() {
    if (getNpcid() < 1 && !isPlayer())
        return 1;
    try {
        if (getNpcid() > 0) {
            ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
            if (npc == null)
                return 1;
            int stat = npc.getLevel() * 5;
            stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "STAMINA");
            if (stat > getMaxStat("STAMINA"))
                stat = getMaxStat("STAMINA");
            return stat;
        }
        if (isPlayer()) {
            ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getBukkitLivingEntity());
            if (solplayer == null)
                return 1;
            int stat = 1;
            if (solplayer.getRace() != null)
                stat += solplayer.getRace().getStamina();
            stat += solplayer.getTotalItemStat("STAMINA");
            stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "STAMINA");
            stat += Utils.getTotalAAEffectStat(this.getBukkitLivingEntity(), "STAMINA");
            if (stat > getMaxStat("STAMINA"))
                stat = getMaxStat("STAMINA");
            return stat;
        }
    } catch (CoreStateInitException e) {
        return 1;
    }
    return 1;
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Aggregations

ISoliniaNPC (com.solinia.solinia.Interfaces.ISoliniaNPC)50 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)43 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)19 Player (org.bukkit.entity.Player)16 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)7 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)7 CommandSender (org.bukkit.command.CommandSender)6 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)6 LivingEntity (org.bukkit.entity.LivingEntity)6 ISoliniaNPCEventHandler (com.solinia.solinia.Interfaces.ISoliniaNPCEventHandler)5 ArrayList (java.util.ArrayList)5 InvalidNpcSettingException (com.solinia.solinia.Exceptions.InvalidNpcSettingException)4 Entity (org.bukkit.entity.Entity)4 ISoliniaFaction (com.solinia.solinia.Interfaces.ISoliniaFaction)3 ItemStack (org.bukkit.inventory.ItemStack)3 InvalidNPCEventSettingException (com.solinia.solinia.Exceptions.InvalidNPCEventSettingException)2 SoliniaItemException (com.solinia.solinia.Exceptions.SoliniaItemException)2 ISoliniaLootTable (com.solinia.solinia.Interfaces.ISoliniaLootTable)2 SoliniaNPC (com.solinia.solinia.Models.SoliniaNPC)2 SoliniaNPCEventHandler (com.solinia.solinia.Models.SoliniaNPCEventHandler)2