Search in sources :

Example 11 with ISoliniaItem

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

the class Solinia3CorePlayerListener method onPlayerConsumeEvent.

@EventHandler
public void onPlayerConsumeEvent(PlayerItemConsumeEvent event) {
    if (event.isCancelled())
        return;
    try {
        ISoliniaItem item = SoliniaItemAdapter.Adapt(event.getItem());
        item.consume(plugin, event.getPlayer());
    } catch (SoliniaItemException | CoreStateInitException e) {
    }
}
Also used : ISoliniaItem(com.solinia.solinia.Interfaces.ISoliniaItem) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) SoliniaItemException(com.solinia.solinia.Exceptions.SoliniaItemException) EventHandler(org.bukkit.event.EventHandler)

Example 12 with ISoliniaItem

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

the class ChannelManager method sendItemListToDiscordChannel.

private void sendItemListToDiscordChannel(DiscordChannel discordChannel, String itemMatch) {
    try {
        String targetChannelId = getDefaultDiscordChannel();
        if (discordChannel.equals(DiscordChannel.ADMIN))
            targetChannelId = getAdminDiscordChannel();
        int itemId = 0;
        try {
            itemId = StateManager.getInstance().getConfigurationManager().getItem(Integer.parseInt(itemMatch)).getId();
        } catch (Exception e) {
        }
        if (itemId > 0) {
            ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(itemId);
            sendItemToDiscordChannel(discordChannel, item);
            return;
        }
        if (itemMatch.length() < 3) {
            sendToDiscordMC(null, targetChannelId, "Item search must be at least 3 characters: " + itemMatch);
            return;
        }
        List<ISoliniaItem> items = StateManager.getInstance().getConfigurationManager().getItemsByPartialName(itemMatch);
        if (items.size() > 20) {
            sendToDiscordMC(null, targetChannelId, "Item matched more than 20 items, please be more specific than " + itemMatch);
            return;
        }
        if (items.size() != 1) {
            List<String> matchingItemList = new ArrayList<String>();
            String currentLine = "";
            for (ISoliniaItem item : items) {
                if ((currentLine + "[" + item.getId() + "] " + item.getDisplayname() + " ").length() > 2000) {
                    matchingItemList.add(currentLine);
                    currentLine = "";
                }
                currentLine += "[" + item.getId() + "] " + item.getDisplayname() + " ";
            }
            if (!currentLine.equals("")) {
                matchingItemList.add(currentLine);
            }
            for (String line : matchingItemList) {
                sendToDiscordMC(null, targetChannelId, "Item [" + itemMatch + "] matched with: " + line);
            }
        } else {
            for (ISoliniaItem item : items) {
                sendItemToDiscordChannel(discordChannel, item);
            }
        }
    } catch (CoreStateInitException e) {
    // ignore it
    }
}
Also used : ISoliniaItem(com.solinia.solinia.Interfaces.ISoliniaItem) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ArrayList(java.util.ArrayList) EventException(org.bukkit.event.EventException) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException)

Example 13 with ISoliniaItem

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

the class SoliniaLootTable method sendLootTableSettingsToSender.

@Override
public void sendLootTableSettingsToSender(CommandSender sender) {
    try {
        for (ISoliniaLootTableEntry le : getEntries()) {
            ISoliniaLootDrop ld = StateManager.getInstance().getConfigurationManager().getLootDrop(le.getLootdropid());
            sender.sendMessage("- " + ChatColor.GOLD + ld.getName().toUpperCase() + ChatColor.RESET + "[" + ld.getId() + "]:");
            for (ISoliniaLootDropEntry lde : ld.getEntries()) {
                ISoliniaItem i = StateManager.getInstance().getConfigurationManager().getItem(lde.getItemid());
                sender.sendMessage("  - " + ChatColor.GOLD + i.getDisplayname() + ChatColor.RESET + "[" + i.getId() + "] - " + lde.getChance() + "% chance Count: " + lde.getCount() + " Always: " + lde.isAlways());
            }
        }
    } catch (CoreStateInitException e) {
        sender.sendMessage(e.getMessage());
    }
}
Also used : ISoliniaLootDropEntry(com.solinia.solinia.Interfaces.ISoliniaLootDropEntry) ISoliniaItem(com.solinia.solinia.Interfaces.ISoliniaItem) ISoliniaLootTableEntry(com.solinia.solinia.Interfaces.ISoliniaLootTableEntry) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaLootDrop(com.solinia.solinia.Interfaces.ISoliniaLootDrop)

