Add ability to get recipe of item in hand (#5346)

Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
Co-authored-by: pop4959 <pop4959@gmail.com>
This commit is contained in:
Charles DeLancey 2023-05-28 14:27:18 -04:00 committed by GitHub
parent 357cd6b246
commit 646b60a90b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User;
import com.earth2me.essentials.craftbukkit.Inventories;
import com.earth2me.essentials.utils.EnumUtil;
import com.earth2me.essentials.utils.NumberUtil;
import com.earth2me.essentials.utils.VersionUtil;
@ -53,7 +54,18 @@ public class Commandrecipe extends EssentialsCommand {
throw new NotEnoughArgumentsException();
}
final ItemStack itemType = ess.getItemDb().get(args[0]);
final ItemStack itemType;
if (args[0].equalsIgnoreCase("hand")) {
if (!sender.isPlayer()) {
throw new Exception(tl("consoleCannotUseCommand"));
}
itemType = Inventories.getItemInHand(sender.getPlayer());
} else {
itemType = ess.getItemDb().get(args[0]);
}
int recipeNo = 0;
if (args.length > 1) {

View File

@ -157,6 +157,7 @@ commandHelpLine3=\u00a76Usage(s);
commandHelpLine4=\u00a76Aliases(s): \u00a7f{0}
commandHelpLineUsage={0} \u00a76- {1}
commandNotLoaded=\u00a74Command {0} is improperly loaded.
consoleCannotUseCommand=This command cannot be used by Console.
compassBearing=\u00a76Bearing\: {0} ({1} degrees).
compassCommandDescription=Describes your current bearing.
compassCommandUsage=/<command>
@ -1025,8 +1026,8 @@ recentlyForeverAlone=\u00a74{0} recently went offline.
recipe=\u00a76Recipe for \u00a7c{0}\u00a76 (\u00a7c{1}\u00a76 of \u00a7c{2}\u00a76)
recipeBadIndex=There is no recipe by that number.
recipeCommandDescription=Displays how to craft items.
recipeCommandUsage=/<command> <item> [number]
recipeCommandUsage1=/<command> <item> [page]
recipeCommandUsage=/<command> <<item>|hand> [number]
recipeCommandUsage1=/<command> <<item>|hand> [page]
recipeCommandUsage1Description=Displays how to craft the given item
recipeFurnace=\u00a76Smelt\: \u00a7c{0}\u00a76.
recipeGrid=\u00a7c{0}X \u00a76| \u00a7{1}X \u00a76| \u00a7{2}X