mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 11:45: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.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
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 {
|
class ChargeCommand extends SubCommand {
|
||||||
|
|
||||||
ChargeCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
|
ChargeCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
|
||||||
super(plugin, cmd, "charge", false);
|
super(plugin, cmd, "charge", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected String getDescription() {
|
protected String getDescription() {
|
||||||
return "commands.charge.description";
|
return "commands.charge.description";
|
||||||
}
|
}
|
||||||
@ -23,13 +31,15 @@ class ChargeCommand extends SubCommand {
|
|||||||
public void onExecute(CommandSender sender, String[] args) {
|
public void onExecute(CommandSender sender, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
if (sender.hasPermission("slimefun.charge.command")) {
|
if (sender.hasPermission("slimefun.charge.command")) {
|
||||||
Player p = ((Player) sender).getPlayer();
|
Player p = (Player) sender;
|
||||||
final ItemStack item = p.getInventory().getItemInMainHand();
|
ItemStack item = p.getInventory().getItemInMainHand();
|
||||||
final SlimefunItem slimefunItem = SlimefunItem.getByItem(item);
|
SlimefunItem slimefunItem = SlimefunItem.getByItem(item);
|
||||||
if (slimefunItem instanceof Rechargeable) {
|
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);
|
SlimefunPlugin.getLocalization().sendMessage(sender, "commands.charge.charge-success", true);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
SlimefunPlugin.getLocalization().sendMessage(sender, "commands.charge.not-rechargeable", true);
|
SlimefunPlugin.getLocalization().sendMessage(sender, "commands.charge.not-rechargeable", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user