Skip to content

Commit

Permalink
Add ability to get recipe of item in hand (EssentialsX#5346)
Browse files Browse the repository at this point in the history
Co-authored-by: Josh Roy <[email protected]>
Co-authored-by: pop4959 <[email protected]>
  • Loading branch information
3 people authored May 28, 2023
1 parent 357cd6b commit 646b60a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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;
Expand Down Expand Up @@ -53,7 +54,18 @@ public void run(final Server server, final CommandSource sender, final String co
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) {
Expand Down
5 changes: 3 additions & 2 deletions Essentials/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 646b60a

Please sign in to comment.