Search in sources :

Example 86 with CoreStateInitException

use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.

the class CommandGrantTitle method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player) && !(sender instanceof CommandSender)) {
        sender.sendMessage("This is a Player/Console only command");
        return false;
    }
    if (sender instanceof Player) {
        Player player = (Player) sender;
        if (!player.isOp()) {
            player.sendMessage("This is an operator only command");
            return true;
        }
    }
    if (args.length < 2)
        return false;
    if (Bukkit.getPlayer(args[0]) == null) {
        sender.sendMessage("Cannot find player");
        return true;
    }
    String targetTitle = "";
    int current = 0;
    for (String entry : args) {
        current++;
        if (current < 2)
            continue;
        targetTitle = targetTitle + entry + " ";
    }
    targetTitle = targetTitle.trim();
    try {
        ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(Bukkit.getPlayer(args[0]));
        boolean success = solplayer.grantTitle(targetTitle);
        if (success)
            sender.sendMessage("Player title granted: " + targetTitle);
        else
            sender.sendMessage("Player already has title: " + targetTitle);
        return true;
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        sender.sendMessage(e.getMessage());
        return true;
    }
}
Also used : ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) Player(org.bukkit.entity.Player) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) CommandSender(org.bukkit.command.CommandSender) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 87 with CoreStateInitException

use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.

the class CommandListItems 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.listitems")) {
            player.sendMessage("You do not have permission to access this command");
            return false;
        }
    }
    if (args.length == 0) {
        sender.sendMessage("You must provide some text to filter the item name by");
        return true;
    }
    // Filter for name
    int found = 0;
    try {
        for (ISoliniaItem item : StateManager.getInstance().getConfigurationManager().getItems()) {
            found++;
            if (item.getDisplayname().toUpperCase().contains(args[0].toUpperCase())) {
                String itemmessage = item.getId() + " - " + item.getDisplayname();
                sender.sendMessage(itemmessage);
            }
        }
        if (found == 0) {
            sender.sendMessage("Item could not be located by search string");
        }
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        sender.sendMessage(e.getMessage());
        e.printStackTrace();
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) ISoliniaItem(com.solinia.solinia.Interfaces.ISoliniaItem) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) CommandSender(org.bukkit.command.CommandSender) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender)

Example 88 with CoreStateInitException

use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.

the class SoliniaEntitySpells method removeSpell.

public void removeSpell(Plugin plugin, Integer spellId) {
    // Effect has worn off
    SoliniaActiveSpell activeSpell = activeSpells.get(spellId);
    if (activeSpell == null)
        return;
    boolean updateMaxHp = false;
    boolean updateDisguise = false;
    // Handle any effect removals needed
    for (ActiveSpellEffect effect : activeSpell.getActiveSpellEffects()) {
        switch(effect.getSpellEffectType()) {
            case TotalHP:
                updateMaxHp = true;
                break;
            case STA:
                updateMaxHp = true;
                break;
            case Illusion:
            case IllusionCopy:
            case IllusionOther:
            case IllusionPersistence:
            case IllusionaryTarget:
                updateDisguise = true;
                break;
        }
    }
    activeSpells.remove(spellId);
    if (updateMaxHp == true) {
        if (getLivingEntity() != null && getLivingEntity() instanceof Player) {
            try {
                ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getLivingEntity());
                if (solplayer != null)
                    solplayer.updateMaxHp();
            } catch (CoreStateInitException e) {
            }
        }
    }
    if (updateDisguise == true) {
        if (getLivingEntity() != null)
            DisguiseAPI.undisguiseToAll(getLivingEntity());
    }
    // Check if bard song, may need to keep singing
    if (activeSpell.getSpell().isBardSong()) {
        if (getLivingEntityUUID().equals(activeSpell.getSourceUuid())) {
            try {
                if (getLivingEntity() != null) {
                    if (StateManager.getInstance().getEntityManager().getEntitySinging(getLivingEntity().getUniqueId()) != null) {
                        Integer singingId = StateManager.getInstance().getEntityManager().getEntitySinging(getLivingEntity().getUniqueId());
                        if (singingId != activeSpell.getSpellId()) {
                            ISoliniaLivingEntity solEntity = SoliniaLivingEntityAdapter.Adapt(getLivingEntity());
                            solEntity.emote(getLivingEntity().getCustomName() + "'s song comes to a close [" + activeSpell.getSpell().getName() + "]");
                        } else {
                            // Continue singing!
                            if (Bukkit.getEntity(activeSpell.getOwnerUuid()) instanceof LivingEntity && Bukkit.getEntity(activeSpell.getSourceUuid()) instanceof LivingEntity) {
                                boolean itemUseSuccess = activeSpell.getSpell().tryApplyOnEntity(plugin, (LivingEntity) Bukkit.getEntity(activeSpell.getSourceUuid()), (LivingEntity) Bukkit.getEntity(activeSpell.getOwnerUuid()));
                                return;
                            }
                        }
                    } else {
                    // skip
                    }
                }
            } catch (CoreStateInitException e) {
            // ignore
            }
        }
    }
}
Also used : ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 89 with CoreStateInitException

use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.

the class SoliniaActiveSpell method applyRevive.

