mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-21 16:09:26 +00:00
增强访问权限管理
This commit is contained in:
@@ -9,7 +9,6 @@ public class BukkitCraftEnginePlugin extends JavaPlugin {
|
||||
this.plugin = new BukkitCraftEngine(this);
|
||||
this.plugin.applyDependencies();
|
||||
this.plugin.setUpConfig();
|
||||
this.plugin.injectRegistries();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.momirealms.craftengine.bukkit.plugin.classpath.PaperClassPathAppender
|
||||
import net.momirealms.craftengine.core.plugin.logger.PluginLogger;
|
||||
import net.momirealms.craftengine.core.plugin.logger.Slf4jPluginLogger;
|
||||
import net.momirealms.craftengine.core.util.ReflectionUtils;
|
||||
import net.momirealms.craftengine.core.util.VersionHelper;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -44,13 +45,15 @@ public class PaperCraftEngineBootstrap implements PluginBootstrap {
|
||||
);
|
||||
this.plugin.applyDependencies();
|
||||
this.plugin.setUpConfig();
|
||||
context.getLifecycleManager().registerEventHandler(LifecycleEvents.DATAPACK_DISCOVERY, (e) -> {
|
||||
try {
|
||||
this.plugin.injectRegistries();
|
||||
} catch (Throwable ex) {
|
||||
logger.warn("Failed to inject registries", ex);
|
||||
}
|
||||
});
|
||||
if (VersionHelper.isOrAbove1_21_4()) {
|
||||
context.getLifecycleManager().registerEventHandler(LifecycleEvents.DATAPACK_DISCOVERY, (e) -> {
|
||||
try {
|
||||
this.plugin.injectRegistries();
|
||||
} catch (Throwable ex) {
|
||||
logger.warn("Failed to inject registries", ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -91,8 +91,10 @@ public class BukkitBlockManager extends AbstractBlockManager {
|
||||
this.blockParser = new BlockParser();
|
||||
this.initVanillaRegistry();
|
||||
this.loadMappingsAndAdditionalBlocks();
|
||||
this.registerBlocks();
|
||||
this.registerEmptyBlock();
|
||||
if (!plugin.requiresRestart()) {
|
||||
this.registerBlocks();
|
||||
this.registerEmptyBlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -718,7 +720,7 @@ public class BukkitBlockManager extends AbstractBlockManager {
|
||||
Object blockHolder;
|
||||
Object resourceLocation = createResourceLocation(realBlockKey);
|
||||
|
||||
if (plugin.hasMod()) {
|
||||
if (this.plugin.hasMod()) {
|
||||
newRealBlock = CoreReflections.method$Registry$get.invoke(MBuiltInRegistries.BLOCK, resourceLocation);
|
||||
newBlockState = getOnlyBlockState(newRealBlock);
|
||||
|
||||
@@ -729,7 +731,7 @@ public class BukkitBlockManager extends AbstractBlockManager {
|
||||
try {
|
||||
newRealBlock = BlockGenerator.generateBlock(clientSideBlockType, clientSideBlock, blockProperties);
|
||||
} catch (Throwable throwable) {
|
||||
plugin.logger().warn("Failed to generate dynamic block class", throwable);
|
||||
this.plugin.logger().warn("Failed to generate dynamic block class", throwable);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,12 +74,12 @@ public class BukkitCraftEngine extends CraftEngine {
|
||||
private JavaPlugin javaPlugin;
|
||||
private final Path dataFolderPath;
|
||||
|
||||
public BukkitCraftEngine(JavaPlugin plugin) {
|
||||
protected BukkitCraftEngine(JavaPlugin plugin) {
|
||||
this(new JavaPluginLogger(plugin.getLogger()), plugin.getDataFolder().toPath().toAbsolutePath(), new ReflectionClassPathAppender(plugin.getClass().getClassLoader()));
|
||||
this.setJavaPlugin(plugin);
|
||||
}
|
||||
|
||||
public BukkitCraftEngine(PluginLogger logger, Path dataFolderPath, ClassPathAppender classPathAppender) {
|
||||
protected BukkitCraftEngine(PluginLogger logger, Path dataFolderPath, ClassPathAppender classPathAppender) {
|
||||
super((p) -> {
|
||||
CraftEngineReloadEvent event = new CraftEngineReloadEvent((BukkitCraftEngine) p);
|
||||
EventUtils.fireAndForget(event);
|
||||
@@ -128,6 +128,10 @@ public class BukkitCraftEngine extends CraftEngine {
|
||||
|
||||
@Override
|
||||
public void onPluginLoad() {
|
||||
if (super.blockManager == null) {
|
||||
injectRegistries();
|
||||
}
|
||||
if (this.requiresRestart) return;
|
||||
try {
|
||||
WorldStorageInjector.init();
|
||||
} catch (Exception e) {
|
||||
@@ -172,7 +176,7 @@ public class BukkitCraftEngine extends CraftEngine {
|
||||
return;
|
||||
}
|
||||
this.successfullyEnabled = true;
|
||||
if (this.hasMod && this.requiresRestart) {
|
||||
if (this.requiresRestart) {
|
||||
logger().warn(" ");
|
||||
logger().warn(" ");
|
||||
logger().warn(" ");
|
||||
|
||||
Reference in New Issue
Block a user