Example multiworld plugin

Discussion in 'Plugin Development' started by Dinnerbone, Feb 7, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Dinnerbone Bukkit Team Member

    I wrote a NetherBone plugin quickly last night to demonstrate multiworld functionality, and a few people have been after the source.

    Well, here it is! www.dinnerbone.com/netherbone.zip

    An important thing that I see a lot of people not paying attention to: You should always check if you already have a world by the name or type or whatever that you're about to create. If you create a world which already exists in memory, it'll be loaded up twice. I do this by just checking if we have a nether and a normal world and assigning that as my nether/normal variable.
     
  2. Offline

    Kane

    Thanks.
     
  3. Offline

    Redecouverte

    why don't you catch this case in bukkit?
     
  4. Offline

    Dinnerbone Bukkit Team Member

    We will.
     
  5. Offline

    NathanWolf

    Thanks, @DinnerBone- I've been wondering where to find this- I really wanted to take a look, make sure I'm not missing anything or doing anything dumb in NetherGate.

    Also, not to threadjack- but NetherGate source is available on github, if you want to look- I'd imagine DinnerBone's code is a better example, though. If you do go look, most of the actual world management stuff is in the Persistence plugin, mainly the PluginUtilities class.
    --- merged: Feb 8, 2011 2:19 PM ---
    Ok, since I already threadjacked- Persistence now supports multi-world in a nice, clean, easy way.

    It manages worlds for you, so you don't have to worry about double-registering (I think DinnerBone may have fixed that internally already anyway, but still).

    And then, of course, managed worlds are persisted as data- check out the built-in WorldData class, and the functions in PluginUtilities to get or create worlds.

    This is useful and important for existing Persistence devs, who can now reference a WorldData and BlockVector to persist a unique location.
     
  6. Offline

    DrewHiggins

    Awesome! Getting some chink issues with mobs, but I'll let it slide since this plugin was made on the fly.

    You guys are doing an AMAZING job! [​IMG]
     
  7. Offline

    unkzdomain

    Nice! Is there a way to change the world generation algorithm before it creates the everything in the new world? I realize that is kinda advanced, but i have a cool idea I want to try out if it's possible...
     
  8. Offline

    Raphfrk

    You could wipe all the chunks that have already been created.

    - create world
    - scan directory to find which chunks were created
    - load those chunks and set them to all zeroes or whatever you plan to have
     
  9. Offline

    JoeMaximum

    How can you load an already created world?
    Just created a "JoeWorld". Stopped the server. Restarted the server.
    Now if i use :

    Code:
    plugin.getServer().getWorld("JoeWorld");


    This return me a null value ... am in doing something wrong?

    Ok, so i just need to verify if its in memory, if not, then creating it will load it in memory if the world already exist ohterwise it will create a new.

    [​IMG]
     
  10. Offline

    DREAD_XI

    How can I use dinnerbone to say type in a command followed by the name of the world folder. I just want to be able to load my different worlds and the worlds my friends have sent. Final plan is to have a build world for guest and then other worlds for different levels of Builders/Clan members. Group spawn can be on one world and they can have permissions and on other worlds evan if there brought over they cannot alter unless given the permission. Oh we want this soooo much!!! Well thank you to anyone that can help or maby just write a simple plugin with the option to run a command followed by nether/normal and then the name of the world folder. We need this sooo bad.... TY
    --- merged: Feb 9, 2011 6:43 PM ---
    Nethergate is actually working great for me now. :D
     
  11. Offline

    unkzdomain

    I basically want to create a "MoonMod" that would just replace the dirt and grass with sponges (and eventually try reducing the gravity and adding extra mobs if possible), but deleting all the created chunks won't make the ones created afterwards automatically have the sponges instead of dirt... is there another way or am I stuck?
     
  12. Offline

    Raphfrk

    There is a ChunkLoadEvent.


    If a new chunk is loaded, then you would have to scan it. Better would be to maintain a list of the (world,x,z) of all chunks that have already been scanned. You only need to process them once.

    However, what you really want is a chunk generated event.
     
  13. Offline

    xZise

    Hello, how I can identify a world? I'm working on my xWarp plugin and at the moment it will only warp within the players world although the warp was created in another. So how I can save in the database, in which world the warp was?

    Fabian
     
  14. Offline

    Drakia

    My method for saving the world was using its name. For saving, I would do player.getWorld().getName() and for teleporting back, I would use server.getWorld(name)
     
  15. Offline

    unkzdomain

    Yeah, I guess your method works fine. I'll probably try to just make it so that if there is a Chunk Generated event later, I can adapt without a whole lot of changes in my code.
     
  16. Offline

    xZise

    Jep but both attributes (getId() and getName()) are documented as “don't has to be unique”. Or could I ignore the JavaDoc for this?

    Fabian
     
  17. Offline

    Drakia

    It's currently the only way I know to save a world reference for later use. Maybe they'll implement something better later?
     
  18. Offline

    unkzdomain

    Is it possible to make the time in one world separate from the time in the normal world? I would like to make it always night in my separate world...
    --- merged: Feb 12, 2011 8:11 PM ---
    Also, the Chunk class has a "getBlock(int x, int y, int z)" but no "setBlock(int x, int y, int z)"

    How am I supposed to CHANGE the Blocks once I get them and see if they need to be changed? Would just doing this change both the "block" variable AND the Block it corresponds to in the Chunk or would I need to somehow set the block back into the Chunk too?
     
  19. Offline

    xZise

    How can I get the “default” world? The world in which the player at beginning spawns?

    Fabian
     
Thread Status:
Not open for further replies.

Share This Page