Search in sources :

Example 31 with ISoliniaPlayer

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

the class CommandEffects method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (sender instanceof Player) {
        Player player = (Player) sender;
        try {
            SoliniaEntitySpells spells = StateManager.getInstance().getEntityManager().getActiveEntitySpells(player);
            if (spells == null)
                return true;
            if (args.length == 0) {
                player.sendMessage(ChatColor.GOLD + "Active Spell Effects on you:" + ChatColor.WHITE);
                ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(player);
                if (solplayer.getExperienceBonusExpires() != null) {
                    System.out.println("Experience Bonus was not null: " + solplayer.getExperienceBonusExpires().toString());
                    LocalDateTime datetime = LocalDateTime.now();
                    Timestamp nowtimestamp = Timestamp.valueOf(datetime);
                    Timestamp expiretimestamp = solplayer.getExperienceBonusExpires();
                    if (expiretimestamp != null) {
                        System.out.println("Experience Bonus expire timestamp " + solplayer.getExperienceBonusExpires() + " vs Now: " + nowtimestamp.toString());
                        if (!nowtimestamp.after(expiretimestamp)) {
                            System.out.println("Experience bonus was after, displaying in effects");
                            int secondsleft = (int) Math.floor(Utils.compareTwoTimeStamps(expiretimestamp, nowtimestamp));
                            TextComponent tc = new TextComponent();
                            tc.setText("- " + ChatColor.GREEN + "100% Experience Potion" + ChatColor.RESET + " " + secondsleft + " seconds");
                            sender.spigot().sendMessage(tc);
                        }
                    }
                } else {
                    System.out.println("Experience Bonus was null");
                }
                for (SoliniaActiveSpell activeSpell : spells.getActiveSpells()) {
                    ISoliniaSpell spell = StateManager.getInstance().getConfigurationManager().getSpell(activeSpell.getSpellId());
                    String removetext = "";
                    ChatColor spellcolor = ChatColor.GREEN;
                    if (spell.isBeneficial()) {
                        removetext = "/effects remove " + spell.getId();
                    } else {
                        removetext = "Unremovable spell";
                        spellcolor = ChatColor.RED;
                    }
                    TextComponent tc = new TextComponent();
                    tc.setText("- " + spellcolor + spell.getName() + ChatColor.RESET + " " + activeSpell.getTicksLeft() + " ticks left - ");
                    TextComponent tc2 = new TextComponent();
                    tc2.setText(removetext);
                    if (spell.isBeneficial()) {
                        tc2.setText(ChatColor.GRAY + "Click here to remove" + ChatColor.RESET);
                        tc2.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, removetext));
                    }
                    tc.addExtra(tc2);
                    sender.spigot().sendMessage(tc);
                }
            } else {
                if (args.length < 2)
                    return true;
                int spellid = Integer.parseInt(args[1]);
                ISoliniaSpell spell = StateManager.getInstance().getConfigurationManager().getSpell(spellid);
                if (spell == null) {
                    player.sendMessage("That spell does not exist");
                    return true;
                }
                StateManager.getInstance().getEntityManager().removeSpellEffectsOfSpellId(plugin, player.getUniqueId(), spell.getId());
                if (!spell.isBeneficial()) {
                    player.sendMessage("Can only remove beneficial spells");
                    return true;
                }
                player.sendMessage("Spell Effect removed");
            }
        } catch (CoreStateInitException e) {
            player.sendMessage(e.getMessage());
        }
    }
    return true;
}
Also used : LocalDateTime(java.time.LocalDateTime) TextComponent(net.md_5.bungee.api.chat.TextComponent) Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) ISoliniaSpell(com.solinia.solinia.Interfaces.ISoliniaSpell) ClickEvent(net.md_5.bungee.api.chat.ClickEvent) SoliniaEntitySpells(com.solinia.solinia.Models.SoliniaEntitySpells) Timestamp(java.sql.Timestamp) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) ChatColor(net.md_5.bungee.api.ChatColor) SoliniaActiveSpell(com.solinia.solinia.Models.SoliniaActiveSpell)

Example 32 with ISoliniaPlayer

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

the class CommandEmote method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (sender instanceof Player) {
        Player player = (Player) sender;
        if (args.length < 1) {
            player.sendMessage("Insufficient arguments (<emote>)");
            return false;
        }
        try {
            ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(player);
            if (solplayer == null) {
                player.sendMessage("Failed to emote, player does not exist");
                return false;
            }
            StringBuilder builder = new StringBuilder();
            for (String value : args) {
                builder.append(value + " ");
            }
            String message = builder.toString();
            message = message.substring(0, message.length());
            if (message.equals("")) {
                return false;
            }
            message = message.replaceAll("(?i)fuck", "shelderhoof");
            message = message.replaceAll("(?i)shit", "qaraf");
            solplayer.emote(ChatColor.AQUA + "* " + solplayer.getFullName() + " " + message);
        } catch (CoreStateInitException e) {
            player.sendMessage(e.getMessage());
        }
    }
    return true;
}
Also used : ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) Player(org.bukkit.entity.Player) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 33 with ISoliniaPlayer

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

the class CommandIgnore method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (sender instanceof Player) {
        if (args.length < 1)
            return false;
        Player targetPlayer = Bukkit.getPlayer(args[0]);
        if (targetPlayer == null) {
            sender.sendMessage("Player is not online to ignore");
            return true;
        }
        if (targetPlayer.getUniqueId().equals(((Player) sender).getUniqueId())) {
            sender.sendMessage("Cannot ignore self");
            return true;
        }
        try {
            ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt((Player) sender);
            solPlayer.ignorePlayer(targetPlayer);
            sender.sendMessage("Done");
        } catch (CoreStateInitException e) {
            return false;
        }
        return true;
    }
    return false;
}
Also used : ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) Player(org.bukkit.entity.Player) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 34 with ISoliniaPlayer

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

the class CommandInspiration method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    try {
        if (args.length == 0) {
            sender.sendMessage(ChatColor.LIGHT_PURPLE + "Inspiration Shop");
            sender.sendMessage("-----------------");
            sender.sendMessage(ChatColor.LIGHT_PURPLE + "Buy 1 AA Point " + ChatColor.RESET + " - Cost: 5 inspiration : /inspiration buy aa");
            sender.sendMessage(ChatColor.LIGHT_PURPLE + "Buy Mana Regen Aug (Head) " + ChatColor.RESET + " - Cost: 2 inspiration : /inspiration buy manahead");
            sender.sendMessage(ChatColor.LIGHT_PURPLE + "Buy Mana Regen Aug (Chest) " + ChatColor.RESET + " - Cost: 2 inspiration : /inspiration buy manachest");
            sender.sendMessage(ChatColor.LIGHT_PURPLE + "Buy Mana Regen Aug (Legs) " + ChatColor.RESET + " - Cost: 2 inspiration : /inspiration buy manalegs");
            sender.sendMessage(ChatColor.LIGHT_PURPLE + "Buy Mana Regen Aug (Feet) " + ChatColor.RESET + " - Cost: 2 inspiration : /inspiration buy manafeet");
            sender.sendMessage(ChatColor.LIGHT_PURPLE + "Buy 1x 100% Experience Potion " + ChatColor.RESET + " - Cost: 2 inspiration : /inspiration buy xpbottle");
            sender.sendMessage(ChatColor.LIGHT_PURPLE + "Buy 1x next tier gear set" + ChatColor.RESET + " - Cost: 35 inspiration : /inspiration buy gear");
            sender.sendMessage("-----------------");
            sender.sendMessage("Sub Commands: " + ChatColor.LIGHT_PURPLE + "sites, buy, send");
            if (sender instanceof Player) {
                ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt((Player) sender);
                sender.sendMessage("Points Available: " + ChatColor.LIGHT_PURPLE + solPlayer.getInspiration());
            }
            return true;
        }
        switch(args[0].toLowerCase()) {
            case "buy":
                if (args.length > 1) {
                    int cost = 0;
                    switch(args[1].toLowerCase()) {
                        case "gear":
                            if (sender instanceof Player) {
                                ISoliniaPlayer player = SoliniaPlayerAdapter.Adapt((Player) sender);
                                cost = 35;
                                if (player.getInspiration() >= cost) {
                                    String suffix = "of Inspiration";
                                    int playertier = 1;
                                    if (player.getLevel() >= 1 && player.getLevel() < 11)
                                        playertier = 1;
                                    if (player.getLevel() >= 11 && player.getLevel() < 21)
                                        playertier = 2;
                                    if (player.getLevel() >= 21 && player.getLevel() < 31)
                                        playertier = 3;
                                    if (player.getLevel() >= 31 && player.getLevel() < 41)
                                        playertier = 4;
                                    if (player.getLevel() >= 41 && player.getLevel() < 51)
                                        playertier = 5;
                                    if (player.getLevel() >= 51 && player.getLevel() < 61)
                                        playertier = 6;
                                    try {
                                        // always give the next tier up
                                        // this ability is for special seasonal rewards only
                                        playertier += 1;
                                        List<Integer> items = SoliniaItemFactory.CreateClassItemSet(player.getClassObj(), playertier, suffix, false, true);
                                        for (int itemid : items) {
                                            ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(itemid);
                                            final String playerName = player.getBukkitPlayer().getName();
                                            final int minLevel = player.getLevel();
                                            final int finalitemid = itemid;
                                            if (item != null) {
                                                Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("Solinia3Core"), new Runnable() {

                                                    public void run() {
                                                        try {
                                                            ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(finalitemid);
                                                            item.setMinLevel(minLevel);
                                                            SoliniaAccountClaim claim = new SoliniaAccountClaim();
                                                            claim.setId(StateManager.getInstance().getConfigurationManager().getNextAccountClaimId());
                                                            claim.setMcname(playerName);
                                                            claim.setItemid(finalitemid);
                                                            claim.setClaimed(false);
                                                            Player claimPlayer = Bukkit.getPlayer(playerName);
                                                            if (claimPlayer != null) {
                                                                claimPlayer.sendMessage(ChatColor.GOLD + "You have been awarded with a claim item! See /claim");
                                                            }
                                                            StateManager.getInstance().getConfigurationManager().addAccountClaim(claim);
                                                            System.out.println("Awarded Claim: " + item.getDisplayname() + " to " + playerName);
                                                        } catch (CoreStateInitException e) {
                                                        // skip
                                                        }
                                                    }
                                                });
                                            }
                                        }
                                        player.setInspiration(player.getInspiration() - cost);
                                        sender.sendMessage("You have purchased a full set of gear!");
                                    } catch (CoreStateInitException e) {
                                        sender.sendMessage("There was a problem generating your gear (Core), please report this to a developer");
                                    } catch (SoliniaItemException e) {
                                        sender.sendMessage("There was a problem generating your gear (Item), please report this to a developer");
                                    }
                                    return true;
                                } else {
                                    sender.sendMessage("You require more inspiration points to purchase this");
                                    return true;
                                }
                            } else {
                                sender.sendMessage("This is a player only subcommand");
                            }
                        case "aa":
                            if (sender instanceof Player) {
                                ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt((Player) sender);
                                if (solPlayer.getLevel() < 20) {
                                    sender.sendMessage("Only players level 20 and above can have AA points any lower and it would be useless");
                                    return true;
                                } else {
                                    cost = 5;
                                    if (solPlayer.getInspiration() >= cost) {
                                        solPlayer.setInspiration(solPlayer.getInspiration() - cost);
                                        solPlayer.setAAPoints(solPlayer.getAAPoints() + 1);
                                        sender.sendMessage("You have purchased an AA point!");
                                        return true;
                                    } else {
                                        sender.sendMessage("You require more inspiration points to purchase this");
                                        return true;
                                    }
                                }
                            } else {
                                sender.sendMessage("This is a player only subcommand");
                            }
                        case "manahead":
                            if (sender instanceof Player) {
                                ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt((Player) sender);
                                cost = 2;
                                if (solPlayer.getInspiration() >= cost) {
                                    solPlayer.setInspiration(solPlayer.getInspiration() - cost);
                                    ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(18019);
                                    ((Player) sender).getLocation().getWorld().dropItemNaturally(((Player) sender).getLocation(), item.asItemStack());
                                    sender.sendMessage("You have purchased an item!");
                                    return true;
                                } else {
                                    sender.sendMessage("You require more inspiration points to purchase this");
                                    return true;
                                }
                            } else {
                                sender.sendMessage("This is a player only subcommand");
                            }
                        case "manachest":
                            if (sender instanceof Player) {
                                ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt((Player) sender);
                                cost = 2;
                                if (solPlayer.getInspiration() >= cost) {
                                    solPlayer.setInspiration(solPlayer.getInspiration() - cost);
                                    ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(18020);
                                    ((Player) sender).getLocation().getWorld().dropItemNaturally(((Player) sender).getLocation(), item.asItemStack());
                                    sender.sendMessage("You have purchased an item!");
                                    return true;
                                } else {
                                    sender.sendMessage("You require more inspiration points to purchase this");
                                    return true;
                                }
                            } else {
                                sender.sendMessage("This is a player only subcommand");
                            }
                        case "manalegs":
                            if (sender instanceof Player) {
                                ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt((Player) sender);
                                cost = 2;
                                if (solPlayer.getInspiration() >= cost) {
                                    solPlayer.setInspiration(solPlayer.getInspiration() - cost);
                                    ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(18021);
                                    ((Player) sender).getLocation().getWorld().dropItemNaturally(((Player) sender).getLocation(), item.asItemStack());
                                    sender.sendMessage("You have purchased an item!");
                                    return true;
                                } else {
                                    sender.sendMessage("You require more inspiration points to purchase this");
                                    return true;
                                }
                            } else {
                                sender.sendMessage("This is a player only subcommand");
                            }
                        case "manafeet":
                            if (sender instanceof Player) {
                                ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt((Player) sender);
                                cost = 2;
                                if (solPlayer.getInspiration() >= cost) {
                                    solPlayer.setInspiration(solPlayer.getInspiration() - cost);
                                    ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(18022);
                                    ((Player) sender).getLocation().getWorld().dropItemNaturally(((Player) sender).getLocation(), item.asItemStack());
                                    sender.sendMessage("You have purchased an item!");
                                    return true;
                                } else {
                                    sender.sendMessage("You require more inspiration points to purchase this");
                                    return true;
                                }
                            } else {
                                sender.sendMessage("This is a player only subcommand");
                            }
                        case "xpbottle":
                            if (sender instanceof Player) {
                                ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt((Player) sender);
                                cost = 2;
                                if (solPlayer.getInspiration() >= cost) {
                                    solPlayer.setInspiration(solPlayer.getInspiration() - cost);
                                    ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(18024);
                                    ((Player) sender).getLocation().getWorld().dropItemNaturally(((Player) sender).getLocation(), item.asItemStack());
                                    sender.sendMessage("You have purchased an item!");
                                    return true;
                                } else {
                                    sender.sendMessage("You require more inspiration points to purchase this");
                                    return true;
                                }
                            } else {
                                sender.sendMessage("This is a player only subcommand");
                            }
                        default:
                            sender.sendMessage("This is not a known shop item to buy. See /inspiration for valid commands");
                            return true;
                    }
                } else {
                    sender.sendMessage("You must specify the shop item you want to buy. Ie: /inspiration buy aa");
                    return true;
                }
            case "sites":
                sender.sendMessage(ChatColor.YELLOW + "Sites you can vote on:");
                sender.sendMessage("https://www.planetminecraft.com/server/fall-of-an-empire-heavyrp/vote/");
                sender.sendMessage("http://www.minecraftforum.net/servers/6305-fall-of-an-empire-heavy-rp/vote:");
                sender.sendMessage("https://minecraftlist.org/vote/5962");
                sender.sendMessage("https://minecraft-server.net/vote/fallofanempire");
                sender.sendMessage("http://minecraft-server-list.com/server/345651/vote/");
                sender.sendMessage(ChatColor.YELLOW + "You will earn 1 inspiration point for each vote");
                break;
            case "send":
                if (args.length > 2) {
                    if (sender instanceof Player) {
                        ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt((Player) sender);
                        String mcAccount = args[1];
                        int amount = Integer.parseInt(args[2]);
                        Player player = Bukkit.getPlayer(mcAccount);
                        if (player == null) {
                            sender.sendMessage("Cannot find that player to forward to. It must be their minecraft account name and they must be online (ie /inspiration send mixxit 1)");
                            return true;
                        }
                        if (solPlayer.getInspiration() >= amount) {
                            ISoliniaPlayer targetPlayer = SoliniaPlayerAdapter.Adapt(player);
                            solPlayer.setInspiration(solPlayer.getInspiration() - amount);
                            targetPlayer.setInspiration(targetPlayer.getInspiration() + amount);
                            sender.sendMessage("You have sent " + amount + " inspiration to " + player.getName());
                            player.sendMessage("You have received " + amount + " inspiration from " + sender.getName());
                            return true;
                        } else {
                            sender.sendMessage("You do not have that amount of inspiration to send");
                            return true;
                        }
                    } else {
                        sender.sendMessage("This is a player only subcommand");
                    }
                } else {
                    sender.sendMessage("You must specify how many you wish to transfer and the mc account name of the person you want to send it to (ie /inspiration send mixxit 1)");
                    return true;
                }
            case "grant":
                if (args.length > 2) {
                    String mcAccount = args[1];
                    int amount = Integer.parseInt(args[2]);
                    Player player = Bukkit.getPlayer(mcAccount);
                    if (player == null) {
                        sender.sendMessage("Cannot find that player to grant to. It must be their minecraft account name and they must be online (ie /inspiration grant mixxit 1)");
                        return true;
                    }
                    if (sender.isOp()) {
                        ISoliniaPlayer targetPlayer = SoliniaPlayerAdapter.Adapt(player);
                        targetPlayer.setInspiration(targetPlayer.getInspiration() + amount);
                        sender.sendMessage("You have granted " + amount + " inspiration to " + player.getName());
                        player.sendMessage("You have received " + amount + " inspiration from " + sender.getName());
                        return true;
                    } else {
                        sender.sendMessage("This is an operator only command");
                    }
                } else {
                    sender.sendMessage("You must specify how many you wish to grant and the mc account name of the person you want to send it to (ie /inspiration grant mixxit 1)");
                    return true;
                }
            default:
                sender.sendMessage("Unknown subcommand - Valid are: sites, buy, send");
                break;
        }
        return true;
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        sender.sendMessage(e.getMessage());
        return true;
    }
}
Also used : SoliniaAccountClaim(com.solinia.solinia.Models.SoliniaAccountClaim) Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) ISoliniaItem(com.solinia.solinia.Interfaces.ISoliniaItem) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) SoliniaItemException(com.solinia.solinia.Exceptions.SoliniaItemException)

Example 35 with ISoliniaPlayer

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

the class CommandEquip method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player) && !(sender instanceof CommandSender))
        return false;
    Player player = (Player) sender;
    try {
        ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt(player);
        showCurrentEquippedItems(solPlayer);
        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 equip in your main hand");
            return false;
        }
        if (!Utils.IsSoliniaItem(primaryItem)) {
            player.sendMessage("You can only equip solinia items this way");
            return true;
        }
        ISoliniaItem item = SoliniaItemAdapter.Adapt(primaryItem);
        if (item == null) {
            player.sendMessage("You cannot equip this item this way");
            return true;
        }
        if (item.getMinLevel() > solPlayer.getLevel()) {
            player.sendMessage("You cannot equip this item (minlevel: " + item.getMinLevel() + ")");
            return true;
        }
        if (solPlayer.getClassObj() == null) {
            player.sendMessage(ChatColor.GRAY + "Your class cannot wear this equipment");
            return true;
        }
        if (item.isSpellscroll()) {
            player.sendMessage("You cannot equip this item");
            return true;
        }
        if (!item.getAllowedClassNames().contains(solPlayer.getClassObj().getName().toUpperCase())) {
            player.sendMessage(ChatColor.GRAY + "Your class cannot wear this equipment");
            return true;
        }
        if (item.getMinLevel() > solPlayer.getLevel()) {
            player.sendMessage(ChatColor.GRAY + "Your are not sufficient level to wear this equipment");
            return true;
        }
        if (item.isFingersItem())
            if (solPlayer.getFingersItem() > 0) {
                player.sendMessage("You have already equipped an item in that slot");
                return true;
            } else {
                solPlayer.setFingersItem(item.getId());
                player.getInventory().setItemInMainHand(null);
                player.updateInventory();
                player.sendMessage("You have equipped this item");
                return true;
            }
        if (item.isShouldersItem())
            if (solPlayer.getShouldersItem() > 0) {
                player.sendMessage("You have already equipped an item in that slot");
                return true;
            } else {
                solPlayer.setShouldersItem(item.getId());
                player.getInventory().setItemInMainHand(null);
                player.updateInventory();
                player.sendMessage("You have equipped this item");
                return true;
            }
        if (item.isNeckItem())
            if (solPlayer.getNeckItem() > 0) {
                player.sendMessage("You have already equipped an item in that slot");
                return true;
            } else {
                solPlayer.setNeckItem(item.getId());
                player.getInventory().setItemInMainHand(null);
                player.updateInventory();
                player.sendMessage("You have equipped this item");
                return true;
            }
        return false;
    } catch (CoreStateInitException e) {
        return false;
    } catch (SoliniaItemException e) {
        player.sendMessage("You cannot equip this item");
        return true;
    }
}
Also used : Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) ISoliniaItem(com.solinia.solinia.Interfaces.ISoliniaItem) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) CommandSender(org.bukkit.command.CommandSender) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) ItemStack(org.bukkit.inventory.ItemStack) SoliniaItemException(com.solinia.solinia.Exceptions.SoliniaItemException)

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