Bukkit Command Support

Status
This thread has been locked.

HuskyGG

Banned
Feedback score
3
Posts
79
Reactions
16
Resources
0
Hey, i was wondering if anyone could help me with a problem im having with a plugin that im working on. Its just a basic party chat plugin, so when a player types pinvite name. It invites the player(s) specified and they can talk. But im having a problem with getting the players names when /pinvite NAME is typed. This is my current code:
HTML:
    //Commands
    public String help = "party";
    public String invite = "pinvite";

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {

        if (sender instanceof Player) {
        if (cmd.getName().equalsIgnoreCase(help)) {
            sender.sendMessage(ChatColor.YELLOW + "Type '/party invite' to create a party chat!");
          }
        }

        if (cmd.getName().equalsIgnoreCase(invite)) {
            Player invited = Bukkit.getPlayer(args[0]);
            if (invited != null) {
                invited.sendMessage("You have been invited to a party by" + sender.getName());
                sender.sendMessage("You have invited " + invited.getName() + "to a party!");
            }
            else if (invited != invited) {
                sender.sendMessage(invited.getName() + "is not online right now!");
            }

        }

        return false;
    }
}

But
Code:
Player invited = Bukkit.getPlayer(args[0]);
as it says that Bukkit.getPlayer is deprecated.
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

Fluddershy

Feedback score
2
Posts
277
Reactions
133
Resources
0
I recommend Bukkit#getPlayerExact, or you're going to get for instance, if I type /party Flu and there is Fluddershy and Fludderbye on, it might select the wrong person.

Unless you're using those strings at the top, might as well get rid of them or make them private, it's good practice.

When you're making checks, I almost always like to check if they aren't so I can give them a bit of info on what they're doing wrong. I.E - sender is console, too many or too little args, sender is him/her self etc...
 
Last edited:
Status
This thread has been locked.
Top