Search in sources :

Example 46 with CoreStateInitException

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

the class CommandAddClass 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;
    String classname = args[0];
    boolean adminonly = Boolean.parseBoolean(args[1]);
    try {
        SoliniaClassFactory.CreateClass(classname, adminonly);
        sender.sendMessage("* Class created");
    } catch (CoreStateInitException | SoliniaClassCreationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        sender.sendMessage("Error: " + e.getMessage());
        return true;
    }
    return true;
}
Also used : SoliniaClassCreationException(com.solinia.solinia.Exceptions.SoliniaClassCreationException) Player(org.bukkit.entity.Player) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) CommandSender(org.bukkit.command.CommandSender) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender)

Example 47 with CoreStateInitException

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

the class ChannelManager method sendItemToDiscordChannel.

private void sendItemToDiscordChannel(DiscordChannel discordChannel, ISoliniaItem item) {
    String targetChannelId = getDefaultDiscordChannel();
    if (discordChannel.equals(DiscordChannel.ADMIN))
        targetChannelId = getAdminDiscordChannel();
    String proc = "";
    if (item.getWeaponabilityid() > 0) {
        try {
            ISoliniaSpell spell = StateManager.getInstance().getConfigurationManager().getSpell(item.getWeaponabilityid());
            proc = "Chance to Proc on Hit: " + ChatColor.YELLOW + spell.getName() + ChatColor.RESET;
        } catch (CoreStateInitException e) {
        // 
        }
    }
    sendToDiscordMC(null, targetChannelId, "Item " + item.getId() + " (" + item.getDisplayname() + ") Base: " + item.getBasename() + " MinLevel: " + item.getMinLevel());
    sendToDiscordMC(null, targetChannelId, "Damage " + item.getDamage() + " UndeadBaneDmg: " + item.getBaneUndead() + " AC: " + item.getAC() + " Proc: " + proc + " Worth: $" + item.getWorth());
    sendToDiscordMC(null, targetChannelId, "Strength: " + item.getStrength() + " Stamina: " + item.getStamina() + " Agility: " + item.getAgility() + " Dexterity: " + item.getDexterity() + " Intelligence: " + item.getIntelligence() + " Wisdom: " + item.getWisdom() + " Charisma: " + item.getCharisma());
    sendToDiscordMC(null, targetChannelId, "DR: " + item.getDiseaseResist() + " CR: " + item.getColdResist() + " FR: " + item.getFireResist() + " PR: " + item.getPoisonResist() + " MR: " + item.getMagicResist());
    sendToDiscordMC(null, targetChannelId, "HP: " + item.getHp() + " Mana: " + item.getMana() + " HPRegen: " + item.getHpregen() + " MPRegen: " + item.getMpregen() + " Temporary: " + item.isTemporary() + " Augmentation " + item.isAugmentation() + " Quest: " + item.isQuest());
    sendToDiscordMC(null, targetChannelId, "Accepts Aug Type: " + item.getAcceptsAugmentationSlotType().name() + " Fits Aug Types: " + item.getAugmentationFitsSlotType().name());
}
Also used : ISoliniaSpell(com.solinia.solinia.Interfaces.ISoliniaSpell) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException)

Example 48 with CoreStateInitException

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

the class Solinia3CorePlayerListener method onPlayerSwapHandItems.

@EventHandler
public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
    if (event.isCancelled())
        return;
    try {
        ItemStack itemstack = event.getOffHandItem();
        if (itemstack == null)
            return;
        if (Utils.IsSoliniaItem(itemstack) && !itemstack.getType().equals(Material.ENCHANTED_BOOK)) {
            ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) event.getPlayer());
            ISoliniaItem soliniaitem = StateManager.getInstance().getConfigurationManager().getItem(itemstack);
            if (soliniaitem.getAllowedClassNames().size() == 0)
                return;
            if (solplayer.getClassObj() == null) {
                Utils.CancelEvent(event);
                ;
                event.getPlayer().sendMessage(ChatColor.GRAY + "Your class cannot wear this armour");
                return;
            }
            if (!soliniaitem.getAllowedClassNames().contains(solplayer.getClassObj().getName().toUpperCase())) {
                Utils.CancelEvent(event);
                ;
                event.getPlayer().getPlayer().sendMessage(ChatColor.GRAY + "Your class cannot wear this armour");
                return;
            }
            if (soliniaitem.getMinLevel() > solplayer.getLevel()) {
                Utils.CancelEvent(event);
                ;
                event.getPlayer().getPlayer().sendMessage(ChatColor.GRAY + "Your are not sufficient level wear this armour");
                return;
            }
            solplayer.updateMaxHp();
        }
    } catch (CoreStateInitException e) {
    }
}
Also used : ISoliniaItem(com.solinia.solinia.Interfaces.ISoliniaItem) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) ItemStack(org.bukkit.inventory.ItemStack) EventHandler(org.bukkit.event.EventHandler)

Example 49 with CoreStateInitException

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

the class Solinia3CorePlayerListener method onPlayerInteract.

@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    // We need it for spells
    if (event.getAction() != Action.RIGHT_CLICK_AIR) {
        if (event.isCancelled())
            return;
    }
    try {
        Timestamp mezExpiry = StateManager.getInstance().getEntityManager().getMezzed((LivingEntity) event.getPlayer());
        if (mezExpiry != null) {
            event.getPlayer().sendMessage("* You are mezzed!");
            Utils.CancelEvent(event);
            ;
            return;
        }
    } catch (CoreStateInitException e) {
    }
    // Handle changing armour
    if ((event.getHand() == EquipmentSlot.HAND || event.getHand() == EquipmentSlot.OFF_HAND) && (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
        try {
            Utils.checkArmourEquip(SoliniaPlayerAdapter.Adapt(event.getPlayer()), event);
        } catch (CoreStateInitException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    try {
        SoliniaPlayerAdapter.Adapt(event.getPlayer()).interact(plugin, event);
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) Timestamp(java.sql.Timestamp) EventHandler(org.bukkit.event.EventHandler)

Example 50 with CoreStateInitException

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

the class Solinia3CorePlayerListener method onPlayerMove.

@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
    try {
        if (StateManager.getInstance().getEntityManager().getTrance(event.getPlayer().getUniqueId()) == true) {
            StateManager.getInstance().getEntityManager().setTrance(event.getPlayer().getUniqueId(), false);
        }
        Timestamp mezExpiry = StateManager.getInstance().getEntityManager().getMezzed((LivingEntity) event.getPlayer());
        if (mezExpiry != null) {
            event.getPlayer().sendMessage("* You are mezzed!");
            if (event.getTo().getY() < event.getFrom().getY()) {
                event.getTo().setX(event.getFrom().getX());
                event.getTo().setZ(event.getFrom().getZ());
                event.getTo().setYaw(event.getFrom().getYaw());
                event.getTo().setPitch(event.getFrom().getPitch());
            } else {
                event.getTo().setX(event.getFrom().getX());
                event.getTo().setY(event.getFrom().getY());
                event.getTo().setZ(event.getFrom().getZ());
                event.getTo().setYaw(event.getFrom().getYaw());
                event.getTo().setPitch(event.getFrom().getPitch());
            }
            return;
        }
    } catch (CoreStateInitException e) {
    // do nothing
    }
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) Timestamp(java.sql.Timestamp) EventHandler(org.bukkit.event.EventHandler)

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