Example 14 with ISoliniaItem

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

the class SoliniaNPCEventHandler method editTriggerEventSetting.

@Override
public void editTriggerEventSetting(String setting, String value) throws InvalidNPCEventSettingException {
    switch(setting.toLowerCase()) {
        case "randomisedgearsuffix":
            setRandomisedGearSuffix(value);
            break;
        case "title":
            setTitle(value);
            break;
        case "awardstitle":
            setAwardsTitle(Boolean.parseBoolean(value));
            break;
        case "triggerdata":
            if (value.equals(""))
                throw new InvalidNPCEventSettingException("Triggerdata is empty");
            if (value.contains(" "))
                throw new InvalidNPCEventSettingException("Triggerdata can only be one value");
            setTriggerdata(value.toUpperCase());
            break;
        case "chatresponse":
            if (value.equals(""))
                throw new InvalidNPCEventSettingException("Chatresponse is empty");
            setChatresponse(value);
            break;
        case "requiresquest":
            int questid = Integer.parseInt(value);
            if (questid < 1)
                throw new InvalidNPCEventSettingException("Invalid quest id");
            try {
                ISoliniaQuest quest = StateManager.getInstance().getConfigurationManager().getQuest(questid);
                if (quest == null)
                    throw new InvalidNPCEventSettingException("Invalid quest id");
            } catch (CoreStateInitException e) {
                throw new InvalidNPCEventSettingException("State not initialised");
            }
            setRequiresQuest(questid);
            break;
        case "awardsquest":
            int aquestid = Integer.parseInt(value);
            if (aquestid < 1)
                throw new InvalidNPCEventSettingException("Invalid quest id");
            try {
                ISoliniaQuest quest = StateManager.getInstance().getConfigurationManager().getQuest(aquestid);
                if (quest == null)
                    throw new InvalidNPCEventSettingException("Invalid quest id");
            } catch (CoreStateInitException e) {
                throw new InvalidNPCEventSettingException("State not initialised");
            }
            setAwardsQuest(aquestid);
            break;
        case "requiresquestflag":
            setRequiresQuestFlag(value);
            break;
        case "awardsquestflag":
            setAwardsQuestFlag(value);
            break;
        case "teleportresponse":
            try {
                String[] zonedata = value.split(",");
                // Dissasemble the value to ensure it is correct
                String world = zonedata[0];
                double x = Double.parseDouble(zonedata[1]);
                double y = Double.parseDouble(zonedata[2]);
                double z = Double.parseDouble(zonedata[3]);
                setTeleportResponse(world + "," + x + "," + y + "," + z);
                break;
            } catch (Exception e) {
                throw new InvalidNPCEventSettingException("Teleport zone value must be in format: world,x,y,z");
            }
        case "awardsrandomisedgear":
            setAwardsRandomisedGear(Boolean.parseBoolean(value));
            break;
        case "awardsitem":
            int itemId = Integer.parseInt(value);
            if (itemId < 1)
                throw new InvalidNPCEventSettingException("Invalid item ID");
            if (getAwardsQuestFlag() == null || getAwardsQuestFlag().equals(""))
                throw new InvalidNPCEventSettingException("You cannot set an awardsitem to a npc event handler unless the npc awards a quest flag -  this is to prevent duplicated awards");
            try {
                ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(itemId);
                if (item == null)
                    throw new InvalidNPCEventSettingException("Invalid item id");
            } catch (CoreStateInitException e) {
                throw new InvalidNPCEventSettingException("State not initialised");
            }
            setAwardsItem(itemId);
            break;
        default:
            throw new InvalidNPCEventSettingException("Invalid NPC Event setting. Valid Options are: triggerdata,chatresponse,interactiontype,requiresquest,awardsquest,requiresquestflag,awardsquestflag,awardsitem");
    }
}
Also used : ISoliniaQuest(com.solinia.solinia.Interfaces.ISoliniaQuest) ISoliniaItem(com.solinia.solinia.Interfaces.ISoliniaItem) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) InvalidNPCEventSettingException(com.solinia.solinia.Exceptions.InvalidNPCEventSettingException) InvalidNPCEventSettingException(com.solinia.solinia.Exceptions.InvalidNPCEventSettingException) InvalidNpcSettingException(com.solinia.solinia.Exceptions.InvalidNpcSettingException) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) InvalidSpellSettingException(com.solinia.solinia.Exceptions.InvalidSpellSettingException) SoliniaItemException(com.solinia.solinia.Exceptions.SoliniaItemException)

