mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-22 17:18:37 +01:00
Create /itemname command that names held items.
This contains changes from #672 minus messages, squashed into one commit. Closes #672.
This commit is contained in:
parent
0e3f48ee54
commit
8bafacbd51
@ -0,0 +1,36 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.I18n;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class Commanditemname extends EssentialsCommand {
|
||||
|
||||
public Commanditemname() {
|
||||
super("itemname");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception {
|
||||
ItemStack item = user.getBase().getItemInHand();
|
||||
if (item.getType() != Material.AIR) {
|
||||
String name = FormatUtil.formatString(user, "essentials.itemname", getFinalArg(args, 0));
|
||||
ItemMeta im = item.getItemMeta();
|
||||
im.setDisplayName(name);
|
||||
item.setItemMeta(im);
|
||||
user.sendMessage(tl("itemnameSuccess", name));
|
||||
return;
|
||||
}
|
||||
user.sendMessage(tl("itemnameInvalidItem", item.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ')));
|
||||
}
|
||||
}
|
@ -208,6 +208,10 @@ commands:
|
||||
description: Searches for an item.
|
||||
usage: /<command> <item>
|
||||
aliases: [dura,edura,durability,edurability,eitemdb,itemno,eitemno]
|
||||
itemname:
|
||||
description: Names an item.
|
||||
usage: /<command> <name...>
|
||||
aliases: [iname, einame, eitemname]
|
||||
jails:
|
||||
description: List all jails.
|
||||
usage: /<command>
|
||||
|
Loading…
Reference in New Issue
Block a user