Search in sources :

Example 41 with ISoliniaItem

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

the class Utils method checkArmourEquip.

public static void checkArmourEquip(ISoliniaPlayer solplayer, PlayerInteractEvent event) {
    ItemStack itemstack = event.getItem();
    if (itemstack == null)
        return;
    if (!(CraftItemStack.asNMSCopy(itemstack).getItem() instanceof net.minecraft.server.v1_12_R1.ItemArmor)) {
        return;
    }
    if (Utils.IsSoliniaItem(itemstack) && !itemstack.getType().equals(Material.ENCHANTED_BOOK)) {
        try {
            ISoliniaItem soliniaitem = StateManager.getInstance().getConfigurationManager().getItem(itemstack);
            if (soliniaitem.getAllowedClassNames().size() == 0)
                return;
            if (solplayer.getClassObj() == null) {
                Utils.CancelEvent(event);
                ;
                event.getPlayer().updateInventory();
                event.getPlayer().sendMessage(ChatColor.GRAY + "Your class cannot wear this armour");
                return;
            }
            if (!soliniaitem.getAllowedClassNames().contains(solplayer.getClassObj().getName())) {
                Utils.CancelEvent(event);
                ;
                event.getPlayer().updateInventory();
                event.getPlayer().sendMessage(ChatColor.GRAY + "Your class cannot wear this armour");
                return;
            }
            if (soliniaitem.getMinLevel() > solplayer.getLevel()) {
                Utils.CancelEvent(event);
                ;
                event.getPlayer().updateInventory();
                event.getPlayer().sendMessage(ChatColor.GRAY + "Your class cannot wear this armour");
                return;
            }
        } catch (CoreStateInitException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
Also used : ISoliniaItem(com.solinia.solinia.Interfaces.ISoliniaItem) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack)

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