mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Removed redundancies, added javadocs, fixed formatting
This commit is contained in:
parent
125c3fe60d
commit
c091c7992f
@ -9,12 +9,20 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* {@link ChargeCommand} adds an in game command which charges any {@link Rechargeable}
|
||||
* item to max.
|
||||
*
|
||||
* @author FluffyBear
|
||||
*
|
||||
*/
|
||||
class ChargeCommand extends SubCommand {
|
||||
|
||||
ChargeCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
|
||||
super(plugin, cmd, "charge", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDescription() {
|
||||
return "commands.charge.description";
|
||||
}
|
||||
@ -23,13 +31,15 @@ class ChargeCommand extends SubCommand {
|
||||
public void onExecute(CommandSender sender, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
if (sender.hasPermission("slimefun.charge.command")) {
|
||||
Player p = ((Player) sender).getPlayer();
|
||||
final ItemStack item = p.getInventory().getItemInMainHand();
|
||||
final SlimefunItem slimefunItem = SlimefunItem.getByItem(item);
|
||||
Player p = (Player) sender;
|
||||
ItemStack item = p.getInventory().getItemInMainHand();
|
||||
SlimefunItem slimefunItem = SlimefunItem.getByItem(item);
|
||||
if (slimefunItem instanceof Rechargeable) {
|
||||
((Rechargeable) slimefunItem).addItemCharge(item, ((Rechargeable) slimefunItem).getMaxItemCharge(item));
|
||||
Rechargeable rechargeableItem = (Rechargeable) slimefunItem;
|
||||
rechargeableItem.setItemCharge(item, rechargeableItem.getMaxItemCharge(item));
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "commands.charge.charge-success", true);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "commands.charge.not-rechargeable", true);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user