1 package org.bukkit.command.defaults;
5 import org.apache.commons.lang.Validate;
6 import org.bukkit.Bukkit;
7 import org.bukkit.ChatColor;
8 import org.bukkit.command.Command;
9 import org.bukkit.command.CommandSender;
10 import org.bukkit.entity.Player;
12 import com.google.common.collect.ImmutableList;
17 this.
description =
"Gives the specified player a certain amount of experience. Specify <amount>L to give levels instead, with a negative amount resulting in taking levels.";
18 this.
usageMessage =
"/xp <amount> [player] OR /xp <amount>L [player]";
26 if (args.length > 0) {
27 String inputAmount = args[0];
30 boolean isLevel = inputAmount.endsWith(
"l") || inputAmount.endsWith(
"L");
31 if (isLevel && inputAmount.length() > 1) {
32 inputAmount = inputAmount.substring(0, inputAmount.length() - 1);
35 int amount =
getInteger(sender, inputAmount, Integer.MIN_VALUE, Integer.MAX_VALUE);
36 boolean isTaking = amount < 0;
42 if (args.length > 1) {
44 }
else if (sender instanceof
Player) {
45 player = (Player) sender;
59 sender.
sendMessage(
ChatColor.
RED +
"Taking experience can only be done by levels, cannot give players negative experience points");
80 Validate.notNull(sender,
"Sender cannot be null");
81 Validate.notNull(args,
"Arguments cannot be null");
82 Validate.notNull(alias,
"Alias cannot be null");
84 if (args.length == 2) {
85 return super.tabComplete(sender, alias, args);
87 return ImmutableList.of();