mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-30 20:39:10 +00:00
修复史莱姆世界兼容
This commit is contained in:
@@ -31,7 +31,7 @@ dependencies {
|
||||
// Placeholder
|
||||
compileOnly("me.clip:placeholderapi:${rootProject.properties["placeholder_api_version"]}")
|
||||
// SlimeWorld
|
||||
compileOnly("com.infernalsuite.asp:api:4.0.0-SNAPSHOT")
|
||||
compileOnly("com.infernalsuite.asp:api:4.2.0-SNAPSHOT")
|
||||
// ModelEngine
|
||||
compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.8")
|
||||
// BetterModel
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.momirealms.craftengine.bukkit.compatibility.legacy.slimeworld;
|
||||
import com.infernalsuite.aswm.api.events.LoadSlimeWorldEvent;
|
||||
import com.infernalsuite.aswm.api.world.SlimeWorld;
|
||||
import net.momirealms.craftengine.core.plugin.config.Config;
|
||||
import net.momirealms.craftengine.core.world.CEWorld;
|
||||
import net.momirealms.craftengine.core.world.World;
|
||||
import net.momirealms.craftengine.core.world.WorldManager;
|
||||
import net.momirealms.craftengine.core.world.chunk.storage.CachedStorage;
|
||||
@@ -24,8 +25,10 @@ public class LegacySlimeFormatStorageAdaptor extends DefaultStorageAdaptor imple
|
||||
@EventHandler
|
||||
public void onWorldLoad(LoadSlimeWorldEvent event) {
|
||||
org.bukkit.World world = Bukkit.getWorld(event.getSlimeWorld().getName());
|
||||
this.worldManager.loadWorld(this.worldManager.createWorld(this.worldManager.wrap(world),
|
||||
Config.enableChunkCache() ? new CachedStorage<>(new LegacySlimeWorldDataStorage(event.getSlimeWorld())) : new LegacySlimeWorldDataStorage(event.getSlimeWorld())));
|
||||
if (world == null) return;
|
||||
CEWorld ceWorld = this.worldManager.createWorld(this.worldManager.wrap(world),
|
||||
Config.enableChunkCache() ? new CachedStorage<>(new LegacySlimeWorldDataStorage(event.getSlimeWorld())) : new LegacySlimeWorldDataStorage(event.getSlimeWorld()));
|
||||
this.worldManager.loadWorld(ceWorld, true);
|
||||
}
|
||||
|
||||
public LegacySlimeFormatStorageAdaptor(WorldManager worldManager, int version) {
|
||||
|
||||
@@ -28,10 +28,7 @@ public class LegacySlimeWorldDataStorage implements WorldDataStorage {
|
||||
|
||||
@Override
|
||||
public CEChunk readNewChunkAt(CEWorld world, ChunkPos pos) {
|
||||
SlimeChunk slimeChunk = getWorld().getChunk(pos.x, pos.z);
|
||||
if (slimeChunk == null) return new CEChunk(world, pos);
|
||||
slimeChunk.getExtraData().getValue().remove("craftengine");
|
||||
return new CEChunk(world, pos);
|
||||
return readChunkAt(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,12 +5,14 @@ import com.infernalsuite.asp.api.events.LoadSlimeWorldEvent;
|
||||
import com.infernalsuite.asp.api.world.SlimeWorld;
|
||||
import net.momirealms.craftengine.core.plugin.config.Config;
|
||||
import net.momirealms.craftengine.core.util.ReflectionUtils;
|
||||
import net.momirealms.craftengine.core.world.CEWorld;
|
||||
import net.momirealms.craftengine.core.world.World;
|
||||
import net.momirealms.craftengine.core.world.WorldManager;
|
||||
import net.momirealms.craftengine.core.world.chunk.storage.CachedStorage;
|
||||
import net.momirealms.craftengine.core.world.chunk.storage.DefaultStorageAdaptor;
|
||||
import net.momirealms.craftengine.core.world.chunk.storage.WorldDataStorage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -26,8 +28,10 @@ public class SlimeFormatStorageAdaptor extends DefaultStorageAdaptor implements
|
||||
@EventHandler
|
||||
public void onWorldLoad(LoadSlimeWorldEvent event) {
|
||||
org.bukkit.World world = Bukkit.getWorld(event.getSlimeWorld().getName());
|
||||
this.worldManager.loadWorld(this.worldManager.createWorld(this.worldManager.wrap(world),
|
||||
Config.enableChunkCache() ? new CachedStorage<>(new SlimeWorldDataStorage(event.getSlimeWorld(), this)) : new SlimeWorldDataStorage(event.getSlimeWorld(), this)));
|
||||
if (world == null) return;
|
||||
CEWorld ceWorld = this.worldManager.createWorld(this.worldManager.wrap(world),
|
||||
Config.enableChunkCache() ? new CachedStorage<>(new SlimeWorldDataStorage(event.getSlimeWorld(), this)) : new SlimeWorldDataStorage(event.getSlimeWorld(), this));
|
||||
this.worldManager.loadWorld(ceWorld, true);
|
||||
}
|
||||
|
||||
public SlimeFormatStorageAdaptor(WorldManager worldManager) {
|
||||
|
||||
@@ -29,10 +29,7 @@ public class SlimeWorldDataStorage implements WorldDataStorage {
|
||||
|
||||
@Override
|
||||
public CEChunk readNewChunkAt(CEWorld world, ChunkPos pos) {
|
||||
SlimeChunk slimeChunk = getWorld().getChunk(pos.x, pos.z);
|
||||
if (slimeChunk == null) return new CEChunk(world, pos);
|
||||
slimeChunk.getExtraData().remove("craftengine");
|
||||
return new CEChunk(world, pos);
|
||||
return readChunkAt(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -187,9 +187,13 @@ public class BukkitWorldManager implements WorldManager, Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWorld(CEWorld world) {
|
||||
public void loadWorld(CEWorld world, boolean forceInit) {
|
||||
UUID uuid = world.world().uuid();
|
||||
if (this.worlds.containsKey(uuid)) return;
|
||||
if (this.worlds.containsKey(uuid)) {
|
||||
if (!forceInit) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.worlds.put(uuid, world);
|
||||
this.resetWorldArray();
|
||||
this.injectChunkGenerator(world);
|
||||
|
||||
Reference in New Issue
Block a user