Help: Dynamically Switch worlds

Discussion in 'Plugin Development' started by Frazz86, Dec 28, 2012.

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

    Frazz86

    What I am looking for is, when an OP types /next, it will move to the next map (World).

    The worlds will be in a YML list i've already got, so it would select the next one in the order of the maps.

    The maps would be like:
    Map 1
    Map 2
    Map 3 (Currently being played, this is the current world).
    Map 4

    When the op types /next, it would switch to map 4, then /next again would set it to map 1.

    When it sets to the next map it should teleport the players to that maps spawn.

    So, i know this is possible; just i am not sure where to start with this:).
     
  2. Offline

    fireblast709

    start with creating a new project :p... Then create a onEnable(), maybe a default config, a onCommand(), a check which world you are in, a check what the next world is, and a teleport
     
    RainoBoy97 likes this.
  3. Offline

    Bench3

    How much Bukkit development knowledge do you have?
     
  4. Offline

    fireblast709

  5. Offline

    Frazz86

    fireblast709
    How can i use the TP, or with the bukkit API can you tp players to different worlds?

    Bench3 2 months worth, but i'd count myself as fairly knowledgable.

    Thanks for the replies guys :).
     
  6. Offline

    fireblast709

    Frazz86 yes, you teleport to a Location object. And in that object you can set whatever world you want to set it to
     
  7. Offline

    Frazz86

    Woah, ill give that a whirl! Thanks a lot! :).

    fireblast709 and to bug you again
    Code:
    Location loc1 = new Location(plugin.getServer().getWorld("world2"), 1,1,1);
    
    Would set that location as a world named "world2" correct?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  8. Offline

    jbman223

    Frazz86 yeah you are doing it right.
     
  9. Offline

    Frazz86

    jbman223 , fireblast709


    What am i doing wrong?

    It keeps returning the "ctm was not found", i assume its because the world is not loaded, how do i load a world? Or what am i actually supposed to do here xD :p.
    Code:
    package com.mcvigor.mcvigor.command;
     
    import org.bukkit.GameMode;
    import org.bukkit.Location;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
     
    import com.mcvigor.mcvigor.MCVigor;
     
     
    public class NextCommand implements CommandExecutor{
    private MCVigor plugin;
     
    public NextCommand(MCVigor plugin){
    this.plugin = plugin;
    }
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    Player p = (Player) sender;
    if(sender.isOp())
    {
    if(p.getWorld() != null)
    {
    if(plugin.getServer().getWorld("ctm") != null)
    {
    Location loc1 = new Location(plugin.getServer().getWorld("ctm"), 1,1,1);
    p.teleport(loc1);
    p.setGameMode(GameMode.CREATIVE);
    }
    else
    {
    plugin.getLogger().info("World, ctm, not found.");
    }
    }
    else
    {
    plugin.getLogger().info("p.getWorld() returned null"); 
    }
    }
    return false;
    }
    }
    
     
  10. Offline

    fireblast709

    Bukkit.createWorld(new WorldCreator("Your world name here"));
    This will create a new world, or load it if it already exists
     
Thread Status:
Not open for further replies.

Share This Page