Add core detection and scheduler adapters
This commit is contained in:
1 parent
f06ad804a5
commit
06a4e67e80
28 files changed
+1440
-2
No files matched your search
@@ -0,0 +1,45 @@
|
||||
package dev.itxiaohui.contentguard;
|
||||
|
||||
import dev.itxiaohui.contentguard.core.CompatibilityManager;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public final class ContentGuardPlugin extends JavaPlugin {
|
||||
private CompatibilityManager compatibility;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
try {
|
||||
compatibility = CompatibilityManager.initialize(this);
|
||||
} catch (IllegalStateException | LinkageError failure) {
|
||||
getLogger().log(Level.SEVERE, "兼容性检查失败,正在停用插件", failure);
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
getLogger().info(compatibility.info().summary());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (compatibility != null) {
|
||||
compatibility.close();
|
||||
getLogger().info("ICG_LIFECYCLE scheduler=closed");
|
||||
}
|
||||
}
|
||||
|
||||
public CompatibilityManager compatibility() {
|
||||
return Objects.requireNonNull(compatibility, "Compatibility manager is not initialized");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (args.length == 0 || (args.length == 1 && args[0].equalsIgnoreCase("info"))) {
|
||||
sender.sendMessage(compatibility().info().summary());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user