diff --git a/src/main/java/eu/m724/tweaks/TweaksPlugin.java b/src/main/java/eu/m724/tweaks/TweaksPlugin.java index 42975fc..e427283 100644 --- a/src/main/java/eu/m724/tweaks/TweaksPlugin.java +++ b/src/main/java/eu/m724/tweaks/TweaksPlugin.java @@ -58,6 +58,23 @@ public class TweaksPlugin extends MStatsPlugin { new Language(Locale.of(config.locale())); // TODO DebugLogger.fine(Language.getString("languageNotice", Language.getString("language"), Language.getString("languageEnglish"))); + var runningVersion = getServer().getBukkitVersion(); + var targetVersion = getTargetVersion(); + + if (!runningVersion.equals(targetVersion)) { + // the incompatibility can be between 1.21.4-R0.1-SNAPSHOT and 1.21.4-R1-SNAPSHOT + var runningMc = runningVersion.split("-")[0]; + var targetMc = targetVersion.split("-")[0]; + if (!runningMc.equals(targetMc)) { + targetVersion = targetMc; + runningVersion = runningMc; + } + + getLogger().warning("This plugin was built for %s. This server is running %s.".formatted(targetVersion, runningVersion)); + getLogger().warning("Some modules will not work. Disable those modules, or make a compatible build yourself:"); + getLogger().warning("https://git.m724.eu/Minecon724/tweaks724/src/branch/master/docs/BUILDING.md"); + } + /* start modules */ if (config.worldborderHide()) { @@ -141,6 +158,15 @@ public class TweaksPlugin extends MStatsPlugin { DebugLogger.fine("Took %.3f milliseconds".formatted((System.nanoTime() - start) / 1000000.0)); } + private String getTargetVersion() { + var permission = getServer().getPluginManager().getPermission("7weaks724.ignore.this"); + + var desc = permission.getDescription().substring("Internal, not for use. ".length()).split(","); + var version = desc[0]; + + return version; + } + public boolean hasResource(String resource) { return this.getClassLoader().getResource(resource) != null; } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index fac4b46..7882556 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -42,6 +42,9 @@ commands: permission: tweaks724.servkill permissions: + 7weaks724.ignore.this: + description: "Internal, not for use. ${project.spigot.version}" + default: false tweaks724: chatmanage: default: true