World that gets regenerated after x seconds

Discussion in 'Archived: Plugin Requests' started by 123isme1, Aug 19, 2014.

  1. Offline

    123isme1

    Hey all,
    Just want a plugin that will delete and regenerate world(s) after a set amount of time (not using same seed). If it uses mv that is fine.
    Example config:
    Code:
    #The world that will get deleted and regenerated
    world: survivalworld
     
    #seed, optional
    seed:
     
    #generator, optional (otherwise will use minecraft world generator)
    generator:
     
    #time between deletings
    time: 600
     
    #world to tp all players in the deleted world
    tp-world: spawn
    I would probably make it myself, but I am busy with a big plugin project/redoing a server :/
     
  2. Online

    timtower Administrator Administrator Moderator

    123isme1 That would be pretty server intensive to load, run for 5 minutes, unload, delete and make a new one.
    Why do you want this?
     
  3. Offline

    123isme1

    timtower
    For the style of server I want to do, players gather materials in this world, build in the plotworld, and this world is constantly being 'refreshed', sortof like a prison server.
     
  4. Online

    timtower Administrator Administrator Moderator

    Then I would advice a daily reset, not based on minutes.
     
  5. Offline

    123isme1

    Last edited by a moderator: Jun 9, 2016
  6. Online

    timtower Administrator Administrator Moderator

  7. Offline

    123isme1

    timtower this one suits my needs, your solution does not.
     
  8. Online

    timtower Administrator Administrator Moderator

    I never gave a solution.
     
    redsoxfan95 and Marten Mooij like this.
  9. Offline

    AngryCola

    I say have a limited amount of chunks in that world so it's not too laggy.

    You can even use command blocks for this, if you don't know how and want them, PM or tag me.

    You can set up the command blocks too look like a plugin with coloured chat and everything
     
  10. Offline

    Yekllurt

    Here is the class wich controlls the deleting, unloading and generating.
    Code:java
    1. package me.Yekllurt.Main;
    2.  
    3. import java.io.File;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.World;
    7. import org.bukkit.WorldCreator;
    8. import org.bukkit.WorldType;
    9. import org.bukkit.World.Environment;
    10.  
    11. public class ResetWorld {
    12.  
    13. private World world;
    14. private File file;
    15.  
    16. public ResetWorld(World w, File f){
    17. this.world = w;
    18. this.file = f;
    19. }
    20.  
    21. public void unloadWorld(){
    22. if(this.world == null){
    23. Bukkit.broadcastMessage("§4Failed unloading " + this.world.getName());
    24. }else{
    25. Bukkit.broadcastMessage("§6Unloading " + this.world.getName() + "");
    26. Bukkit.getServer().unloadWorld(this.world, true);
    27. Bukkit.broadcastMessage("§6Unloaded " + this.world.getName() + "");
    28. }
    29. }
    30.  
    31. public void loadWorld(){
    32. if(this.world == null){
    33. Bukkit.broadcastMessage("§4Failed loading " + this.world.getName());
    34. }else{
    35. Bukkit.broadcastMessage("§6Loading " + this.world.getName() + "");
    36. Bukkit.getServer().unloadWorld(this.world, false);
    37. Bukkit.broadcastMessage("§6Loaded " + this.world.getName() + "");
    38. }
    39. }
    40.  
    41. public void createWorld(String name, long seed, boolean useSeed, WorldType worldType, boolean useWorldType, Environment enviromment, boolean useEnviromment, String generator, boolean useGenerator, boolean generateStructure){
    42. String info = "";
    43. WorldCreator worldCreator = new WorldCreator(name); info = "§6Name: " + name;
    44. if(useSeed){
    45. worldCreator.seed(seed); info = info + " Seed: " + seed;
    46. }else{
    47. info = info + " Seed: random Seed";
    48. }
    49. if(useWorldType){
    50. worldCreator.type(worldType); info = info + " World Type: " + worldType.toString();
    51. }else{
    52. info = info + " World Type: normal";
    53. }
    54. if(useEnviromment){
    55. worldCreator.environment(enviromment); info = info + " Enviromment: " + enviromment.toString();
    56. }else{
    57. info = info + " Enviromment: normal";
    58. }
    59. if(useGenerator){
    60. worldCreator.generator(generator); info = info + " Generator: " + generator;
    61. }else{
    62. info = info + " Generator: standard";
    63. }
    64. if(generateStructure){
    65. worldCreator.generateStructures(true); info = info + " Generate Structure: true";
    66. }else{
    67. info = info + " Generate Structure: false";
    68. }
    69. Bukkit.broadcastMessage("Creating world: " + name);
    70. Bukkit.broadcastMessage(info);
    71. worldCreator.createWorld();
    72. Bukkit.broadcastMessage("Created world: " + name);
    73. }
    74.  
    75. //delete world method by ThunderWaffeMc
    76. public boolean deleteWorld() {
    77. if(file.exists()) {
    78. File files[] = file.listFiles();
    79. for(int i=0; i<files.length; i++) {
    80. if(files[i].isDirectory()) {
    81. files[i].delete();
    82. } else {
    83. files[i].delete();
    84. }
    85. }
    86. }
    87. return(file.delete());
    88. }
    89.  
    90.  
    91.  
    92. }
    93. [/i][/i][/i]


    Here is the onEnable() part

    Code:java
    1. public void onEnable(){
    2. Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    3.  
    4. @Override
    5. public void run() {
    6.  
    7. String getResetTimeOutOfConfig = "06:00:00";
    8. DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
    9. Date date = new Date();
    10. String actualTime = dateFormat.format(date);
    11. if(actualTime == getResetTimeOutOfConfig){
    12. ResetWorld resetWorld = new ResetWorld(Bukkit.getWorld("world"));
    13. World w = Bukkit.getWorld("world");
    14. World otherWorld = Bukkit.getWorld("spawn");
    15. for(Player online : Bukkit.getOnlinePlayers()){
    16. if(online.getWorld() == w){
    17. online.teleport(otherWorld.getSpawnLocation());
    18. }
    19. }
    20. resetWorld.unloadWorld();
    21. resetWorld.deleteWorld();
    22. resetWorld.createWorld("NewWorld", 50, true, WorldType.NORMAL, true, Environment.NORMAL, true, "Generator", false, true);
    23. }
    24. }
    25. }, 0, 20 * 60 * 1);
    26. }


    If you compile that coorect it will check every minute for resting the world. If the server time equals the reset time it will reset
     

Share This Page