From 5ad9f60d61e9cc5ce458b7a94c5f5d9146518b31 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Tue, 2 Nov 2021 20:46:32 +0000 Subject: [PATCH] Added plugin meta.txt property "Essentials", which lists versions of Essentials the plugin is compatible with --- .../Scripts/001_Technical/005_PluginManager.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Data/Scripts/001_Technical/005_PluginManager.rb b/Data/Scripts/001_Technical/005_PluginManager.rb index a379d7582..492132bf7 100644 --- a/Data/Scripts/001_Technical/005_PluginManager.rb +++ b/Data/Scripts/001_Technical/005_PluginManager.rb @@ -172,18 +172,17 @@ module PluginManager def self.register(options) name = nil version = nil + essentials = nil link = nil dependencies = nil incompats = nil credits = [] - order = [:name, :version, :link, :dependencies, :incompatibilities, :credits] + order = [:name, :version, :essentials, :link, :dependencies, :incompatibilities, :credits] # Ensure it first reads the plugin's name, which is used in error reporting, # by sorting the keys keys = options.keys.sort do |a, b| - idx_a = order.index(a) - idx_a = order.size if idx_a == -1 - idx_b = order.index(b) - idx_b = order.size if idx_b == -1 + idx_a = order.index(a) || order.size + idx_b = order.index(b) || order.size next idx_a <=> idx_b end for key in keys @@ -202,6 +201,8 @@ module PluginManager self.error("Plugin version must be a string.") end version = value + when :essentials + essentials = value when :link # Plugin website if nil_or_empty?(value) self.error("Plugin link must be a non-empty string.") @@ -338,6 +339,7 @@ module PluginManager @@Plugins[name] = { :name => name, :version => version, + :essentials => essentials, :link => link, :dependencies => dependencies, :incompatibilities => incompats, @@ -495,6 +497,9 @@ module PluginManager data.each_with_index { |value, i| data[i] = value.strip } # begin formatting data hash case property + when 'ESSENTIALS' + meta[:essentials] = [] if !meta[:essentials] + data.each { |ver| meta[:essentials].push(ver) } when 'REQUIRES' meta[:dependencies] = [] if !meta[:dependencies] if data.length < 2 # No version given, just push name of plugin dependency @@ -694,6 +699,9 @@ module PluginManager for plugin in scripts # get the required data name, meta, script = plugin + if !meta[:essentials] || !meta[:essentials].include?(Essentials::VERSION) + echoln_warn "WARNING: Plugin '#{name}' may not be compatible with Essentials v#{Essentials::VERSION}. Trying to load anyway." + end # register plugin self.register(meta) # go through each script and interpret