use of xyz.derkades.ublisk.iconmenus.FriendsMenu in project Ublisk by Derkades.
the class FriendsCommand method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
UPlayer player = new UPlayer(sender);
if (args.length == 0) {
new FriendsMenu(player).open();
} else if (args.length == 2) {
if (args[0].equals("add")) {
OfflinePlayer target = Ublisk.getOfflinePlayer(args[1]);
if (target == null) {
player.sendMessage(Message.PLAYER_NOT_FOUND);
return true;
}
if (player.isFriend(target)) {
player.sendPrefixedMessage("Friends", ChatColor.RED + target.getName() + " is already in your friends list.");
return true;
}
player.addFriend(target);
player.sendPrefixedMessage("Friends", target.getName() + " has been added to your friends list");
} else if (args[0].equals("remove") || args[0].equals("delete")) {
OfflinePlayer target = Ublisk.getOfflinePlayer(args[1]);
if (target == null) {
player.sendMessage(Message.PLAYER_NOT_FOUND);
return true;
}
if (!player.isFriend(target)) {
player.sendMessage(Message.FRIEND_NOT_EXIST);
return true;
}
player.removeFriend(target);
player.sendPrefixedMessage("Friends", target.getName() + " has been removed from your friends list");
} else {
player.sendMessage(Message.WRONG_USAGE);
}
} else {
player.sendMessage(Message.WRONG_USAGE);
}
} else {
sender.sendMessage(Message.NOT_A_PLAYER.toString());
}
return true;
}
Aggregations