9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2026-01-06 15:52:03 +00:00

修复低版本slimeworld兼容性

This commit is contained in:
XiaoMoMi
2025-11-16 00:33:10 +08:00
parent 13f1d96e34
commit 10796028af
7 changed files with 21 additions and 12 deletions

View File

@@ -70,6 +70,7 @@ public class BukkitCompatibilityManager implements CompatibilityManager {
@Override
public void onEnable() {
this.initSlimeWorldHook();
// WorldEdit
// FastAsyncWorldEdit
if (this.isPluginEnabled("FastAsyncWorldEdit")) {
@@ -110,7 +111,6 @@ public class BukkitCompatibilityManager implements CompatibilityManager {
@Override
public void onDelayedEnable() {
this.initSlimeWorldHook();
if (this.isPluginEnabled("PlaceholderAPI")) {
PlaceholderAPIUtils.registerExpansions(this.plugin);
this.hasPlaceholderAPI = true;
@@ -234,7 +234,7 @@ public class BukkitCompatibilityManager implements CompatibilityManager {
Bukkit.getPluginManager().registerEvents(adaptor, plugin.javaPlugin());
logHook("AdvancedSlimePaper");
} catch (ClassNotFoundException ignored) {
if (Bukkit.getPluginManager().isPluginEnabled("SlimeWorldPlugin")) {
if (hasPlugin("SlimeWorldPlugin")) {
LegacySlimeFormatStorageAdaptor adaptor = new LegacySlimeFormatStorageAdaptor(worldManager, 2);
worldManager.setStorageAdaptor(adaptor);
Bukkit.getPluginManager().registerEvents(adaptor, plugin.javaPlugin());

View File

@@ -72,6 +72,7 @@ paper {
register("LuckPerms") { required = false }
register("ViaVersion") { required = false }
register("QuickShop-Hikari") { required = false }
register("SlimeWorldPlugin") { required = false }
// external tag
register("CustomNameplates") { required = false }

View File

@@ -234,8 +234,12 @@ public class BukkitCraftEngine extends CraftEngine {
super.senderFactory = new BukkitSenderFactory(this);
// 初始化指令管理器
super.commandManager = new BukkitCommandManager(this);
try {
super.compatibilityManager().onEnable();
} catch (Throwable t) {
this.logger.severe("Failed to enable compatibility manager", t);
}
super.onPluginEnable();
super.compatibilityManager().onEnable();
}
@Override

View File

@@ -49,10 +49,6 @@ public class BukkitWorldManager implements WorldManager, Listener {
this.plugin = plugin;
this.worlds = ConcurrentUUID2ReferenceChainedHashTable.createWithCapacity(10, 0.5f);
this.storageAdaptor = new DefaultStorageAdaptor();
// fixme 初始化
for (World world : Bukkit.getWorlds()) {
this.worlds.put(world.getUID(), new BukkitCEWorld(new BukkitWorld(world), this.storageAdaptor));
}
}
@Override
@@ -77,6 +73,11 @@ public class BukkitWorldManager implements WorldManager, Listener {
if (world != null) {
this.lastWorldUUID = uuid;
this.lastWorld = world;
} else {
World bukkitWorld = Bukkit.getWorld(uuid);
if (bukkitWorld != null) {
world = this.loadWorld(new BukkitWorld(bukkitWorld));
}
}
return world;
}
@@ -139,9 +140,11 @@ public class BukkitWorldManager implements WorldManager, Listener {
}
@Override
public void loadWorld(net.momirealms.craftengine.core.world.World world) {
public CEWorld loadWorld(net.momirealms.craftengine.core.world.World world) {
UUID uuid = world.uuid();
if (this.worlds.containsKey(uuid)) return;
if (this.worlds.containsKey(uuid)) {
return this.worlds.get(uuid);
}
CEWorld ceWorld = new BukkitCEWorld(world, this.storageAdaptor);
this.worlds.put(uuid, ceWorld);
this.resetWorldArray();
@@ -150,6 +153,7 @@ public class BukkitWorldManager implements WorldManager, Listener {
handleChunkLoad(ceWorld, chunk, false);
}
ceWorld.setTicking(true);
return ceWorld;
}
@Override

View File

@@ -99,7 +99,7 @@ resource-pack:
fix-atlas: true
# Optimize your resource pack by reducing its size without any quality loss.
optimization:
enable: true
enable: false
# .png
texture:
enable: true

View File

@@ -1613,7 +1613,7 @@ public abstract class AbstractPackManager implements PackManager {
JsonObject textures = sourceModelJson.get("textures").getAsJsonObject();
for (Map.Entry<String, JsonElement> entry : textures.entrySet()) {
String value = entry.getValue().getAsString();
if (value.charAt(0) == '#') continue;
if (value.isEmpty() || value.charAt(0) == '#') continue;
Key textureResourceLocation = Key.from(value);
imageToModels.put(textureResourceLocation, sourceModelLocation);
}

View File

@@ -15,7 +15,7 @@ public interface WorldManager extends Manageable {
CEWorld[] getWorlds();
void loadWorld(World world);
CEWorld loadWorld(World world);
void loadWorld(CEWorld world);