Search in sources :

Example 26 with ISoliniaPlayer

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

the class ConfigurationManager method commitPlayersToCharacterLists.

private void commitPlayersToCharacterLists() {
    try {
        int count = 0;
        for (ISoliniaPlayer player : StateManager.getInstance().getPlayerManager().getPlayers()) {
            commitPlayerToCharacterLists(player);
            count++;
        }
        System.out.println("Commited " + count + " characters to the CharacterList repository");
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 27 with ISoliniaPlayer

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

the class Solinia3CorePlayerListener method onPlayerRespawn.

@EventHandler
public void onPlayerRespawn(PlayerRespawnEvent event) {
    try {
        ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(event.getPlayer());
        if (solplayer != null) {
            solplayer.updateMaxHp();
            if (solplayer.getBindPoint() != null && !solplayer.getBindPoint().equals("")) {
                String[] loc = solplayer.getBindPoint().split(",");
                Location location = new Location(Bukkit.getWorld(loc[0]), Double.parseDouble(loc[1]), Double.parseDouble(loc[2]), Double.parseDouble(loc[3]));
                event.setRespawnLocation(location);
                event.getPlayer().teleport(location);
            }
        }
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 28 with ISoliniaPlayer

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

the class SoliniaNPC method processChatInteractionEvent.

@Override
public void processChatInteractionEvent(SoliniaLivingEntity solentity, LivingEntity triggerentity, String data) {
    String[] words = data.split(" ");
    // Merchant special commands
    if (words.length > 0) {
        // Check player has sufficient faction
        if (triggerentity instanceof Player)
            if (solentity.getNpcid() > 0) {
                try {
                    ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(solentity.getNpcid());
                    if (npc.getFactionid() > 0) {
                        ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt((Player) triggerentity);
                        PlayerFactionEntry factionEntry = solPlayer.getFactionEntry(npc.getFactionid());
                        if (factionEntry != null) {
                            switch(Utils.getFactionStandingType(factionEntry.getFactionId(), factionEntry.getValue())) {
                                case FACTION_THREATENLY:
                                case FACTION_SCOWLS:
                                    solentity.emote("* " + npc.getName() + " scowls angrily at " + solPlayer.getFullName());
                                    return;
                                default:
                                    break;
                            }
                        }
                    }
                } catch (CoreStateInitException e) {
                }
            }
        switch(words[0].toUpperCase()) {
            case "SHOP":
                if (triggerentity instanceof Player)
                    if (getMerchantid() > 0) {
                        if (words.length == 1) {
                            sendMerchantItemListToPlayer((Player) triggerentity, 1);
                            return;
                        }
                        int page = 1;
                        try {
                            page = Integer.parseInt(words[1]);
                        } catch (Exception e) {
                        }
                        if (page < 1)
                            page = 1;
                        sendMerchantItemListToPlayer((Player) triggerentity, page);
                    }
                return;
            case "LISTEFFECTS":
                if (triggerentity instanceof Player) {
                    if (((Player) triggerentity).isOp()) {
                        Player player = (Player) triggerentity;
                        try {
                            for (SoliniaActiveSpell spell : StateManager.getInstance().getEntityManager().getActiveEntitySpells(solentity.getBukkitLivingEntity()).getActiveSpells()) {
                                player.sendMessage(spell.getSpell().getName());
                                for (ActiveSpellEffect effect : spell.getActiveSpellEffects()) {
                                    player.sendMessage(" - " + effect.getSpellEffectType().name() + " " + effect.getBase());
                                }
                            }
                        } catch (CoreStateInitException e) {
                        // 
                        }
                    }
                }
                return;
            default:
                break;
        }
    }
    // Normal text matching
    for (ISoliniaNPCEventHandler handler : getEventHandlers()) {
        if (!handler.getInteractiontype().equals(InteractionType.CHAT))
            continue;
        if (!data.toUpperCase().contains(handler.getTriggerdata().toUpperCase()))
            continue;
        if (handler.getChatresponse() != null && !handler.getChatresponse().equals("")) {
            if ((triggerentity instanceof Player)) {
                if (!handler.playerMeetsRequirements((Player) triggerentity))
                    return;
            }
            String response = handler.getChatresponse();
            solentity.say(replaceChatWordsWithHints(response), triggerentity);
            if (triggerentity instanceof Player)
                handler.awardPlayer((Player) triggerentity);
            if (handler.getTeleportResponse() != null && !handler.getTeleportResponse().equals("")) {
                if (triggerentity instanceof Player) {
                    String[] zonedata = handler.getTeleportResponse().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]);
                    Location loc = new Location(Bukkit.getWorld(world), x, y, z);
                    ((Player) triggerentity).teleport(loc);
                }
            }
        }
    }
    return;
}
Also used : Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) ISoliniaNPCEventHandler(com.solinia.solinia.Interfaces.ISoliniaNPCEventHandler) InvalidNPCEventSettingException(com.solinia.solinia.Exceptions.InvalidNPCEventSettingException) InvalidNpcSettingException(com.solinia.solinia.Exceptions.InvalidNpcSettingException) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) Location(org.bukkit.Location)

Example 29 with ISoliniaPlayer

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

the class SoliniaLivingEntity method checkHitChance.

@Override
public boolean checkHitChance(SoliniaLivingEntity attacker, DamageHitInfo hit) {
    ISoliniaLivingEntity defender = this;
    if (defender.isPlayer()) {
        try {
            ISoliniaPlayer player = SoliniaPlayerAdapter.Adapt((Player) defender.getBukkitLivingEntity());
            if (player.isMeditating()) {
                return true;
            }
        } catch (CoreStateInitException e) {
        // ignore it
        }
    }
    int avoidance = defender.getTotalDefense();
    int accuracy = hit.tohit;
    // if (accuracy == -1)
    // return true;
    double hitRoll = Utils.RandomBetween(0, (int) Math.floor(accuracy));
    double avoidRoll = Utils.RandomBetween(0, (int) Math.floor(avoidance));
    // tie breaker? Don't want to be biased any one way
    return hitRoll > avoidRoll;
}
Also used : ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 30 with ISoliniaPlayer

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

the class SoliniaLivingEntity method getStrength.

@Override
public int getStrength() {
    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(), "STRENGTH");
            if (stat > getMaxStat("STRENGTH"))
                stat = getMaxStat("STRENGTH");
            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().getStrength();
            stat += solplayer.getTotalItemStat("STRENGTH");
            stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "STRENGTH");
            stat += Utils.getTotalAAEffectStat(this.getBukkitLivingEntity(), "STRENGTH");
            if (stat > getMaxStat("STRENGTH"))
                stat = getMaxStat("STRENGTH");
            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

ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)89 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)85 Player (org.bukkit.entity.Player)57 ISoliniaNPC (com.solinia.solinia.Interfaces.ISoliniaNPC)16 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)13 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)12 EventHandler (org.bukkit.event.EventHandler)11 LivingEntity (org.bukkit.entity.LivingEntity)10 ArrayList (java.util.ArrayList)9 UUID (java.util.UUID)9 SoliniaItemException (com.solinia.solinia.Exceptions.SoliniaItemException)8 TextComponent (net.md_5.bungee.api.chat.TextComponent)8 ItemStack (org.bukkit.inventory.ItemStack)8 CommandSender (org.bukkit.command.CommandSender)5 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)5 Entity (org.bukkit.entity.Entity)5 Timestamp (java.sql.Timestamp)4 LocalDateTime (java.time.LocalDateTime)4 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)4 HoverEvent (net.md_5.bungee.api.chat.HoverEvent)4