WorldPathConfig.java
package com.hypixel.hytale.server.core.universe.world.path;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.codecs.map.MapCodec;
import com.hypixel.hytale.codec.util.RawJsonReader;
import com.hypixel.hytale.event.IEventDispatcher;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.server.core.HytaleServer;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.util.BsonUtil;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.bson.BsonValue;
public class WorldPathConfig {
public static final BuilderCodec<WorldPathConfig> CODEC;
protected Map<String, WorldPath> paths = new ConcurrentHashMap();
public WorldPathConfig {
}
WorldPath {
(WorldPath).paths.get(name);
}
Map<String, WorldPath> {
Collections.unmodifiableMap(.paths);
}
WorldPath {
Objects.requireNonNull(worldPath);
IEventDispatcher<WorldPathChangedEvent, WorldPathChangedEvent> dispatcher = HytaleServer.get().getEventBus().dispatchFor(WorldPathChangedEvent.class);
(dispatcher.hasListener()) {
dispatcher.dispatch( (worldPath));
}
(WorldPath).paths.put(worldPath.getName(), worldPath);
}
WorldPath {
Objects.requireNonNull(path);
(WorldPath).paths.remove(path);
}
CompletableFuture<Void> {
CODEC.encode();
BsonUtil.writeDocument(world.getSavePath().resolve(), bsonValue.asDocument());
}
CompletableFuture<WorldPathConfig> {
world.getSavePath().resolve();
world.getSavePath().resolve();
(Files.exists(oldPath, []) && !Files.exists(path, [])) {
{
Files.move(oldPath, path);
} (IOException var4) {
}
}
CompletableFuture.supplyAsync(() -> {
(WorldPathConfig)RawJsonReader.readSyncWithBak(path, CODEC, HytaleLogger.getLogger());
config != ? config : ();
});
}
String {
+ String.valueOf(.paths) + ;
}
{
CODEC = ((BuilderCodec.Builder)BuilderCodec.builder(WorldPathConfig.class, WorldPathConfig::).addField( (, (WorldPath.CODEC, ConcurrentHashMap::, )), (config, paths) -> config.paths = paths, (config) -> config.paths)).build();
}
}