CBWrapper
CBWrapper
Concept
Have you ever wanted to be able to use WorldEdit from command blocks? Or other plugins, too, whose commands won't work from command blocks. Well, this is the plugin for you! When the command /cw is run from a command block, it will create a dummy player where the command block is and run the command specified in the command parameters!
News
Some people (everybody) were getting issues between CBW 1.8_alpha, Essentials, and a few other plugins. These conflicts are a side effect of how CBW 1.8_alpha works and is what I hoped wouldn't happen. Avyge1l came up with a solution, which I have now implemented. The plugin now works almost exactly the same way it did in 1.7, but it works for 1.8 still.
Installation
Standard bukkit plugin installation; download the CBWrapper.jar and stick it in your plugins folder
Source Code
Version | Source Link |
Development Version | https://github.com/misson20000/CBWrapper |
Version 1.8.3 (current) | https://github.com/misson20000/CBWrapper/tree/v1.8.3 |
Version 1.8 | https://github.com/misson20000/CBWrapper/tree/v1.8 |
Version 1.8_alpha | https://github.com/misson20000/CBWrapper/tree/v1.8-playerlist |
Usage
If anything doesn't make sense, you might want to consult this page, which I think is a bit more friendly but less clear.
Just tell me how to use the plugin as fast as you can
Put /cw
in front of your commands and remove the first slash. WorldEdit commands will have one slash left and other commands will have no slashes left. Use commands just like you would as a player. Look at the examples for complicated things
That was great but didn't make much sense
That's what this section is for. Here I'll explain everything in more detail
CBWrapper adds one command, /cw for use in command blocks. The general usage is as follows:
/cw [-u username] [-w world] [ -o x y z] <command> [arguments]
For many purposes, however, simply
/cw <command> [arguments]
is sufficient.
The /cw command create a fake player and runs the command as it. This allows you to use commands from plugins that would usually only work for players. The best example of this would be WorldEdit. WorldEdit is usually meant for only players to use, and has no support for command blocks. Using the /cw command, you can trick WorldEdit into thinking that a player is using it and allow the operation.
Say you wanted a command block system to reset a spleef arena every time a new round starts.
You could put a command block at each corner to run the WorldEdit selection commands //pos1
and //pos2
and another
command block to replace the empty blocks with snow or whatever material you are using.
What if I want to have the command blocks far away? No problem. Use the -o option. -o originally stood for offset, but now it would make more sense as -p for position. Oh well. You give it 3 numbers, which are interpreted as coordinates. And numbers starting with a ~
will be interpreted as relative, so -o 5 ~0 -4
would mean run the command at X coordinate 5, use the command block's Y coordinate, and Z coordinate -4.
How about selecting regions in different worlds? Use the -w for world option. It takes one parameter: the name of the world to run the command in. Usually this would be "world", "world_nether", or "world_the_end." If you have Multiverse or something installed, the name of the multiverse world should work too. The -w option is best used with -o, because otherwise your command will be run in the same position, but in the nether or whatever world you specify.
That's great, but how can I prevent my selections from colliding? Pretend to be different players with the -u option. It takes one parameter: the username it pretends to have. WorldEdit thinks it's different players, but it actually isn't any players at all. It's just command blocks.
Examples
Select corner 1 of a WorldEdit selection: /cw /pos1
Select corner 2 of a WorldEdit selection: /cw /pos2
Replace blocks in selection: /cw /replace air snow
Make sure you don't use /set or /wall, as those might delete your command blocks!
Ban whoever dares approach the command block and pretend that someone else did it: /cw -u @r ban @p
Select a corner 2 blocks above the command block /cw -o ~0 ~2 ~0 /pos1
Select the coordinates (0, 0, 0) in the nether: /cw -w world_nether -o 0 0 0 /pos1
Stop the server: /cw stop
Help me it still doesn't make sense!
Leave a comment below. Post the commands you tried, what you're trying to do, and anything else you think would be helpful.
Be careful with the wiki formatting, it can mess things up. Usually putting {{{
and }}}
around your commands helps
Permissions
There is only one permission node, "cbwrapper.cb", for the /cw command
Other Notes
- The dummy player's username, by default, is "@"
- The dummy player's position is the position of the command block it was run from, unless you use the -o flag
- The dummy players isn't actually registered as a player, so you can't teleport people to it or anything
- The dummy player is an op with all permissions. The only bit of security is that the dummy player is only created by command blocks, which can only be edited by ops in creative mode
If you comment anywhere other than this page, I probably won't see it for at least a few months. PMs are fine, too
Thank you so much for making this! I'm on mc version 1.5.2 but it isn't working. I don't know if your plugin is now out of date or I'm doing something wrong. When I load up the server it says: [SEVERE] Could not load 'plugins/cbwrapper.jar' in folder 'plugins' org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError
@stapleshotz Yes, there would be conflicts, however you can put the command block in an anvil, rename it, and place it to solve conflicts. All command blocks of the same name share a dummy player
@Benja6678
Sorry, but I can't help you enless you tell me what the plugin says
I haven't tested this yet, but wouldn't there be some sort of conflict if you have 2 command blocks activating at once? I can't think of a good example, I'm just wondering if this would ever be an issue.
Hi, the plugin sends an error message when i start my server - I am using 1.5.1 Spigot and the latest version of this plugin. Is Spigot the reason its not working? thanks
@xfeldt
When CBWrapper gets a /cb command, it will first check what kind of command sender sent the command. There are 3 types of command senders that I know of: Player, ConsoleCommandSender, and BlockCommandSender. The first 2 should be pretty self-explanitory, but a BlockCommandSender is created when a command block is powered. My plugin gets one of those command senders, and it checks to see what kind it is. If it is a Player, CBWrapper will run the specified command as the player that sent the command. If it is a ConsoleCommandSender, CBWrapper will tell the console that /cb doesn't work from the console. If it is a BlockCommandSender, CBWrapper will find out the X, Y, Z, and anvil given name of the command block. It will then create a dummy player based off of this information and run the specified command as that dummy player. If you can read Java, here is the source code. For WorldEdit, I can name a command block "wegroup1" and place it in a few different locations. WorldEdit doesn't care about different player objects. WorldEdit just cares about their usernames, so all those "wegroup1" command blocks will look like the same person in different places to WorldEdit. I can name some different command blocks "wegroup2", and they will look like a different person than "wegroup1". There is currently no way to name the dummy player other than by using an anvil. In the source code on github, there is partially implemented support for a -u option. It doesn't work right now, though.
The anvil method is actually sufficient.
I am not sure if I understand it right. Does CBWrapper only distinguish between the players who use the commandblock, or is there a way (without anvils) to set something like a commandblock-group which operates under its own dummyname? And if so, how do I do it? Sorry if I can't explain better, my english is rather limited.
Thanks a million!!
Okay, CBWrapper v1.1 for 1.5.1 has been approved. I took down the mediafire download
Link Removed: http://www.mediafire.com/?nii77w7id7cz95z is the 1.5 version of the plugin. I'm going to take down this download when they approve it here on bukkitdev, though.
The 1.4.7 version does not work with 1.5, because 1.5 introduced some new mechanics that were added to bukkit's player interface. It didn't work because bukkit would try to call one of the new 1.5 methods on my dummy player, and they didn't exist, because I hadn't updated the plugin yet. I did update the plugin, and it is awaiting approval.
@misson20000
Is the 1.4.7 version working for 1.5? :0
@misson20000
Could you link me the 1.5 version? I don't see it under the "Files" tab. If you can't please let me know, or send me a PM..
And there is actually a way to have more than 1 user. You can rename the command block with an anvil, and the username of the dummy player will be the username of the command block. I'll still add a better way to do that, though.
Sorry I didn't get to your wishes earlier... I'll update it and add multiple users.
Is there a way to have more than one virtual user. Like /cb <instanz> <command>. For example:
Atm it is not possible to do two things at once and thus one can not use the cb command in two redstone circuits with a clock.
Me too :D Very nice plugin, that'd solve a LOT of problems for me, an update would be awesome
Can you post a link to the source? I see this is GPLv3 and I was going to look at giving a shot at updating for 1.5.1. This plugin seems like a really great idea. Thanks!
PLEEEEEEEASE UPDATE IT! D: