PowerTool
PowerTool — Bind commands to items
Originally requested by InflamedSebi in this thread.
PowerTool allows you to bind commands to your in-hand items. Any item may be assigned commands for both left-click and right-click. Bound commands remain until you manually clear the binding.
Please post bugs and/or feature requests as dev.bukkit.org tickets.
Features
- Bound commands may include special tokens which are appropriately substituted when the item is used. Currently, these are:
Token | Description |
---|---|
%p | The name of the player you left-clicked or right-clicked. |
%x | X-coordinate of the block targeted by your crosshairs |
%y | Y-coordinate of the block targeted by your crosshairs |
%z | Z-coordinate of the block targeted by your crosshairs |
%Y | Y-coordinate of the nearest air block above the block targeted by your crosshairs |
All of these tokens are configurable.
-
Works in creative mode. Right-clicking and left-clicking players in creative mode will generally work, even when far away (up to 100 blocks).
-
Ability to define global power tools. These are administrator-defined binds that can be made available to whoever you want (based on permissions).
-
Fine-grained control over the use of power tools via permissions.
-
Global power tools may grant temporary permissions or even be run as the console. Needless to say, these features should be used with care.
-
The number of player-created binds may be limited based on group/permission.
-
Items may be further differentiated by custom display name (e.g. when given one via Anvils). Note this option is off by default, enable it in the configuration file.
Commands
There's only one command, /powertool
which may also be abbreviated /pt
or /ptool
:
/powertool left <the-command-to-bind>
— Binds the command (and its arguments) to the left-click action of the current item. The command must not include the first slash. This may also be abbreviated as/powertool l
./powertool right <the-command-to-bind>
— Binds the command (and its arguments) to the right-click action of the current item. This may also be abbreviated as/powertool r
./powertool left
— With no command to bind, the currently-bound left-click command is cleared from the current item. Use/powertool right
to clear the right-click command./powertool list
— Displays all player-defined power tools for the current player./powertool clear
— Clears all bound commands from the current item./powertool clear <item-id-or-name>
— Clears all bound commands from the specified item./powertool clear -a
— Clears all bound commands from all items./powertool on
— Enable power tools for this session (default is on)./powertool off
— Disable power tools for this session./powertool toggle
— Toggle power tools availability. Can also be abbreviated as/powertool t
./powertool reload
— Re-reads config.yml.
Permissions
PowerTool only supports Bukkit permissions (aka Superperms). By default, ops have all permissions.
powertool.use
— Allows the use and creation of power tools. (Haspowertool.use.*
andpowertool.create
as child permissions.)powertool.use.*
— Allows the use of all power tools.powertool.use.<item-id>
— Allows the use of a specific power tool identified by item-id. item-id may be numeric (e.g. 322 for golden apple), or the Bukkit Material name with or without underscores (e.g. GOLDEN_APPLE or GOLDENAPPLE). Note that Bukkit permissions are not case-sensitive, so bothpowertool.use.golden_apple
andpowertool.use.GOLDEN_APPLE
work fine.powertool.create
— Allows the creation of personal power tools. A player must be given this permission in order to use the left/right/list/clear subcommands.powertool.reload
— Allows use of/powertool reload
Additionally, per-group power tool limits may be defined using permissions. See the options
section in config.yml for details.
Global, Administrator-defined Binds
By editing config.yml, the server administrator can define binds for use by anyone with the powertool.use
permission.
For example:
powertools:
string:
left-click: plugins
right-click: version
The item ID ("string" in the above example) may be an integer item ID or a name. If using an integer item ID, you must quote it as a string, e.g. '287'
for "string." If using a name, you must use a standard Bukkit material name (found here). For example, for golden apples, you may use one of:
GOLDEN_APPLE
'golden apple'
(since it has a space, it must be quoted)goldenapple
Examples
-
Promote and demote users using the left-click and right-click actions of the current item:
/powertool l promote %p
/powertool r demote %p
-
Bind WorldEdit's copy & paste commands. Remember that many WorldEdit commands normally start with two slashes, but you must always omit the first slash.
/powertool left /copy
/powertool right /paste
License & Source
PowerTool is released under the Apache License, Version 2.0.
Sources may be found on GitHub:
Development builds of this project can be acquired at the provided continuous integration server. These builds have not been approved by the BukkitDev staff. Use them at your own risk.
- PowerTool (Requires ToHPluginUtils.jar)
- PowerTool-standalone (includes ToHPluginUtils, like the version distributed on dev.bukkit.org)
To Do
- Allow setting/clearing global power tools from the command line (for those with the proper permission, of course).
- Allow player-specific power tools to override global ones.
- Allow global power tool flags (e.g. run-as-console) to be assigned to each individual action.
(#7)
I will probably only be using global power tools for multiple lines of command. But it would still be a nice feature. That being said, if you want it for personal power tools as well, perhaps you could make it so you enter the command twice? What I mean:
So that way it adds the second command to that player's config. So after typing the first command it looks like this:
But after the second command it looks like this:
Just how I would do it for personal tools if I wanted/needed to. Since you asked.
(#3)
There is nothing special about books. It was just an example.
For some reason I missed the display name option. How do you get it to work? I tried adding a global power tool named "wand' in the config. And then gave myself a stick named "wand". But it didn't seem to work.
Still, the ability to have the same object with different names (like books) issue different commands is awesome. The two best ways I can think of accomplishing this is the item's name (like you currently have) or the item's damage value.
Take a look at this plugin and its config: http://dev.bukkit.org/server-mods/itemrenamer/pages/configuration/
It uses item damage values to rename items (even that damage value doesn't change block/item). Like giving yourself stick:4 (stick with a damage value of 4) could have a different name then giving yourself stick:2. Perhaps you could code it similarly? And then someone could use both of these plugins together? Have that plugin rename stick:2 to Wand and stick:17 to Staff of Healing. Then have PowerTools make stick:2 and stick:17 issue spells (commands) but have stick:0 (plain stick) do nothing.
So config (shortened):
(I wrote this comment really fast and hardly looked over it. Let me know if something doesn't make sense.)
@SanguineScythe
Those requests already exist as tickets #7 and #3. Though I guess I've been sitting on #3 for quite a while. But with your explanation, it makes a bit more sense. So I will probably be adding that next.
There is already (partial) item data and even item name support. What's special about books?
For #7, what is your proposal for a command line interface to enter multi-line commands? Or would this be restricted to global power tools only?
Alright. Here is the next ones:
1) Simple idea, but a very nice feature. More than one command per use for global items. In the config you could do something like this:
And maybe put a miniscule delay between the commands and have them execute in the order they are listed.
2) Config option for global items to be used on use. Such as add a "removeonuse: true/false" setting to each item's config. This would remove item from the players inventory when they right or left click (only one item per use, not the whole stack).
With these two options, there is so many more uses for this plugin. Custom food (with /heal and /effect or /buff), a one time teleport item, magic scrolls (book or something is destroyed but casts a spell, will be really awesome if you add in support for item data), lockpicks to open locked doors (with the already added temp perm), etc.
Once again, thank you for listening and for your time and effort put into this.
@jacob_vejvoda
Not at this time. The global power tools can only be defined by someone who can edit the config file.
Can an OP make a PT have a command then give the PT to a user and the user be able to use the PT?
what are all /pt commands?
@ZerothAngel
Well, I tried out build #281 and it seemed to fix that message. Thanks. =)
@SanguineScythe
Glad to hear it works for you!
This plugin actually doesn't output any message like that. Most likely it's coming from Essentials' own "powertool" feature. (This plugin started out as a clone/alternative to the Essentials version, after all...)
@ZerothAngel
I just tried this out on a test server running Essentials, GroupManager, and the latest development build of PowerTool (and about 15 other popular plugins). It worked perfectly!
The only noticeable problem was that a "You are not permitted to use <itemname>" message appears when someone who does not have the normal permission uses a global PowerTool. The command still executed though.
Other than that one small problem, it works great. Thank you so much for this. You are awesome!
@SanguineScythe
I've been meaning to get to it, but I've been busy with one of my other plugins.
Anyway, I got something working this morning. Dev build 275+ will have it. (See above for link. I can't link to it in a comment because it's against the rules.)
Something like the following should work now:
I don't use Essentials, though I tested the above with CommandBook. I assume the behavior of "shock" is similar.
I plan to add a permission-based option as well, where the player is temporarily granted permissions while they run a global power tool.
But that's for another time.Temporary permissions now also work:
Doing it this way runs the command as the player but grants them the named permissions (
commandbook.shock
andcommandbook.shock.other
) temporarily (for 1 tick).I don't want to pressure you or anything, but I would just like to know if you are currently working on or are ever going to implement the feature for a PowerTool to bypass a player's permissions (like we shortly discussed).
Once again, thanks for your time.
umm i was Just Thinking of Adding some of the Commands allowed in Command Blocks Example: (/powertool invsee @n) would allow you to see the Nearest Players Inventory and (/powertool kill @a) would Kill all Players and a (/powertool kill @p) or something of the sort to make the command only affect you
Obviously some Commands Wouldnt be able to work such as (/powertool invsee @a) Because you couldnt be viewing all Players inventories at Once
Just a suggestion hope its read (;
@cupcakekid7
Use your permissions plugin to give everyone the
powertool.use
permission.If you don't have a permissions plugin, I think adding something like the following to permissions.yml will work:
As of right now there is no way to make this work for everyone on the server or am i missing something somewhere??
@ZerothAngel
Sorry for the slow reply. Yeah, I was thinking about it executing the command through the console. That is how I have seen it done on other plugins.
Hmm...I wish I could remember specific examples though. But I know quite a few use this technique and I think I have seen a few tutorials on how to do it. To be honest, I am in no way an expert at this. Otherwise I wouldn't be asking you to do it. =P
Good luck on the research and coding, if you decide to do this. And thank you so much.
Also: I am pretty much focusing only on global tools. I guess I don't really have any need for the personal ones, is all. Maybe you should split it into two plugins. One for personal "powertools" (like you had before I came and messed everything up) and one for globally set commands on items (the direction this plugin is headed)? Hmm...just an idea.
@SanguineScythe
So basically a "sudo" or "runas" feature? Seems like treading in dangerous waters... ;)
Originally I thought running the command as console might work. But then some commands don't work when run as console and need an actual player (e.g. for current location).
So granting temporary permissions? Might work, but the trick would be making sure the permissions go away.
I don't know, it's going to need some research. What are other plugins that do something similar? I think CommandHelper has a "run-as" feature. Any others?
Anyway, if I did implement this, it would probably be a per-power tool switch only for global power tools.
Example (server has both Essentials and PowerTool):
Admin wants a user to have the lightning command both normally and the Powertool version through a stick. Gives them both the "essentials.lightning" permission and the "powertool.use.stick".
OR
Admin wants a user to have the lightning command only through Powertool. Gives them just the "powertool.use.stick" permission.
OR
Admin wants a user to be able to use the lightning command only through the command line. Gives them just the "essentials.lightning".
@ZerothAngel Awesome! You are the best. Tried it on my 1.4.7 server and it works great. There is only one catch:
@Minecrafterguy64 This. I actually thought the commands executed by the items bypassed the user's permissions. It would be awesome if you could make this happen. It would also make more sense for it to work this way now - If an admin doesn't want someone to use a command normally, than they will not give them permission to the PowerTool version of that command. But if they want them to only have the PowerTool version (so players need the item to execute the command), then that is possible too.
Once again: Thank you so much for your time with this. It is a great plugin with an even better author. Keep up the good work. =)
I want to bind /lightning to a stick and use it as a wand to give to people who aren't op. Of course, if you aren't op, then it won't work since /lightning is only for ops? How do I do this?