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