Search in sources :

Example 61 with ISoliniaPlayer

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

the class Utils method getTotalAAEffectMaxHp.

public static double getTotalAAEffectMaxHp(LivingEntity bukkitLivingEntity) {
    if (!(bukkitLivingEntity instanceof Player))
        return 0;
    try {
        ISoliniaPlayer player = SoliniaPlayerAdapter.Adapt((Player) bukkitLivingEntity);
        int total = 0;
        int effectIdLookup = 0;
        effectIdLookup = Utils.getEffectIdFromEffectType(SpellEffectType.MaxHPChange);
        if (effectIdLookup > 0) {
            for (SoliniaAARankEffect effect : player.getRanksEffectsOfEffectType(effectIdLookup)) {
                total += effect.getBase1();
            }
        }
        effectIdLookup = Utils.getEffectIdFromEffectType(SpellEffectType.TotalHP);
        if (effectIdLookup > 0) {
            for (SoliniaAARankEffect effect : player.getRanksEffectsOfEffectType(effectIdLookup)) {
                total += effect.getBase1();
            }
        }
        return total;
    } catch (CoreStateInitException e) {
        return 0;
    }
}
Also used : Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) SoliniaAARankEffect(com.solinia.solinia.Models.SoliniaAARankEffect) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 62 with ISoliniaPlayer

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

the class Utils method getTotalAAEffectEffectType.

public static int getTotalAAEffectEffectType(LivingEntity bukkitLivingEntity, SpellEffectType effectType) {
    if (!(bukkitLivingEntity instanceof Player))
        return 0;
    try {
        ISoliniaPlayer player = SoliniaPlayerAdapter.Adapt((Player) bukkitLivingEntity);
        int total = 0;
        for (SoliniaAARankEffect effect : player.getRanksEffectsOfEffectType(Utils.getEffectIdFromEffectType(effectType))) {
            total += effect.getBase1();
        }
        return total;
    } catch (CoreStateInitException e) {
        return 0;
    }
}
Also used : Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) SoliniaAARankEffect(com.solinia.solinia.Models.SoliniaAARankEffect) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 63 with ISoliniaPlayer

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

the class CommandCraft method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player)) {
        return false;
    }
    Player player = (Player) sender;
    ItemStack primaryItem = player.getInventory().getItemInMainHand();
    if (primaryItem.getType().equals(Material.AIR)) {
        player.sendMessage(ChatColor.GRAY + "Empty item in primary hand. You must hold the item you want to use in your crafting recipe");
        return false;
    }
    ItemStack secondaryItem = player.getInventory().getItemInOffHand();
    if (secondaryItem.getType().equals(Material.AIR)) {
        player.sendMessage(ChatColor.GRAY + "Empty item in offhand. You must hold the item you want to use in your crafting recipe");
        return false;
    }
    if (primaryItem.getAmount() > 1) {
        player.sendMessage(ChatColor.GRAY + "Stack size in primary hand is too high (max 1)");
        return false;
    }
    if (secondaryItem.getAmount() > 1) {
        player.sendMessage(ChatColor.GRAY + "Stack size in secondary hand is too high (max 1)");
        return false;
    }
    if (!Utils.IsSoliniaItem(primaryItem)) {
        player.sendMessage("You can only create a new item from solinia items, not minecraft items");
        return true;
    }
    if (!Utils.IsSoliniaItem(secondaryItem)) {
        player.sendMessage("You can only create a new item from solinia items, not minecraft items");
        return true;
    }
    try {
        ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt(player);
        ISoliniaItem primarysolItem = SoliniaItemAdapter.Adapt(primaryItem);
        ISoliniaItem secondarysolItem = SoliniaItemAdapter.Adapt(secondaryItem);
        List<SoliniaCraft> craft = StateManager.getInstance().getConfigurationManager().getCrafts(primarysolItem.getId(), secondarysolItem.getId());
        if (craft.size() < 1) {
            player.sendMessage("You do not seem to know how to make anything with these items");
            return true;
        }
        int createCount = 0;
        for (SoliniaCraft craftEntry : craft) {
            if (craftEntry.getClassId() > 0) {
                if (solPlayer.getClassObj() == null) {
                    player.sendMessage("You do not seem to know how to make anything with these items");
                    continue;
                }
                if (solPlayer.getClassObj().getId() != craftEntry.getClassId()) {
                    player.sendMessage("You do not seem to know how to make anything with these items");
                    continue;
                }
            }
            if (craftEntry.getSkilltype() != SkillType.None) {
                if (craftEntry.getMinSkill() > 0) {
                    SoliniaPlayerSkill skill = solPlayer.getSkill(craftEntry.getSkilltype().name().toUpperCase());
                    if (skill == null) {
                        player.sendMessage("You do not seem to know how to make anything with these items");
                        continue;
                    }
                    if (skill.getValue() < craftEntry.getMinSkill()) {
                        player.sendMessage("You do not seem to know how to make anything with these items");
                        continue;
                    }
                }
            }
            ISoliniaItem outputItem = StateManager.getInstance().getConfigurationManager().getItem(craftEntry.getOutputItem());
            if (outputItem != null) {
                player.getWorld().dropItemNaturally(player.getLocation(), outputItem.asItemStack());
                player.sendMessage("You fashion the items together to make something new!");
                createCount++;
                if (craftEntry.getSkilltype() != SkillType.None) {
                    solPlayer.tryIncreaseSkill(craftEntry.getSkilltype().name().toUpperCase(), 1);
                }
            }
        }
        if (createCount > 0) {
            player.getInventory().setItemInMainHand(null);
            player.getInventory().setItemInOffHand(null);
            player.updateInventory();
        }
    } catch (CoreStateInitException e) {
    } catch (SoliniaItemException e) {
        player.sendMessage("Item no longer exists");
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) ISoliniaItem(com.solinia.solinia.Interfaces.ISoliniaItem) SoliniaPlayerSkill(com.solinia.solinia.Models.SoliniaPlayerSkill) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) SoliniaCraft(com.solinia.solinia.Models.SoliniaCraft) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) ItemStack(org.bukkit.inventory.ItemStack) SoliniaItemException(com.solinia.solinia.Exceptions.SoliniaItemException)

