Improve integration and migration logging
This commit is contained in:
@@ -172,6 +172,16 @@ Imported original plugins/MagicGem into MagicGem-Reforged: X files copied, Y con
|
|||||||
MagicGem Reforged 已启用,命令 /mgem,加载 N 颗宝石。
|
MagicGem Reforged 已启用,命令 /mgem,加载 N 颗宝石。
|
||||||
```
|
```
|
||||||
|
|
||||||
|
插件还会逐项记录可选挂钩插件的状态,例如:
|
||||||
|
|
||||||
|
```text
|
||||||
|
Optional integration PlaceholderAPI: enabled (version 2.x, api=available)
|
||||||
|
Optional integration MMOItems: absent
|
||||||
|
Optional integration MythicMobs: enabled (version 5.x, adapter=items=..., skillApi=true)
|
||||||
|
```
|
||||||
|
|
||||||
|
迁移器也会记录开始、未找到 `plugins/MagicGem`、已完成标记跳过和迁移失败等状态。
|
||||||
|
|
||||||
然后执行:
|
然后执行:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import cn.infstar.magicgem.skill.SkillEngine;
|
|||||||
import cn.infstar.magicgem.util.MessageDispatcher;
|
import cn.infstar.magicgem.util.MessageDispatcher;
|
||||||
import de.tr7zw.changeme.nbtapi.NBT;
|
import de.tr7zw.changeme.nbtapi.NBT;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -90,13 +91,39 @@ public class MagicGemPlugin extends JavaPlugin {
|
|||||||
getServer().getPluginManager().registerEvents(gemBrowser, this);
|
getServer().getPluginManager().registerEvents(gemBrowser, this);
|
||||||
getServer().getPluginManager().registerEvents(guiManager, this);
|
getServer().getPluginManager().registerEvents(guiManager, this);
|
||||||
getServer().getPluginManager().registerEvents(skillEngine, this);
|
getServer().getPluginManager().registerEvents(skillEngine, this);
|
||||||
getLogger().info("Integrations: Vault=" + economy.status()
|
logIntegrationStatus();
|
||||||
+ ", PlayerPoints=" + points.status()
|
|
||||||
+ ", PlaceholderAPI=" + placeholders.status()
|
|
||||||
+ ", MythicMobs=" + mythic.status());
|
|
||||||
getLogger().info("MagicGem Reforged 已启用,命令 /mgem,加载 " + gemRegistry.all().size() + " 颗宝石。");
|
getLogger().info("MagicGem Reforged 已启用,命令 /mgem,加载 " + gemRegistry.all().size() + " 颗宝石。");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void logIntegrationStatus() {
|
||||||
|
logOptionalPlugin("PlaceholderAPI", "api=" + (placeholders.available() ? "available" : "unavailable"));
|
||||||
|
logOptionalPlugin("Vault", "economy=" + (economy.available() ? "available" : "unavailable"));
|
||||||
|
logOptionalPlugin("PlayerPoints", "api=" + (points.available() ? "available" : "unavailable"));
|
||||||
|
logOptionalPlugin("MythicMobs", "adapter=" + mythic.status());
|
||||||
|
logOptionalPlugin("MMOItems", null);
|
||||||
|
logOptionalPlugin("MythicArtifacts", null);
|
||||||
|
logOptionalPlugin("MythicCrucible", null);
|
||||||
|
logOptionalPlugin("Residence", null);
|
||||||
|
logOptionalPlugin("PvPManager", null);
|
||||||
|
logOptionalPlugin("EcoEnchants", null);
|
||||||
|
logOptionalPlugin("GoldenEnchants", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void logOptionalPlugin(String name, String adapterStatus) {
|
||||||
|
Plugin dependency = getServer().getPluginManager().getPlugin(name);
|
||||||
|
if (dependency == null) {
|
||||||
|
getLogger().info("Optional integration " + name + ": absent");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String version = dependency.getDescription().getVersion();
|
||||||
|
if (!dependency.isEnabled()) {
|
||||||
|
getLogger().warning("Optional integration " + name + ": present but disabled (version " + version + ")");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String suffix = adapterStatus == null ? "" : ", " + adapterStatus;
|
||||||
|
getLogger().info("Optional integration " + name + ": enabled (version " + version + suffix + ")");
|
||||||
|
}
|
||||||
|
|
||||||
public void reloadAll() {
|
public void reloadAll() {
|
||||||
reloadScope("all");
|
reloadScope("all");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,17 +36,27 @@ public final class LegacyDirectoryImporter {
|
|||||||
|
|
||||||
public ImportResult importIfPresent() {
|
public ImportResult importIfPresent() {
|
||||||
Path sourceDirectory = pluginsDirectory.resolve(LEGACY_PLUGIN_DIRECTORY).normalize();
|
Path sourceDirectory = pluginsDirectory.resolve(LEGACY_PLUGIN_DIRECTORY).normalize();
|
||||||
if (targetDirectory.equals(sourceDirectory) || !Files.isDirectory(sourceDirectory)) {
|
if (targetDirectory.equals(sourceDirectory)) {
|
||||||
|
logger.info("MagicGem migration skipped because the legacy source and target directories are identical: "
|
||||||
|
+ sourceDirectory);
|
||||||
|
return ImportResult.none();
|
||||||
|
}
|
||||||
|
if (!Files.isDirectory(sourceDirectory)) {
|
||||||
|
logger.info("MagicGem migration source not found at " + sourceDirectory + "; no legacy import is needed.");
|
||||||
return ImportResult.none();
|
return ImportResult.none();
|
||||||
}
|
}
|
||||||
|
|
||||||
Path marker = targetDirectory.resolve(MARKER);
|
Path marker = targetDirectory.resolve(MARKER);
|
||||||
if (Files.exists(marker)) return new ImportResult(0, 0, true);
|
if (Files.exists(marker)) {
|
||||||
|
logger.info("MagicGem migration already completed; skipping legacy import (marker: " + marker + ").");
|
||||||
|
return new ImportResult(0, 0, true);
|
||||||
|
}
|
||||||
|
|
||||||
int copiedFiles = 0;
|
int copiedFiles = 0;
|
||||||
int conflictFiles = 0;
|
int conflictFiles = 0;
|
||||||
List<Conflict> conflicts = new ArrayList<>();
|
List<Conflict> conflicts = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
|
logger.info("Starting MagicGem migration: source=" + sourceDirectory + ", target=" + targetDirectory);
|
||||||
Files.createDirectories(targetDirectory);
|
Files.createDirectories(targetDirectory);
|
||||||
for (String directory : DATA_DIRECTORIES) {
|
for (String directory : DATA_DIRECTORIES) {
|
||||||
ImportCounts counts = importDirectory(sourceDirectory.resolve(directory),
|
ImportCounts counts = importDirectory(sourceDirectory.resolve(directory),
|
||||||
|
|||||||
Reference in New Issue
Block a user