Example 15 with ISoliniaItem

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

the class SoliniaPlayer method getTotalResist.

@Override
public int getTotalResist(SpellResistType type) {
    int total = 0;
    // Get resist total from all active effects
    try {
        total += SoliniaLivingEntityAdapter.Adapt(getBukkitPlayer()).getResistsFromActiveEffects(type);
        int effectId = 0;
        switch(type) {
            case RESIST_FIRE:
                effectId = Utils.getEffectIdFromEffectType(SpellEffectType.ResistFire);
                break;
            case RESIST_COLD:
                effectId = Utils.getEffectIdFromEffectType(SpellEffectType.ResistCold);
                break;
            case RESIST_MAGIC:
                effectId = Utils.getEffectIdFromEffectType(SpellEffectType.ResistMagic);
                break;
            case RESIST_POISON:
                effectId = Utils.getEffectIdFromEffectType(SpellEffectType.ResistPoison);
                break;
            case RESIST_DISEASE:
                effectId = Utils.getEffectIdFromEffectType(SpellEffectType.ResistDisease);
                break;
            default:
                break;
        }
        if (effectId > 0) {
            for (SoliniaAARankEffect effect : this.getRanksEffectsOfEffectType(effectId)) {
                total += effect.getBase1();
            }
        }
        int resistAllEffectId = Utils.getEffectIdFromEffectType(SpellEffectType.ResistAll);
        for (SoliniaAARankEffect effect : this.getRanksEffectsOfEffectType(resistAllEffectId)) {
            total += effect.getBase1();
        }
    } catch (CoreStateInitException e) {
    // Skip
    }
    for (ISoliniaItem item : this.getEquippedSoliniaItems()) {
        switch(type) {
            case RESIST_FIRE:
                if (item.getFireResist() > 0) {
                    total += item.getFireResist();
                }
                break;
            case RESIST_COLD:
                if (item.getColdResist() > 0) {
                    total += item.getColdResist();
                }
                break;
            case RESIST_MAGIC:
                if (item.getMagicResist() > 0) {
                    total += item.getMagicResist();
                }
                break;
            case RESIST_POISON:
                if (item.getPoisonResist() > 0) {
                    total += item.getPoisonResist();
                }
                break;
            case RESIST_DISEASE:
                if (item.getDiseaseResist() > 0) {
                    total += item.getDiseaseResist();
                }
                break;
            default:
                break;
        }
    }
    if (total > 255)
        return 255;
    return total;
}
Also used : ISoliniaItem(com.solinia.solinia.Interfaces.ISoliniaItem) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException)

Aggregations

ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)41 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)37 ItemStack (org.bukkit.inventory.ItemStack)18 Player (org.bukkit.entity.Player)16 SoliniaItemException (com.solinia.solinia.Exceptions.SoliniaItemException)14 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)14 ArrayList (java.util.ArrayList)12 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)7 ISoliniaNPC (com.solinia.solinia.Interfaces.ISoliniaNPC)7 LivingEntity (org.bukkit.entity.LivingEntity)7 TextComponent (net.md_5.bungee.api.chat.TextComponent)5 CommandSender (org.bukkit.command.CommandSender)5 Entity (org.bukkit.entity.Entity)5 EventHandler (org.bukkit.event.EventHandler)5 ISoliniaLootDropEntry (com.solinia.solinia.Interfaces.ISoliniaLootDropEntry)4 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)4 ISoliniaLootDrop (com.solinia.solinia.Interfaces.ISoliniaLootDrop)3 ISoliniaLootTableEntry (com.solinia.solinia.Interfaces.ISoliniaLootTableEntry)3 ISoliniaSpell (com.solinia.solinia.Interfaces.ISoliniaSpell)3 ISoliniaLootTable (com.solinia.solinia.Interfaces.ISoliniaLootTable)2