46 lines
1.3 KiB
Java
46 lines
1.3 KiB
Java
package cn.citycraft.SimpleEssential.command;
|
|
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandException;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
import cn.citycraft.PluginHelper.commands.BaseCommand;
|
|
import cn.citycraft.SimpleEssential.SimpleEssential;
|
|
import cn.citycraft.SimpleEssential.config.I18n;
|
|
|
|
/**
|
|
* @Author 代小呆 created in 2015年8月16日下午1:44:22
|
|
*/
|
|
|
|
public class CommandHat extends BaseCommand {
|
|
|
|
@SuppressWarnings("unused")
|
|
private final SimpleEssential plugin;
|
|
|
|
public CommandHat(final SimpleEssential main) {
|
|
super("hat", "sehat");
|
|
this.plugin = main;
|
|
setDescription("把手上的方块带在手上");
|
|
}
|
|
|
|
@Override
|
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
|
final Player p = (Player) sender;
|
|
if (p.getItemInHand() == null) {
|
|
sender.sendMessage(I18n.p("Hat.empty"));
|
|
return;
|
|
}
|
|
final ItemStack hand = p.getItemInHand();
|
|
p.setItemInHand(null);
|
|
final ItemStack helmet = p.getInventory().getHelmet();
|
|
if (!(helmet == null)) {
|
|
p.getInventory().addItem(helmet);
|
|
}
|
|
p.getInventory().setHelmet(hand);
|
|
sender.sendMessage(I18n.p("Hat.enjoy"));
|
|
|
|
}
|
|
}
|