Sueta

Global Item Commands

1.06

Allows you to bind commands to any items

·Plugin

This will let you bind a command to any items. Just like Essentials' powertool, but more flexible. The commands are global, meaning if I add the "home" command to a stick, any player on the server right clicking a stick in the air will execute /home. They do not have to do anything to enable it. Obviously you may not want everyone having it, so it also supports permission nodes. You can specify as many dependent permissions as you wish. You can also make it require that the item be named a certain way. You can stack commands as well, not just one command.

Note: Any time a command asks for an item, it's using the standard material constants as seen here. Also when "item" is mentioned in the docs, it means the item in the player's hand or the material name passed by the console.

Commands, their permission nodes and how to use them:

First a special permission note:
For a player to use the functionality at all, they must have the gic.use permission!

/itemcmd add command player|console item
gic.add

This is what you use to add a command to an item. I'm a novice Java coder, so I haven't figured out yet how to properly handle spaces in my arguments so if you need to do a space, use a underscore. I'll work on that, I know it sucks lol. Player means execute as the player, console means execute on console. Player must have gic.admin or gic.add.console to be able to use console option.

/itemcmd clear item
gic.clear

This will remove any existing commands from the item.

/itemcmd reqname name item
gic.reqname

Makes it so to run the command, the item must be named with a specific name. It's not case sensitive, but spaces do count.

/itemcmd reqperm permission item
gic.reqperm

Makes it so to run the command, the player must have the permission node specified. To use multiple permissions, comma delimit them.

/itemcmd toggle player|!uuid item
gic.toggle

Toggles functionality of the commands on and off. So if you don't want the command to fire off, you can toggle and it won't until you toggle again. If running from the console, pass it the player's name. If the player is not online, you would need to know the UUID. If you do, pass it with an exclamation point prefixed so the command knows you are passing a UUID.

/itemcmd info item
gic.info

Displays information about the item. Shows what command(s) it performs, what permission(s) are required and what name is required.

/itemcmd reload
gic.reload

Reloads the configuration file from disk.

/itemcmd cfg option [option parameters]
gic.admin

Used to configure things. See the following for specifics.

/itemcmd cfg activation rca|rcb|lca|lcb|phy
gic.admin

Determines what action will trigger the commands. The options can be stacked by comma delimiting them. The options are:
rca - When the player right clicks air with the item
rcb - When the player right clicks a block with the item
lca/lcb - As above, just for left clicking
phy - When activating physical items. I actually have no better way to describe that, lol, that's just what the action is called in the class. Stuff like pressure plates and tripwires cause this action.

Examples:

Let's say you want to make a stick that will shoot lighting and fireballs. You want only certain people to be able to use it, and the stick should be named "My BoomStick". Whilst holding a stick, you would do:

/itemcmd add lightning,fireball player
/itemcmd reqname My_BoomStick
/itemcmd reqperm gic.group.pranksters,essentials.lightning,essentials.fireball

Now when a player swings the stick in the air, it'll unleash devastation if it meets the criteria I described. Nice thing about throwing in essentials.lightning is say I have a PEX group AnnoyingPeople and I gave it the perm gic.group.pranksters. One person in there though I don't want using lightning. If I had just did gic.group.pranksters, when they swing it they would get the Essentials "permission denied". Since the essentials permission is part of the item level permissions, it won't even try to fire the /lightning so no error denied messages.

Command Shortening:

I'm lazy, so I made it to run slimmed down:

/ic a home p - Same as /itemcmd add home player. Obviously use c for console.
You can use r for reload, i for info, rn for reqname, rp for reqperm, c for clear and t for toggle.

In the configuration section, you can use ac for activation.

Customizing Messages:

On first run, it should pregenerate a config.yml with all the strings. I'd list all the meanings in here, but I think I named them fairly self explanatory. It uses the & codes for colors. It understands some tokens; %player% as the player's name, or Console if ran from the console and %br% as a line break. Remember, line break = new player.sendMessage execution so colors must be reset after a line break. It also, for the info command, understands %data% for the permission/command when it iterates those lists. For things that have more than one, it's %data1% and %data2%, etc.

List of what strings have data options:

info-cmd-header - %data% returns player or console
info-cmd-data - %data% returns the each individual command as it loops
info-perm-data - %data% returns individual permissions as it loops
info-name-header - %data% returns the required name
config-activation-data - %data% returns the action description for the activation method
config-activation-bad - %data% returns the action code tried
config-activation-data - %data1% returns the action's code and %data2% returns a description on said action

If you look at the default strings in the config.yml, those explanations for the data variables should make sense once seen in context.

Upcoming Features:

One thing I want to do next is to make it so you can bind commands not only to items, but to the actions applied to said items. So a stick when right clicked in the air would /home, but a stick right clicked on a block would /sethome for example.

Ooh that gave me another idea. It'd be cool to make "teleport keys" or something. I could make another activation parameter where, if the action is right/left click block or physical, the block clicked / item interacted with needs to have a specific name set. So that way you could put down a pressure plate and name it "Mountain Base" then make a tripwire hook setup so commands activate on physical and physical interacted item must be named "Mountain Block" then run command /tppos #/#/#. That'd be kinda cool; you could give the "key" to someone so they can walk on the "teleport pad" to be sent to where the key is set.

Of course, right now activations are global so I'd also have to make it more configurable - actions would also have to be tied to the item. But then I need to make it allow for more than one item with commands.. ugh. One thing leads to another leads to another :)

Someday, when I get more motivation hehe.

Similar projects

Plugin →