Add version notice
This commit is contained in:
		
					parent
					
						
							
								6e0d7e5a40
							
						
					
				
			
			
				commit
				
					
						832a5edccc
					
				
			
		
					 2 changed files with 29 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -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;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue