Solved Show Inventory

Discussion in 'Spigot Plugin Development' started by MadMaxCookie, May 12, 2016.

  1. Hello so I have the command /rs inv or inventory <player> to show the target's inventory to the player sender

    Code (Java):
                    if(args[0].equalsIgnoreCase("inventory") || (args[0].equalsIgnoreCase("inv"))) {
                        if(!p.hasPermission("relationship.*") || (!p.hasPermission("relationship.inventory"))) {
                            return true;
                        Player target = (Player) Bukkit.getServer().getPlayer(args[0]);
                        // check if the player is offline
                        if(target == null) {
                            sender.sendMessage(colorize("&8[&6RelationShip&8] &eError >> &8: &4Player is not online"));
                            return true;
                        // check if the player has no partner
                        if(getConfig().getString(target.getName() + ".Married.who") == null) {
                            p.sendMessage(colorize("&8[&6RelationShip&8] &eError >> &8: &4That player has no partner"));
                            return true;
                        // check if the target is player's partner
                        if(getConfig().getString(target.getName() + ".Married.who") != p.getName()) {
                            p.sendMessage(colorize("&8[&6RelationShip&8] &eError >> &8: &4That player is either married with someone or no partner"));
                            return true;
                        // check if share boolean is true
                        if(!getConfig().getBoolean(target.getName() + ".Married.share")) {
                            p.sendMessage(colorize("&8[&6RelationShip&8] &eError >> &8: &4That player isn't sharing his / her inventory"));
                            return true;
                        // open the inventory
                        p.playSound(p.getLocation(), Sound.ENTITY_CHICKEN_EGG, 10, 10);
    but even the target is not equals to null its still sending me the That player is not online message
  2. It seems like you want args[1] instead of args[0] in the line Player target =(Player) Bukkit.getServer().getPlayer(args[0]);

    args[0] is equal to "inventory" or "inv"
    • Agree Agree x 2
  3. deym :D I'm really confused sorry about that lemme try again