private void applyRevive(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int casterLevel) {
    if (!(getLivingEntity() instanceof Player)) {
        return;
    }
    Entity source = Bukkit.getEntity(getSourceUuid());
    if (!(source instanceof Player))
        return;
    Player sourcePlayer = (Player) source;
    if (!sourcePlayer.getInventory().getItemInOffHand().getType().equals(Material.NAME_TAG)) {
        sourcePlayer.sendMessage("You are not holding a Signaculum in your offhand (MC): " + sourcePlayer.getInventory().getItemInOffHand().getType().name());
        return;
    }
    ItemStack item = sourcePlayer.getInventory().getItemInOffHand();
    if (item.getEnchantmentLevel(Enchantment.DURABILITY) != 1) {
        sourcePlayer.sendMessage("You are not holding a Signaculum in your offhand (EC)");
        return;
    }
    if (!item.getItemMeta().getDisplayName().equals("Signaculum")) {
        sourcePlayer.sendMessage("You are not holding a Signaculum in your offhand (NC)");
        return;
    }
    if (item.getItemMeta().getLore().size() < 5) {
        sourcePlayer.sendMessage("You are not holding a Signaculum in your offhand (LC)");
        return;
    }
    String sigdataholder = item.getItemMeta().getLore().get(3);
    String[] sigdata = sigdataholder.split("\\|");
    if (sigdata.length != 2) {
        sourcePlayer.sendMessage("You are not holding a Signaculum in your offhand (SD)");
        return;
    }
    String str_experience = sigdata[0];
    String str_stimetsamp = sigdata[1];
    int experience = Integer.parseInt(str_experience);
    Timestamp timestamp = Timestamp.valueOf(str_stimetsamp);
    LocalDateTime datetime = LocalDateTime.now();
    Timestamp currenttimestamp = Timestamp.valueOf(datetime);
    long maxminutes = 60 * 7;
    if ((currenttimestamp.getTime() - timestamp.getTime()) >= maxminutes * 60 * 1000) {
        sourcePlayer.sendMessage("This Signaculum has lost its binding to the soul");
        return;
    }
    String playeruuidb64 = item.getItemMeta().getLore().get(4);
    String uuid = Utils.uuidFromBase64(playeruuidb64);
    Player targetplayer = Bukkit.getPlayer(UUID.fromString(uuid));
    if (targetplayer == null || !targetplayer.isOnline()) {
        sourcePlayer.sendMessage("You cannot resurrect that player as they are offline");
        return;
    }
    int multiplier = 1;
    if (spellEffect.getBase() > 0 && spellEffect.getBase() < 100)
        multiplier = spellEffect.getBase();
    try {
        double finalexperience = (experience / 100) * multiplier;
        SoliniaPlayerAdapter.Adapt(targetplayer).increasePlayerNormalExperience(finalexperience);
        targetplayer.sendMessage("You have been resurrected by " + sourcePlayer.getCustomName() + "!");
        targetplayer.teleport(sourcePlayer.getLocation());
        sourcePlayer.getInventory().setItemInOffHand(new ItemStack(Material.AIR));
    } catch (CoreStateInitException e) {
        return;
    }
    return;
}
Also used : LocalDateTime(java.time.LocalDateTime) CraftLivingEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) Entity(org.bukkit.entity.Entity) CraftEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity) LivingEntity(org.bukkit.entity.LivingEntity) PathEntity(net.minecraft.server.v1_12_R1.PathEntity) Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ItemStack(org.bukkit.inventory.ItemStack) Timestamp(java.sql.Timestamp)

Example 90 with CoreStateInitException

use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.

the class SoliniaActiveSpell method applySenseSummoned.

private void applySenseSummoned(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int casterLevel) {
    try {
        for (Entity e : this.getLivingEntity().getNearbyEntities(100, 100, 100)) {
            if (!(e instanceof LivingEntity))
                continue;
            if (!(e instanceof Creature))
                continue;
            ISoliniaLivingEntity solEntity = SoliniaLivingEntityAdapter.Adapt((LivingEntity) e);
            if (!solEntity.isPet())
                continue;
            Vector dir = ((LivingEntity) e).getLocation().clone().subtract(getLivingEntity().getEyeLocation()).toVector();
            Location loc = getLivingEntity().getLocation().setDirection(dir);
            getLivingEntity().teleport(loc);
        }
    } catch (CoreStateInitException e) {
    }
}
Also used : CraftLivingEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) CraftLivingEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) Entity(org.bukkit.entity.Entity) CraftEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity) LivingEntity(org.bukkit.entity.LivingEntity) PathEntity(net.minecraft.server.v1_12_R1.PathEntity) CraftCreature(org.bukkit.craftbukkit.v1_12_R1.entity.CraftCreature) Creature(org.bukkit.entity.Creature) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) Vector(org.bukkit.util.Vector) Location(org.bukkit.Location)

Aggregations

CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)216 Player (org.bukkit.entity.Player)114 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)99 ISoliniaNPC (com.solinia.solinia.Interfaces.ISoliniaNPC)43 CommandSender (org.bukkit.command.CommandSender)42 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)41 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)36 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)36 LivingEntity (org.bukkit.entity.LivingEntity)32 ArrayList (java.util.ArrayList)31 Entity (org.bukkit.entity.Entity)21 ItemStack (org.bukkit.inventory.ItemStack)20 SoliniaItemException (com.solinia.solinia.Exceptions.SoliniaItemException)17 ISoliniaSpell (com.solinia.solinia.Interfaces.ISoliniaSpell)16 EventHandler (org.bukkit.event.EventHandler)16 Timestamp (java.sql.Timestamp)13 TextComponent (net.md_5.bungee.api.chat.TextComponent)12 CraftEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity)11 CraftLivingEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity)11 PathEntity (net.minecraft.server.v1_12_R1.PathEntity)10