else {
if (!player.hasPermission("canary.command.give.other")) {
player.notice(Translator.translate("give failed"));
return;
}
Player target = Canary.getServer().matchPlayer(args[2]);
if (target == null) {
player.notice(Translator.translateAndFormat("unknown player", args[2]));
return;
}
Item item = makeItem(args[1], 1);
if (item == null) { // NULL CHECK!
player.notice(Translator.translateAndFormat("give invalid itemtype", args[1]));
return;
}
target.giveItem(item);
target.message(Colors.YELLOW + Translator.translateAndFormat("give received", item.getType().getDisplayName()));
player.notice(Translator.translateAndFormat("give success other", target.getName()));
}
}
// Give to other
else if (args.length == 4) {
if (!player.hasPermission("canary.command.give.other")) {
player.notice(Translator.translate("give failed"));
return;
}
int amount = 1;
if (args[2].matches("\\d+")) {
amount = Integer.parseInt(args[2]);
}
Item item = makeItem(args[1], amount);
if (item == null) {
player.notice(Translator.translateAndFormat("give invalid itemtype", args[1]));
return;
}
Player target = Canary.getServer().matchPlayer(args[3]);
if (target == null) {
player.notice(Translator.translateAndFormat("unknown player", args[3]));
return;
}
target.giveItem(item);
target.message(Colors.YELLOW + Translator.translateAndFormat("give received", item.getType().getDisplayName()));
player.notice(Translator.translateAndFormat("give success other", target.getName()));
}
}