use of com.plotsquared.core.plot.world.SinglePlotArea 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);
}
Aggregations