Quick Help, Easy Fix?

Discussion in 'Plugin Development' started by chennault, Nov 27, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    chennault

    Thanks a lot for looking! I can't seem to figure this out; I'm trying to create a command "/card view <player>" that will display another players player card/profile when used. Problem is, I don't know what I'm doing wrong and can't seem to get it to work.

    I have a method already that will display the information when shift clicking, but I can't figure this one out or how it will look.

    Thanks for all the help!

    The /card view <player>
    Code:
    if(args.length == 2)
                    {
                        if(args[0].equalsIgnoreCase("view"))
                        {
                            p.sendMessage("Stepped into");
                            String otherplayer = args[1];
                            if(getConfig().contains((new StringBuilder("Players.")).append(otherplayer).toString()))
                            {
                                p.sendMessage("Works");
                                //sendCardPlayer This is where the method will go to display info
                            }
                            //p.sendMessage((new StringBuilder(String.valueOf(pl.getDisplayName()))).append(ChatColor.WHITE).append(" has not set their profile up! Tell em' to!").toString());
                           
                        }
                        else{
                        p.sendMessage(getConfig().getString("HelpMessage").replaceAll("&", "\247"));
                        return true;
                        }
                    }
    The shift click method to view profile
    Code:
        public void onPlayerClick(PlayerInteractEntityEvent event)
        {
            Player p = event.getPlayer();
            if(event.getRightClicked() instanceof Player)
            {
                Player pl = (Player)event.getRightClicked();
                if(p.isSneaking())
                {
                    String str = pl.getUniqueId().toString();
                    if(getConfig().contains((new StringBuilder("Players.")).append(str).toString()))
                    {
                        sendCardPlayer(p, pl);
                        return;
                    }
                    p.sendMessage((new StringBuilder(String.valueOf(pl.getDisplayName()))).append(ChatColor.WHITE).append(" has not set their profile up! Tell em' to!").toString());
                } else
                {
                    return;
                }
            } else
            {
                return;
            }
        }
     
  2. Offline

    adam753

    chennault
    So are you saying the first code part doesn't work at all? Do any of the messages get sent ("Stepped into", etc)?
     
  3. Offline

    chennault


    adam753
    The "step into" fires, the second "works" trigger does not however.
     
  4. Offline

    mythbusterma

    chennault

    Are you sure your config actually contains the value players.whatever and doesn't contain any errors?
     
  5. Offline

    adam753

    chennault
    In the working code snippet, you're checking their UUID from the config, but in the non-working one you're checking their username. That can't be right, surely?

    Code:java
    1.  
    2. Player player = null;
    3. for(Player p: Bukkit.getOnlinePlayers()) {
    4. if(p.getName().equalsIgnoreCase(args[1]) {
    5. player = p;
    6. break;
    7. }
    8. }
    9.  
    10. if(player == null) {
    11. //There is no player online with that name
    12. }
    13. else {
    14. String otherPlayer = p.getUniqueId().toString();
    15. //etc
    16. }
    17.  
     
    chennault likes this.
Thread Status:
Not open for further replies.

Share This Page