Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved auto-save=off/on by world?

Comments in 'Plugin Development' started by Praxthisnovcht, Nov 3, 2015.

  1. Praxthisnovcht
    Offline

    Praxthisnovcht Notable Member Plugin Developer

    Joined:
    Mar 10, 2014
    Posts:
    699
    Plugins:
    4
    Minecraft User:
    PraxHellTag
    hi much is in the title.

    I would svoir if it is possible to change the auto-save by the world?
  2. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    yes use LevelSaveEvent or event for that
    Praxthisnovcht likes this.
  3. Praxthisnovcht
    Offline

    Praxthisnovcht Notable Member Plugin Developer

    Joined:
    Mar 10, 2014
    Posts:
    699
    Plugins:
    4
    Minecraft User:
    PraxHellTag
    Thank you
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Note that the server.properties auto-save attribute also affects the saving of player data like coords, inventories.
  5. Praxthisnovcht
    Offline

    Praxthisnovcht Notable Member Plugin Developer

    Joined:
    Mar 10, 2014
    Posts:
    699
    Plugins:
    4
    Minecraft User:
    PraxHellTag
    it is better to use the method below, or it may just be enough to Unload-Load the world that does not save


    PHP:
        public function unload(Level $w$name) {

            
    $path $this->getConfig()->get("WorldsFilePath");
            
    $this->getServer()->unloadLevel($w);
            
    $files glob("../$path/worlds/$name/region"); // get all file names
            
    foreach ($files as $file) { // iterate files
                
    if (is_file($file))
                    
    unlink($file); // delete file
            
    }
            
    $this->recurse_copy("../$path/copys/$name""../$path/worlds/$name/region");
            
    $this->getServer()->getScheduler()->scheduleDelayedTask(new JTask([$this"load"], [$name]), 20);
            return 
    true;
        }

        public function 
    getAllWorlds() {

            
    $resule = [];
            foreach (
    scandir($this->getDataFolder()) as $file) {
                if (
    substr($file, -3) === "yml") {
                    
    $data = @yaml_parse(Config::fixYAMLIndexes(@file_get_contents($this->getDataFolder() . "data/" $file)));
                    if (isset(
    $data['ArenaWorld'])) {
                        
    $resule[] = $data;
                    }
                }
            }
            return 
    $resule;
        }

        public function 
    recurse_copy($src$dst) {

            
    $dir opendir($src);
            @
    mkdir($dst);
            while (
    false !== ($file readdir($dir))) {
                if ((
    $file != '.') && ($file != '..')) {
                    if (
    is_dir($src '/' $file)) {
                        
    recurse_copy($src '/' $file$dst '/' $file);
                    } else {
                        
    copy($src '/' $file$dst '/' $file);
                    }
                }
            }
            
    closedir($dir);
        }
        
    //Utils
        
    public function load($w) {

            
    $this->getServer()->loadLevel($w);
            return 
    true;
        }
    iDirtPlayzMC and DevWars like this.

Share This Page

Advertisement