9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-27 10:59:07 +00:00

社区版

This commit is contained in:
XiaoMoMi
2025-04-12 21:44:07 +08:00
parent f5a45f38f9
commit 892a0d724c
2 changed files with 25 additions and 2 deletions

View File

@@ -59,7 +59,7 @@ artifacts {
tasks {
shadowJar {
archiveFileName = "${rootProject.name}-plugin-${rootProject.properties["project_version"]}.jar"
archiveFileName = "${rootProject.name}-plugin-${rootProject.properties["project_version"]}-community-edition.jar"
destinationDirectory.set(file("$rootDir/target"))
relocate("net.kyori", "net.momirealms.craftengine.libraries")
relocate("net.momirealms.sparrow.nbt", "net.momirealms.craftengine.libraries.nbt")

View File

@@ -1,8 +1,13 @@
package net.momirealms.craftengine.bukkit;
import net.momirealms.craftengine.bukkit.plugin.BukkitCraftEngine;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.Collection;
import java.util.concurrent.TimeUnit;
public class BukkitBootstrap extends JavaPlugin {
private final BukkitCraftEngine plugin;
@@ -12,16 +17,34 @@ public class BukkitBootstrap extends JavaPlugin {
@Override
public void onLoad() {
if (!Bukkit.getServer().getOnlineMode()) {
return;
}
this.plugin.onPluginLoad();
}
@Override
public void onEnable() {
this.plugin.onPluginEnable();
if (!Bukkit.getServer().getOnlineMode()) {
this.plugin.logger().warn("CraftEngine Community Edition requires online mode to be enabled.");
} else {
this.plugin.scheduler().asyncRepeating(() -> {
Collection<? extends Player> players = Bukkit.getOnlinePlayers();
if (players.size() > 20) {
this.plugin.logger().warn("CraftEngine Community Edition restricts servers to a maximum of 20 concurrent players.");
this.plugin.logger().warn("Your server has exceeded this limit and will be shut down.");
Bukkit.shutdown();
}
}, 1, 1, TimeUnit.MINUTES);
this.plugin.onPluginEnable();
}
}
@Override
public void onDisable() {
if (!Bukkit.getServer().getOnlineMode()) {
return;
}
this.plugin.onPluginDisable();
}
}