remove usages of TerraWorld#getConfig

This commit is contained in:
dfsek
2021-07-22 13:59:39 -07:00
parent a56d1818c8
commit 8898bbd5c4
17 changed files with 23 additions and 70 deletions
@@ -100,8 +100,8 @@ public class TerraBukkitPlugin extends JavaPlugin implements TerraPlugin {
boolean succeed = registry.loadAll(this);
Map<World, TerraWorld> newMap = new HashMap<>();
worldMap.forEach((world, tw) -> {
tw.getConfig().getSamplerCache().clear();
String packID = tw.getConfig().getID();
world.getConfig().getSamplerCache().clear();
String packID = world.getConfig().getID();
newMap.put(world, new TerraWorldImpl(world, registry.get(packID), this));
});
worldMap.clear();
@@ -43,8 +43,7 @@ public class CommonListener implements Listener {
if(e.isCancelled()) return;
World bukkit = BukkitAdapter.adapt(e.getWorld());
if(!bukkit.isTerraWorld()) return;
TerraWorld tw = main.getWorld(bukkit);
WorldConfig c = tw.getConfig();
WorldConfig c = bukkit.getConfig();
if(c.isDisableSaplings()) return;
e.setCancelled(true);
Block block = e.getLocation().getBlock();
@@ -83,7 +83,7 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
public static final ConfiguredFeature<?, ?> POPULATOR_CONFIGURED_FEATURE = POPULATOR_FEATURE.configure(FeatureConfig.DEFAULT).decorate(Decorator.NOPE.configure(NopeDecoratorConfig.INSTANCE));
private static TerraFabricPlugin instance;
private final org.apache.logging.log4j.Logger log4jLogger = LogManager.getLogger();
private final Map<DimensionType, Pair<ServerWorld, TerraWorld>> worldMap = new HashMap<>();
private final Map<DimensionType, ServerWorld> worldMap = new HashMap<>();
private final EventManager eventManager = new EventManagerImpl(this);
private final GenericLoaders genericLoaders = new GenericLoaders(this);
private final Profiler profiler = new ProfilerImpl();
@@ -119,7 +119,7 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
return instance;
}
public Map<DimensionType, Pair<ServerWorld, TerraWorld>> getWorldMap() {
public Map<DimensionType, ServerWorld> getWorldMap() {
return worldMap;
}
@@ -144,9 +144,7 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
}
public TerraWorld getWorld(DimensionType type) {
TerraWorld world = worldMap.get(type).getRight();
if(world == null) throw new IllegalArgumentException("No world exists with dimension type " + type);
return world;
throw new IllegalArgumentException("No world exists with dimension type " + type);
}
@Override
@@ -188,10 +186,9 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
config.load(this);
LangUtil.load(config.getLanguage(), this); // Load language.
boolean succeed = configRegistry.loadAll(this);
worldMap.forEach((seed, pair) -> {
pair.getRight().getConfig().getSamplerCache().clear();
String packID = pair.getRight().getConfig().getID();
pair.setRight(new TerraWorldImpl(pair.getRight().getWorld(), configRegistry.get(packID), this));
worldMap.forEach((seed, world) -> {
if(!(world instanceof World)) return;
((World) world).getConfig().getSamplerCache().clear();
});
return succeed;
}