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

problem ..... of my Plugin !!

Comments in 'Plugin Development' started by Ritch, Mar 3, 2016.

  1. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    Problem : Level "test" not found
    PHP:
             $this->cfg $this->getConfig();
            
    $name $this->cfg->get("reset_map");
               if (!
    $this->getServer()->getLevelByName($name) instanceof Level) {
                    
    $this->deleteDirectory($this->getServer()->getDataPath() . "/worlds/" $name);
                    
    $this->copymap($this->getDataFolder() . "/maps/" $name$this->getServer()->getDataPath() . "/worlds/" $name);
                    
    $this->getServer()->loadLevel($name);
                } else {
                    
    $this->getServer()->unloadLevel($this->getServer()->getLevelByName($name));
                    
    $this->deleteDirectory($this->getServer()->getDataPath() . "/worlds/" $name);
                    
    $this->copymap($this->getDataFolder() . "/maps/" $name$this->getServer()->getDataPath() . "/worlds/" $name);
                    
    $this->getServer()->loadLevel($name);
    PHP:
               public function copymap($src$dst) {
            
    $dir opendir($src);
            @
    mkdir($dst);
            while (
    false !== ( $file readdir($dir))) {
                if (( 
    $file != '.' ) && ( $file != '..' )) {
                    if (
    is_dir($src '/' $file)) {
                        
    $this->copymap($src '/' $file$dst '/' $file);
                    } else {
                        
    copy($src '/' $file$dst '/' $file);
                    }
                }
            }
            
    closedir($dir);
        }

        public function 
    deleteDirectory($dirPath) {
            if (
    is_dir($dirPath)) {
                
    $objects scandir($dirPath);
                foreach (
    $objects as $object) {
                    if (
    $object != "." && $object != "..") {
                        if (
    filetype($dirPath DIRECTORY_SEPARATOR $object) == "dir") {
                            
    $this->deleteDirectory($dirPath DIRECTORY_SEPARATOR $object);
                        } else {
                            
    unlink($dirPath DIRECTORY_SEPARATOR $object);
                        }
                    }
                }
                
    reset($objects);
                
    rmdir($dirPath);
            }
        }
    }
  2. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    You're sure that your level name is "test"? Remember that it needs to be the name inside level.dat, not the folder name.
    applqpak likes this.
  3. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    I know ... I use manyworld ...Level not found "test" the World it work ??? Problem with reset Map .....
  4. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    I think that the problem is that you delete the map before copy it. You can't copy a map that doesn't exists...
    applqpak likes this.
  5. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    So he should delete his backup? Great idea!
  6. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Well, I'll tell you an history.

    [​IMG]

    Can you understand me?
    applqpak likes this.
  7. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Really?!.... You mean he should copy his map for no reason and then delete it?
  8. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    No. :/
    I said it because he's deleting the map with no reason.
    Last edited: Mar 5, 2016
    applqpak likes this.
  9. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    For your solution not work create world ect.... = Level "not found" :)
  10. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
  11. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Lol, I didn't understand that at all xD
    applqpak likes this.
  12. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    please look Google translate and go spanish - English For you :D
  13. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Maybe you're who need translate that from your language to english...
  14. TheDeibo
    Offline

    TheDeibo Notable Member

    Joined:
    Sep 8, 2014
    Posts:
    693
    Minecraft User:
    TheDeibo
    if you send is your worlds in a zip folder, I may be able to see if they is any problems.

    (Edit: fixed shameful typos)
    Last edited: Mar 6, 2016
    Ritch likes this.
  15. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    Please stop spam ..
  16. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    As I know I gave you the code right, so I should know how it works, because it's working for me, you need to store a folder called "maps" in plugins/<YourPluginDataFolder>, it must have the same name as your world you want to delete as I see.
    Ritch likes this.

Share This Page

Advertisement