mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-08-05 12:02:53 +00:00
Allow clearing item names + add locale messages for /itemname
This commit is contained in:
parent
155d3ec938
commit
111a18585d
3 changed files with 15 additions and 8 deletions
|
@ -7,6 +7,7 @@ import com.earth2me.essentials.I18n;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import com.earth2me.essentials.utils.FormatUtil;
|
import com.earth2me.essentials.utils.FormatUtil;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.utils.MaterialUtil;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
@ -23,14 +24,17 @@ public class Commanditemname extends EssentialsCommand {
|
||||||
@Override
|
@Override
|
||||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception {
|
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception {
|
||||||
ItemStack item = user.getBase().getItemInHand();
|
ItemStack item = user.getBase().getItemInHand();
|
||||||
if (item.getType() != Material.AIR) {
|
if (item.getType().name().contains("AIR")) {
|
||||||
String name = FormatUtil.formatString(user, "essentials.itemname", getFinalArg(args, 0));
|
user.sendMessage(tl("itemnameInvalidItem", item.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ')));
|
||||||
ItemMeta im = item.getItemMeta();
|
|
||||||
im.setDisplayName(name);
|
|
||||||
item.setItemMeta(im);
|
|
||||||
user.sendMessage(tl("itemnameSuccess", name));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
user.sendMessage(tl("itemnameInvalidItem", item.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ')));
|
|
||||||
|
String name = FormatUtil.formatString(user, "essentials.itemname", getFinalArg(args, 0)).trim();
|
||||||
|
if (name.isEmpty()) name = null;
|
||||||
|
|
||||||
|
ItemMeta im = item.getItemMeta();
|
||||||
|
im.setDisplayName(name);
|
||||||
|
item.setItemMeta(im);
|
||||||
|
user.sendMessage(name == null ? tl("itemnameClear") : tl("itemnameSuccess", name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,6 +211,9 @@ itemCannotBeSold=\u00a74That item cannot be sold to the server.
|
||||||
itemId=\u00a76ID\:\u00a7c {0}
|
itemId=\u00a76ID\:\u00a7c {0}
|
||||||
itemMustBeStacked=\u00a74Item must be traded in stacks. A quantity of 2s would be two stacks, etc.
|
itemMustBeStacked=\u00a74Item must be traded in stacks. A quantity of 2s would be two stacks, etc.
|
||||||
itemNames=\u00a76Item short names\:\u00a7r {0}
|
itemNames=\u00a76Item short names\:\u00a7r {0}
|
||||||
|
itemnameClear=\u00a76You have cleared this item''s name.
|
||||||
|
itemnameInvalidItem=\u00a7cYou need to hold an item to rename it.
|
||||||
|
itemnameSuccess=\u00a76You have renamed your held item to "\u00a7c{0}\u00a76".
|
||||||
itemNotEnough1=\u00a74You do not have enough of that item to sell.
|
itemNotEnough1=\u00a74You do not have enough of that item to sell.
|
||||||
itemNotEnough2=\u00a76If you meant to sell all of your items of that type, use\u00a7c /sell itemname\u00a76.
|
itemNotEnough2=\u00a76If you meant to sell all of your items of that type, use\u00a7c /sell itemname\u00a76.
|
||||||
itemNotEnough3=\u00a7c/sell itemname -1\u00a76 will sell all but one item, etc.
|
itemNotEnough3=\u00a7c/sell itemname -1\u00a76 will sell all but one item, etc.
|
||||||
|
|
|
@ -210,7 +210,7 @@ commands:
|
||||||
aliases: [dura,edura,durability,edurability,eitemdb,itemno,eitemno]
|
aliases: [dura,edura,durability,edurability,eitemdb,itemno,eitemno]
|
||||||
itemname:
|
itemname:
|
||||||
description: Names an item.
|
description: Names an item.
|
||||||
usage: /<command> <name>
|
usage: /<command> [name]
|
||||||
aliases: [iname, einame, eitemname, itemrename, irename, eitemrename, eirename]
|
aliases: [iname, einame, eitemname, itemrename, irename, eitemrename, eirename]
|
||||||
jails:
|
jails:
|
||||||
description: List all jails.
|
description: List all jails.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue