Skip to content

SnLib v1.39.0

Choose a tag to compare

@ValentinTarnovsky ValentinTarnovsky released this 24 Sep 15:50
· 1 commit to main since this release

Changes

Command priority (SnSpec.Builder.commandPriority(), API level 26)

A plugin that is the core of its server mode can now declare that its commands win:

@Override
protected SnSpec buildSpec() {
    return SnSpec.builder()
            .config("config.yml")
            .lang()
            .commandPriority()
            .build();
}
  • Every root the plugin registers through sn.commands(), dynamic or declared in the plugin.yml, takes its bare name and each alias from another plugin's command, registered before or after it. /money runs the priority plugin's command while Essentials keeps answering as /essentials:money; namespaced keys are never taken.
  • One INFO per key and enable: Command '/money' of SnDungeons took the name from Essentials (command priority); Essentials still answers as /essentials:money (aliases: Alias '/bal' of '/money' in SnDungeons took the name from Essentials (command priority); Essentials still answers as /essentials:bal).
  • A command counts as another plugin's when that plugin provides its class: its plugin.yml command, or any Command/BukkitCommand it registers itself.
  • Never taken: a key of the same plugin, a namespaced plugin:key form, vanilla/Bukkit/Paper commands, commands registered through Paper's Brigadier API, commands.yml aliases, and a root of another plugin that declared priority too (whichever holds the key keeps it).
  • Given back: when the root unregisters (disable, or a reload that drops the root or the alias), the name returns to the command it was taken from (or to a plugin that enabled later and was refused it) if that plugin is still enabled, its command still answers as /<plugin>:<name> and nothing else took the name meanwhile. Nothing is given back while the server is stopping.
  • Taken back: a later plugin that overwrites an alias loses it again when it finishes enabling, when the server finishes loading and on every reload of the priority plugin.
  • Plugins without commandPriority() behave exactly as in 1.38.0.

Menu backups no longer load as menus

The old-<file>-<yyyyMMdd-HHmmss>.yml backups the config merge leaves in a menu folder (guis/ or a loadFolder folder) were loaded as ghost menus (old-... / <ns>:old-...). They are now skipped (one debug line each); a menu merely named old-town.yml or oldies.yml still loads. The pruning of those backups (its match unchanged) and the menu listers share one stamp regex.

Tests

15 new tests (667 total, all green). japicmp against 1.38.0: 2 NEW METHOD (SnSpec.commandPriority(), SnSpec.Builder.commandPriority()) and 1 NEW CONSTRUCTOR (SnCommands(Sn, SnLang, boolean, boolean)), nothing removed.

Installation

  1. Replace SnLib.jar in plugins/ with SnLib-1.39.0.jar.
  2. Restart the server (a reload never reloads classes).

Existing consumers do NOT need a recompile. A consumer that declares commandPriority() requires API level 26, so SnLib 1.39.0 must be on the server BEFORE that consumer.