Search in sources :

Example 1 with SinglePlotAreaManager

use of com.plotsquared.core.plot.world.SinglePlotAreaManager in project PlotSquared by IntellectualSites.

the class SingleWorldListener method handle.

private void handle(ChunkEvent event) {
    World world = event.getWorld();
    String name = world.getName();
    PlotAreaManager man = PlotSquared.get().getPlotAreaManager();
    if (!(man instanceof SinglePlotAreaManager)) {
        return;
    }
    if (!SinglePlotArea.isSinglePlotWorld(name)) {
        return;
    }
    markChunkAsClean(event.getChunk());
}
Also used : PlotAreaManager(com.plotsquared.core.plot.world.PlotAreaManager) SinglePlotAreaManager(com.plotsquared.core.plot.world.SinglePlotAreaManager) SinglePlotAreaManager(com.plotsquared.core.plot.world.SinglePlotAreaManager) World(org.bukkit.World)

Example 2 with SinglePlotAreaManager

use of com.plotsquared.core.plot.world.SinglePlotAreaManager in project PlotSquared by IntellectualSites.

the class DebugImportWorlds method execute.

@Override
public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
    // UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8))
    if (!(this.plotAreaManager instanceof SinglePlotAreaManager)) {
        player.sendMessage(TranslatableCaption.of("debugimportworlds.single_plot_area"));
        return CompletableFuture.completedFuture(false);
    }
    SinglePlotArea area = ((SinglePlotAreaManager) this.plotAreaManager).getArea();
    PlotId id = PlotId.of(0, 0);
    File container = PlotSquared.platform().worldContainer();
    if (container.equals(new File("."))) {
        player.sendMessage(TranslatableCaption.of("debugimportworlds.world_container"));
        return CompletableFuture.completedFuture(false);
    }
    for (File folder : container.listFiles()) {
        String name = folder.getName();
        if (!this.worldUtil.isWorld(name) && PlotId.fromStringOrNull(name) == null) {
            UUID uuid;
            if (name.length() > 16) {
                uuid = UUID.fromString(name);
            } else {
                player.sendMessage(TranslatableCaption.of("players.fetching_player"));
                uuid = PlotSquared.get().getImpromptuUUIDPipeline().getSingle(name, 60000L);
            }
            if (uuid == null) {
                uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8));
            }
            while (new File(container, id.toCommaSeparatedString()).exists()) {
                id = id.getNextId();
            }
            File newDir = new File(container, id.toCommaSeparatedString());
            if (folder.renameTo(newDir)) {
                area.getPlot(id).setOwner(uuid);
            }
        }
    }
    player.sendMessage(TranslatableCaption.of("players.done"));
    return CompletableFuture.completedFuture(true);
}
Also used : SinglePlotArea(com.plotsquared.core.plot.world.SinglePlotArea) PlotId(com.plotsquared.core.plot.PlotId) SinglePlotAreaManager(com.plotsquared.core.plot.world.SinglePlotAreaManager) UUID(java.util.UUID) File(java.io.File)

Aggregations

SinglePlotAreaManager (com.plotsquared.core.plot.world.SinglePlotAreaManager)2 PlotId (com.plotsquared.core.plot.PlotId)1 PlotAreaManager (com.plotsquared.core.plot.world.PlotAreaManager)1 SinglePlotArea (com.plotsquared.core.plot.world.SinglePlotArea)1 File (java.io.File)1 UUID (java.util.UUID)1 World (org.bukkit.World)1