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
Will this plugin ever be updated to 1.11?
I have the same problem.. it works fine for a few minutes but then it stops working. The commandblocks just dont do anything anymore even if i create new ones. After a server restart everything works again for a few minutes. Using an older Version (1.8 or 1.8alpha instead of 1.8.3) does not work for me... same problem there. Its such a great plugin and i really need it.. Is there any way to fix this? I would appreciate it :) Im using Spigot 1.8.8.
@Kiwiko1
Same issue
PLease smoeone tell me how to fix it it works for few minutes and then it stopes pls help me.
@deartoto
I have the same problem, but I'm on 1.7.10.
@Wavebrother
I solved the problem. Just download an older version of 1.8. (not 1.8.3). For other players with the same problem ;)
I have the same problem ass Wavebrother, it works only for a short time. Is there a solution? Help me please :/
Hello, I got the plugin up and running, however the command blocks stop working after a short amount of time. I don't see anything in the console even when they do work. These are the commands:
Just saying, I am planning some great great things with your plugin, in conjunction with movecraft. Thank you for all your hard work and efforts. *This Guy Appreciates you/IT*
@misson20000
Sure, I'll default to using pastebin in the future.
http://pastebin.com/RJWRZfi0
As you can see the error started exactly 3 minutes after "test" says hi, from the command "/cw -u test -o 0 1 2 say hi". The default config for CommandBook (AFK) shows that AFK kicks in at 3 minutes. The error then proceeds to spam the console as I'm guessing it is constantly trying to mark "test" as AFK and can't. Not sure how God-mode ties in but it was in the error so I just took it out anyway.
@GrinningMoon
That's good that it works. Can I get the errors with the AFK and Godmode components (on Pastebin- BukkitDev makes the exceptions very hard to read) so that I can try to fix this?
@misson20000
Soooooo... yeah. Just tried out 'CBWrapper for 1.8.3' for shits n' giggles and the two commands I was trying went through... as well as loading and pasting a schematic with the dummyplayer via console. So I don't really know what to think. (Knock on wood) the only noticeable side effect I've found so far is that the AFK and God-mode components from CommandBook were spamming errors. Maybe that's because they mistook the dummyplayers for real players? I don't know.
I'll report back with any other errors/limits I find in case someone is using this post to determine whether they should use CBWrapper for Cauldron 1.7.10.
@misson20000
Thank you misson for your reply and apologies for taking so long to reply myself! Full disclosure, I was using CBWrapper 1.8_alpha on my 1.7.10 Cauldron (build 1236) server. Some of the other plugins I've come across (namely WorldGuard) have stated reverse compatibility with CB 1.7.9 so I figured (desperately) that that may be the case with CBWrapper. As you can see, it wasn't. So reverting back to CBWrapper 1.7, here are some of the commands I've tried running and their errors. I've tried searching outside my logs folder but this is the full error I get (can't find what the "18 more" is). If there is other information you need that you can direct me to, I can get that for you as well.
/cw -u test -o 0 1 2 /replacenear 10 19 3
[23:29:27] [Server thread/ERROR]: [WorldEdit] Could not dispatch event: com.sk89q.worldedit.event.platform.CommandEvent@3c43ec73 to handler EventHandler{priority=NORMAL} java.lang.reflect.InvocationTargetException at com.sk89q.worldedit.util.eventbus.EventHandler.handleEvent(EventHandler.java:75) [EventHandler.class:?] at com.sk89q.worldedit.util.eventbus.EventBus.dispatch(EventBus.java:187) [EventBus.class:?] at com.sk89q.worldedit.util.eventbus.EventBus.post(EventBus.java:173) [EventBus.class:?] at com.sk89q.worldedit.bukkit.WorldEditPlugin.onCommand(WorldEditPlugin.java:242) [worldedit-bukkit-6.0-beta-01.jar:?] at com.sk89q.bukkit.util.DynamicPluginCommand.execute(DynamicPluginCommand.java:54) [worldedit-bukkit-6.0-beta-01.jar:?] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:181) [SimpleCommandMap.class:git-Cauldron-MCPC-Plus-1.7.10-1.1236.06.212] at org.bukkit.craftbukkit.v1_7_R4.CraftServer.dispatchCommand(CraftServer.java:717) [CraftServer.class:git-Cauldron-MCPC-Plus-1.7.10-1.1236.06.212] at misson20000.plugins.cbwrapper.CBWrapper.onCommand(Unknown Source) [CBWrapper.jar:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) [PluginCommand.class:git-Cauldron-MCPC-Plus-1.7.10-1.1236.06.212] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:181) [SimpleCommandMap.class:git-Cauldron-MCPC-Plus-1.7.10-1.1236.06.212] at net.minecraft.command.server.CommandBlockLogic.func_145755_a(CommandBlockLogic.java:220) [agp.class:?] at net.minecraft.block.BlockCommandBlock.func_149674_a(BlockCommandBlock.java:63) [akb.class:?] at net.minecraft.world.WorldServer.func_72955_a(WorldServer.java:740) [mt.class:?] at net.minecraft.world.WorldServer.func_72835_b(WorldServer.java:272) [mt.class:?] at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:920) [MinecraftServer.class:?] at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:423) [lt.class:?] at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:798) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:658) [MinecraftServer.class:?] at java.lang.Thread.run(Thread.java:745) [?:1.8.0_25] Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.GeneratedMethodAccessor90.invoke(Unknown Source) [?:?] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [?:1.8.0_25] at java.lang.reflect.Method.invoke(Method.java:483) [?:1.8.0_25] at com.sk89q.worldedit.util.eventbus.MethodEventHandler.dispatch(MethodEventHandler.java:58) [MethodEventHandler.class:?] at com.sk89q.worldedit.util.eventbus.EventHandler.handleEvent(EventHandler.java:73) [EventHandler.class:?] ... 18 more Caused by: java.lang.NullPointerException at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:213) [minecraft_server.1.7.10.jar:?] at com.sk89q.worldedit.session.storage.JsonFileSessionStore.getPath(JsonFileSessionStore.java:81) [JsonFileSessionStore.class:?] at com.sk89q.worldedit.session.storage.JsonFileSessionStore.load(JsonFileSessionStore.java:87) [JsonFileSessionStore.class:?] at com.sk89q.worldedit.session.SessionManager.get(SessionManager.java:147) [SessionManager.class:?] at com.sk89q.worldedit.extension.platform.CommandManager.handleCommand(CommandManager.java:216) [CommandManager.class:?] at sun.reflect.GeneratedMethodAccessor90.invoke(Unknown Source) [?:?] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [?:1.8.0_25] at java.lang.reflect.Method.invoke(Method.java:483) [?:1.8.0_25] at com.sk89q.worldedit.util.eventbus.MethodEventHandler.dispatch(MethodEventHandler.java:58) [MethodEventHandler.class:?] at com.sk89q.worldedit.util.eventbus.EventHandler.handleEvent(EventHandler.java:73) [EventHandler.class:?] ... 18 more
/cw -u test -o 0 1 2 say hi
[23:37:09] [Server thread/WARN]: com.sk89q.minecraft.util.commands.WrappedCommandException: java.lang.NullPointerException [23:37:09] [Server thread/WARN]: at com.sk89q.minecraft.util.commands.CommandsManager.invokeMethod(CommandsManager.java:538) [23:37:09] [Server thread/WARN]: at com.sk89q.minecraft.util.commands.CommandsManager.executeMethod(CommandsManager.java:516) [23:37:09] [Server thread/WARN]: at com.sk89q.minecraft.util.commands.CommandsManager.execute(CommandsManager.java:409) [23:37:09] [Server thread/WARN]: at com.zachsthings.libcomponents.bukkit.BukkitComponent.onCommand(BukkitComponent.java:80) [23:37:09] [Server thread/WARN]: at com.sk89q.bukkit.util.DynamicPluginCommand.execute(DynamicPluginCommand.java:54) [23:37:09] [Server thread/WARN]: at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:181) [23:37:09] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_7_R4.CraftServer.dispatchCommand(CraftServer.java:717) [23:37:09] [Server thread/WARN]: at misson20000.plugins.cbwrapper.CBWrapper.onCommand(Unknown Source) [23:37:09] [Server thread/WARN]: at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) [23:37:09] [Server thread/WARN]: at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:181) [23:37:09] [Server thread/WARN]: at net.minecraft.command.server.CommandBlockLogic.func_145755_a(CommandBlockLogic.java:220) [23:37:09] [Server thread/WARN]: at net.minecraft.block.BlockCommandBlock.func_149674_a(BlockCommandBlock.java:63) [23:37:09] [Server thread/WARN]: at net.minecraft.world.WorldServer.func_72955_a(WorldServer.java:740) [23:37:09] [Server thread/WARN]: at net.minecraft.world.WorldServer.func_72835_b(WorldServer.java:272) [23:37:09] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:920) [23:37:09] [Server thread/WARN]: at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:423) [23:37:09] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:798) [23:37:09] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:658) [23:37:09] [Server thread/WARN]: at java.lang.Thread.run(Thread.java:745) [23:37:09] [Server thread/WARN]: Caused by: java.lang.NullPointerException [23:37:09] [Server thread/WARN]: at com.sk89q.commandbook.util.entity.player.UUIDUtil.toUniqueString(UUIDUtil.java:19) [23:37:09] [Server thread/WARN]: at com.sk89q.commandbook.session.SessionComponent.getSession(SessionComponent.java:180) [23:37:09] [Server thread/WARN]: at com.sk89q.commandbook.MessagingComponent$Commands.say(MessagingComponent.java:190) [23:37:09] [Server thread/WARN]: at sun.reflect.GeneratedMethodAccessor79.invoke(Unknown Source) [23:37:09] [Server thread/WARN]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [23:37:09] [Server thread/WARN]: at java.lang.reflect.Method.invoke(Method.java:483) [23:37:09] [Server thread/WARN]: at com.sk89q.minecraft.util.commands.CommandsManager.invokeMethod(CommandsManager.java:528) [23:37:09] [Server thread/WARN]: ... 18 more
All this being said, I did read your reply fully and I do understand that adding compatibility for Cauldron may just be too much work. I'm willing to take any chance I can get though!
@misson20000
I know that each added dependency is a complication, (f.e. should be good to implement dynmap also, now we must run one extra command /dynmap hide for each new DummyPlayer, ... or just try to call this command directly from code during creating new DummyPlayer) but: try to take hiding (ListListener.class) from my code at least. Do your best, I did my, now we are without errors and that was my only wish. Thx for coop.
@mwkaicz
I took a different approach to solving this problem. It would be really hard to integrate with each plugin (Essentials isn't the only broken plugin here), so I reverted back to the 1.7 code and implemented an idea from Avygeil where I use Reflections to integrate with WorldEdit. Everything's working great on my local test server, and it should be available as soon as it passes approval
@misson20000
Hi, I made reverse engineering from 1.8_aplha yesterday and now I have fixed this error, I'll fork your repo today and make a merge request with this fix.
EDIT: There will be necessary to make softdependency to Essentials for fix this error, so it's your choice if you merge it or not.
I: It's normal that I see these users in player list (TAB and also in server list) ?
II: There are still some bugs in repo (git clone causes that cbwrapper folder contains only two files, zip file gets all src, but f.e. plugin.yml gets only version 1.0 with .yml~ subfix) How to edit this tag? I know only about editing branches.
III: I made a temporary parallel repo, so please try to take content and look on it: https://github.com/mwkaicz/CBWrapper_Essentials + I added hiding DummyPlayers from TAB and server list
@mwkaicz
The GitHub repo is recent, I just forgot to update it. The 1.8 code is up there now. I've got a few more ideas to try to fix these problems, which I'm working on soon. I've done some work on CBWrapper since the last release, so use this link for the source code to 1.8_alpha (the current release, as of writing this comment)
We have one of latest spigot and it works fine. But:
There is problem with Essentials plugin.
I know that this error comes from Essetials, but i think that it should be fixed in this plugin. Because Essentials have some problems with this imaginary CBW entity. Both plugins keeps working but this error causes big spam in console log.
Is sourcecode of this plugin published somewhere? GitHub repo looks very deprecated.
EDIT: I found source of the problem: Essentials Timer (for kicking AFK players) is trying to get latest user Activity but it can't find any record about user and returns user = null which resulting to spam in console each 2 seconds.
It's little bit complicated because essentials see a user (well enough to kick him) but can't get own userdata from this user.
temporary solution:
create a file user_name.yml in Essentials/userdata/ (Essentials will convert its name to UUID name and spam will disappear) turnoff autokick
I think this has broken with the latest Spigot build... is this just me?
@GrinningMoon
I might be ablt to get Cauldron support in, but it's already tricky getting the plugin to work with CraftBukkit and Spigot. Also, I think there's a little bit more to that error than is shown there. The part that I'm interested in:
java.lang.NoClassDefFoundError: misson20000/plugins/cbwrapper/DummyPlayer at misson20000.plugins.cbwrapper.CBWrapper.onCommand(CBWrapper.java:117) [?:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) [PluginCommand.class:git-Cauldron-MCPC-Plus-1.7.10-1.1236.06.212] ... 8 more
Seems to have been cut off. I'm not 100% sure what's going on here, but here's what I think is happening: Somewhere, misson20000.plugins.cbwrapper.DummyPlayer isn't implementing everything that Cauldron wants it to implement. Cauldron might be adding some more methods to the org.bukkit.Player class, which would be a problem. Because Java doesn't like this, it doesn't accept that class definition, leading to the java.lang.NoClassDefFoundError.
If that is indeed the case, it should be a pretty simple fix once I get around to it. If Cauldron changes a bunch of internal stuff, I might not be able to implement it for Cauldron.
If there's any more of the error, that would be extremely helpful. Also, are you running CBWrapper for 1.7? The logs say "Cauldron-MCPC-Plus-1.7.10" which seems to indicate that you're running 1.7.10. If you're running a CBWrapper that isn't for 1.7.10, that'd be your problem.