Java Code Examples for org.bukkit.Bukkit#getWorldContainer()

The following examples show how to use org.bukkit.Bukkit#getWorldContainer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DResourceWorld.java    From DungeonsXL with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Generate a new DResourceWorld.
 *
 * @return the automatically created DEditWorld instance
 */
public DEditWorld generate() {
    int id = DInstanceWorld.counter;
    String name = DInstanceWorld.generateName(false, id);
    File folder = new File(Bukkit.getWorldContainer(), name);
    WorldCreator creator = new WorldCreator(name);
    creator.type(WorldType.FLAT);
    creator.generateStructures(false);

    DEditWorld editWorld = new DEditWorld(plugin, this, folder);
    this.editWorld = editWorld;

    EditWorldGenerateEvent event = new EditWorldGenerateEvent(editWorld);
    Bukkit.getPluginManager().callEvent(event);
    if (event.isCancelled()) {
        return null;
    }

    if (!RAW.exists()) {
        createRaw();
    }
    FileUtil.copyDir(RAW, folder, DungeonsXL.EXCLUDED_FILES);
    editWorld.generateIdFile();
    editWorld.world = creator.createWorld().getName();
    editWorld.generateIdFile();

    return editWorld;
}
 
Example 2
Source File: DResourceWorld.java    From DungeonsXL with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates the "raw" world that is copied for new instances.
 */
public static void createRaw() {
    WorldCreator rawCreator = WorldCreator.name(".raw");
    rawCreator.type(WorldType.FLAT);
    rawCreator.generateStructures(false);
    World world = rawCreator.createWorld();
    File worldFolder = new File(Bukkit.getWorldContainer(), ".raw");
    FileUtil.copyDir(worldFolder, RAW, DungeonsXL.EXCLUDED_FILES);
    Bukkit.unloadWorld(world, /* SPIGOT-5225 */ !Version.isAtLeast(Version.MC1_14_4));
    FileUtil.removeDir(worldFolder);
}
 
Example 3
Source File: ImportCommand.java    From DungeonsXL with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onExecute(String[] args, CommandSender sender) {
    File target = new File(DungeonsXL.MAPS, args[1]);
    File source = new File(Bukkit.getWorldContainer(), args[1]);

    if (!source.exists()) {
        MessageUtil.sendMessage(sender, DMessage.ERROR_NO_SUCH_MAP.getMessage(args[1]));
        return;
    }

    if (target.exists()) {
        MessageUtil.sendMessage(sender, DMessage.ERROR_NAME_IN_USE.getMessage(args[1]));
        return;
    }

    World world = Bukkit.getWorld(args[1]);
    if (world != null) {
        world.save();
    }

    MessageUtil.log(plugin, "&6Creating new map.");
    MessageUtil.log(plugin, "&6Importing world...");

    FileUtil.copyDir(source, target, "playerdata", "stats");

    DResourceWorld resource = new DResourceWorld(plugin, args[1]);
    plugin.getDungeonRegistry().add(args[1], new DDungeon(plugin, resource));
    if (world.getEnvironment() != Environment.NORMAL) {
        WorldConfig config = resource.getConfig(true);
        config.setWorldEnvironment(world.getEnvironment());
        config.save();
    }
    plugin.getMapRegistry().add(resource.getName(), resource);
    MessageUtil.sendMessage(sender, DMessage.CMD_IMPORT_SUCCESS.getMessage(args[1]));
}
 
Example 4
Source File: BukkitQueue_0.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public File getSaveFolder() {
    return new File(Bukkit.getWorldContainer(), getWorldName() + File.separator + "region");
}