How to run save world command?

Discussion in 'Plugin Development' started by Gigi10012, May 4, 2013.

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

    Gigi10012

    I want to save world when i rightclick sign
    Code:
        @EventHandler
        public void onPlayerInteract(PlayerInteractEvent e){
            if(e.getAction() == Action.RIGHT_CLICK_BLOCK)
            {
                if(e.getClickedBlock().getState() instanceof Sign)
                {
                    Sign s = (Sign) e.getClickedBlock().getState();
                    if(s.getLine(0).equalsIgnoreCase("[Save]"))
                    {
                        //Code to save World
                    {
                }
              }
    How to do that?
     
  2. Offline

    LucasEmanuel

    How about world.save() ?
     
  3. Offline

    Gigi10012

    What variable is world?

    Code:
    org.bukkit.World world = //What to write here?
    world.save();
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016
  4. Offline

    iZanax

  5. Offline

    justcool393

    Do you want to save all the worlds (or just a specific world)?
     
  6. Offline

    skipperguy12

    Gigi10012
    To save all (LOADED) worlds:
    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "save-all");

    To save the players world:
    e.getPlayer().getWorld().save();
     
  7. Offline

    Gigi10012

    thanks
     
  8. Offline

    Quaro

    Code:java
    1.  
    2. for(World worlds: Bukkit.getWorlds()) {
    3. worlds.save()
    4. }
    5.  
     
    MCMastery likes this.
Thread Status:
Not open for further replies.

Share This Page