Example 64 with ISoliniaPlayer

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

the class Solinia3CoreEntityListener method onEntityTargetEvent.

// Needs to occur before anything else
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityTargetEvent(EntityTargetEvent event) {
    if (event.isCancelled())
        return;
    if (!(event.getEntity() instanceof Creature))
        return;
    try {
        Timestamp mzExpiry = StateManager.getInstance().getEntityManager().getMezzed((LivingEntity) event.getEntity());
        if (mzExpiry != null) {
            if (event.getEntity() instanceof Player) {
                event.getEntity().sendMessage("* You are mezzed!");
            }
            Utils.CancelEvent(event);
            ;
            return;
        }
    } catch (CoreStateInitException e) {
    }
    try {
        // Me
        ISoliniaLivingEntity solEntity = SoliniaLivingEntityAdapter.Adapt((LivingEntity) event.getEntity());
        if (solEntity.isUndead() && !(event.getEntity() instanceof Player) && event.getTarget() instanceof LivingEntity) {
            if (StateManager.getInstance().getEntityManager().hasEntityEffectType((LivingEntity) event.getTarget(), SpellEffectType.InvisVsUndead) || StateManager.getInstance().getEntityManager().hasEntityEffectType((LivingEntity) event.getTarget(), SpellEffectType.InvisVsUndead2)) {
                ((Creature) event.getEntity()).setTarget(null);
                Utils.CancelEvent(event);
                ;
                return;
            }
        }
        if (!solEntity.isUndead() && !(event.getEntity() instanceof Player) && !solEntity.isAnimal() && event.getTarget() instanceof LivingEntity) {
            if (StateManager.getInstance().getEntityManager().hasEntityEffectType((LivingEntity) event.getTarget(), SpellEffectType.Invisibility) || StateManager.getInstance().getEntityManager().hasEntityEffectType((LivingEntity) event.getTarget(), SpellEffectType.Invisibility2)) {
                ((Creature) event.getEntity()).setTarget(null);
                Utils.CancelEvent(event);
                ;
                return;
            }
        }
        if (solEntity.isAnimal() && !(event.getEntity() instanceof Player) && event.getTarget() instanceof LivingEntity) {
            if (StateManager.getInstance().getEntityManager().hasEntityEffectType((LivingEntity) event.getTarget(), SpellEffectType.InvisVsAnimals) || StateManager.getInstance().getEntityManager().hasEntityEffectType((LivingEntity) event.getTarget(), SpellEffectType.ImprovedInvisAnimals)) {
                ((Creature) event.getEntity()).setTarget(null);
                Utils.CancelEvent(event);
                ;
                return;
            }
        }
        // rogue sneak
        if (event.getTarget() instanceof Player && !(event.getEntity() instanceof Player)) {
            Player targetPlayer = (Player) event.getTarget();
            if (targetPlayer.isSneaking()) {
                ISoliniaPlayer player = SoliniaPlayerAdapter.Adapt((Player) event.getTarget());
                if (player.getClassObj() != null) {
                    if (player.getClassObj().isSneakFromCrouch()) {
                        Utils.CancelEvent(event);
                        ;
                        return;
                    }
                }
            }
        }
        if (event.getEntity() != null && event.getTarget() != null) {
            if (!(event.getEntity() instanceof Player)) {
                if (event.getEntity() instanceof LivingEntity) {
                    ISoliniaLivingEntity livingEntity = SoliniaLivingEntityAdapter.Adapt((LivingEntity) event.getEntity());
                }
                // Mez cancel target
                Timestamp mezExpiry = StateManager.getInstance().getEntityManager().getMezzed((LivingEntity) event.getTarget());
                if (mezExpiry != null) {
                    ((Creature) event.getEntity()).setTarget(null);
                    event.getEntity().sendMessage("The target is mezzed, you cannot hit it");
                    Utils.CancelEvent(event);
                    ;
                    return;
                }
            }
        }
    } catch (CoreStateInitException e) {
        return;
    }
}
Also used : ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) Creature(org.bukkit.entity.Creature) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) Timestamp(java.sql.Timestamp) EventHandler(org.bukkit.event.EventHandler)

Example 65 with ISoliniaPlayer

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

the class CommandWho method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (sender instanceof Player) {
        Player player = (Player) sender;
        for (Player currentplayer : Bukkit.getServer().getOnlinePlayers()) {
            try {
                ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(currentplayer);
                int lvl = (int) Math.floor(solplayer.getLevel());
                String racename = "UNKNOWN";
                String classname = "UNKNOWN";
                if (solplayer.getRace() != null)
                    racename = solplayer.getRace().getName();
                if (solplayer.getClassObj() != null)
                    classname = solplayer.getClassObj().getName();
                player.sendMessage("[" + currentplayer.getName() + "]" + ChatColor.YELLOW + solplayer.getFullName().toUpperCase() + ChatColor.RESET + " [" + currentplayer.getWorld().getName() + "] - LVL " + ChatColor.AQUA + lvl + ChatColor.RESET + " " + racename + " " + ChatColor.AQUA + classname + ChatColor.RESET);
            } catch (CoreStateInitException e) {
            }
        }
    }
    if ((sender instanceof ConsoleCommandSender || sender instanceof DiscordDefaultChannelCommandSender || sender instanceof DiscordAdminChannelCommandSender)) {
        CommandSender player = (CommandSender) sender;
        for (Player currentplayer : Bukkit.getServer().getOnlinePlayers()) {
            ISoliniaPlayer solplayer;
            try {
                solplayer = SoliniaPlayerAdapter.Adapt(currentplayer);
                int lvl = (int) Math.floor(solplayer.getLevel());
                String racename = "UNKNOWN";
                String classname = "UNKNOWN";
                if (solplayer.getRace() != null)
                    racename = solplayer.getRace().getName();
                if (solplayer.getClassObj() != null)
                    classname = solplayer.getClassObj().getName();
                player.sendMessage("[" + currentplayer.getName() + "]" + ChatColor.YELLOW + solplayer.getFullName().toUpperCase() + ChatColor.RESET + " [" + currentplayer.getWorld().getName() + "] - LVL " + ChatColor.AQUA + lvl + ChatColor.RESET + " " + racename + " " + ChatColor.AQUA + classname + ChatColor.RESET);
            } catch (CoreStateInitException e) {
            }
        }
    }
    return true;
}
Also used : ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) Player(org.bukkit.entity.Player) DiscordAdminChannelCommandSender(com.solinia.solinia.Providers.DiscordAdminChannelCommandSender) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) DiscordDefaultChannelCommandSender(com.solinia.solinia.Providers.DiscordDefaultChannelCommandSender) CommandSender(org.bukkit.command.CommandSender) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender) DiscordDefaultChannelCommandSender(com.solinia.solinia.Providers.DiscordDefaultChannelCommandSender) DiscordAdminChannelCommandSender(com.solinia.solinia.Providers.DiscordAdminChannelCommandSender) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender)

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