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

Reset level minigame

Comments in 'Plugin Development' started by MyNameIsTriXz, Sep 17, 2016.

  1. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    What method do you use to restore the level after a minigame was played? I am disappointed of my current one because it doesnt work properly... Can you show me yours?
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Which one do you use?
    Also, do you have everything in one world? Or is the world completely empty after the game?
    applqpak likes this.
  3. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Well no it wasnt reset. It mostly works, but sometimes I feel like it doesnt. I use the way where you delete and replace the folder.
  4. Ragnok1234
    Offline

    Ragnok1234 Active Member

    Joined:
    Jul 18, 2016
    Posts:
    53
    Minecraft User:
    Ragnok123
    Im using this:
    PHP:
     copy($this->getServer()->getDataPath().'copyworld/world/region/r.-1.0.mcr',$this->getServer()->getDataPath().'worlds/world/region/r.-1.0.mcr'); 
    MyNameIsTriXz likes this.
  5. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Looks simple, thanks!
  6. Ragnok1234
    Offline

    Ragnok1234 Active Member

    Joined:
    Jul 18, 2016
    Posts:
    53
    Minecraft User:
    Ragnok123
    Yeah, but dont forgot to make all .mcr files. It's copy only files, not repos.
  7. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    You're doing that one line for each mcr file???
    applqpak likes this.
  8. Ragnok1234
    Offline

    Ragnok1234 Active Member

    Joined:
    Jul 18, 2016
    Posts:
    53
    Minecraft User:
    Ragnok123
    Yes. Maximum i have 9-11 lines.
  9. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Why? Just copy the whole folder..
    applqpak likes this.
  10. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    You cannot copy the entire folder, you must copy recursively. copy() can only handle single files. I found a very good example demonstrating how you can achieve that on StackOverflow.
    applqpak likes this.
  11. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    I didn't tell him to copy the whole folder with copy(). I am using an own function as well in my old plugins.
    applqpak likes this.
  12. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Your post suggested otherwise. You should've said "recursively copy" instead of "copy the entire folder". @Ragnok1234 You shouldn't use the code you're using right now, because it's very inefficient. You should utilize loops and recursively copy the entire directory instead.
    applqpak likes this.
  13. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    "Copy" doesn't mean only specific files. I can copy the entire folder, and I can copy only one file. I never said anything about "copy the folder with your current code/copy()".
    applqpak likes this.
  14. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    I know. But since minigame levels use about 1 mcr file except on BedWars or SurvivalGames this method is useful.
  15. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Thats the way I use, but I think the problem is my minigame code which returns a "" as levelname :/ I am looking for a faster and easier function too. I have heard once that turning auto save off and reloading the level should reset it, is that true?
  16. Ragnok1234
    Offline

    Ragnok1234 Active Member

    Joined:
    Jul 18, 2016
    Posts:
    53
    Minecraft User:
    Ragnok123
    Sorry, but I think, way that i gived here is best and faster.
    MyNameIsTriXz likes this.
  17. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Wrong. Th fastest way is to setAutoSave(false), then unload and loading it.
    ImagicalGamer likes this.
  18. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Do you use it for your minigames?
  19. ImagicalGamer
    Offline

    ImagicalGamer Active Member

    Joined:
    Feb 25, 2016
    Posts:
    141
    Minecraft User:
    ImagicalGamer
    I use AsyncTasks + a zipping method You can view it here
    MyNameIsTriXz likes this.
  20. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    I used that method previously. It works, but is slower and it actually does lag the server, even if you don't feel it. setAutoSave does not.

Share This Page

Advertisement