World Reset is not working

Discussion in 'Plugin Development' started by VNGC, Apr 8, 2020.

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

    VNGC

    Hey,
    i am trying to make a world reset with /reset, but the world still stays the same after i get kicked and rejoin.
    the Command is registered in the main, and in the yml as well.

    Code:
    public class Reset implements CommandExecutor {
    
    
    here is my part of the class:
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (sender instanceof Player) {
                if (args.length == 0) {
                    for (Player player : Bukkit.getServer().getOnlinePlayers()) {
                        player.getInventory().clear();
                        player.kickPlayer("Worlds are resetting!");
                        deleteWorld("world");
                        deleteWorld("world_nether");
                        deleteWorld("world_the_end");
                    }
                }
            }
    
            return false;
        }
    
        public void deleteWorld(String worldName) {
            Path pathToBeDeleted = Bukkit.getWorldContainer().toPath().resolve(worldName);
    
            try {
                Files.walk(pathToBeDeleted).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    
    }
     
  2. Online

    timtower Administrator Administrator Moderator

    @VNGC Did you unload the world first?
     
Thread Status:
Not open for further replies.

Share This Page