Added plugin meta.txt property "Essentials", which lists versions of Essentials the plugin is compatible with

This commit is contained in:
Maruno17
2021-11-02 20:46:32 +00:00
parent cff6edac5b
commit 5ad9f60d61

View File

@@ -172,18 +172,17 @@ module PluginManager
def self.register(options) def self.register(options)
name = nil name = nil
version = nil version = nil
essentials = nil
link = nil link = nil
dependencies = nil dependencies = nil
incompats = nil incompats = nil
credits = [] 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, # Ensure it first reads the plugin's name, which is used in error reporting,
# by sorting the keys # by sorting the keys
keys = options.keys.sort do |a, b| keys = options.keys.sort do |a, b|
idx_a = order.index(a) idx_a = order.index(a) || order.size
idx_a = order.size if idx_a == -1 idx_b = order.index(b) || order.size
idx_b = order.index(b)
idx_b = order.size if idx_b == -1
next idx_a <=> idx_b next idx_a <=> idx_b
end end
for key in keys for key in keys
@@ -202,6 +201,8 @@ module PluginManager
self.error("Plugin version must be a string.") self.error("Plugin version must be a string.")
end end
version = value version = value
when :essentials
essentials = value
when :link # Plugin website when :link # Plugin website
if nil_or_empty?(value) if nil_or_empty?(value)
self.error("Plugin link must be a non-empty string.") self.error("Plugin link must be a non-empty string.")
@@ -338,6 +339,7 @@ module PluginManager
@@Plugins[name] = { @@Plugins[name] = {
:name => name, :name => name,
:version => version, :version => version,
:essentials => essentials,
:link => link, :link => link,
:dependencies => dependencies, :dependencies => dependencies,
:incompatibilities => incompats, :incompatibilities => incompats,
@@ -495,6 +497,9 @@ module PluginManager
data.each_with_index { |value, i| data[i] = value.strip } data.each_with_index { |value, i| data[i] = value.strip }
# begin formatting data hash # begin formatting data hash
case property case property
when 'ESSENTIALS'
meta[:essentials] = [] if !meta[:essentials]
data.each { |ver| meta[:essentials].push(ver) }
when 'REQUIRES' when 'REQUIRES'
meta[:dependencies] = [] if !meta[:dependencies] meta[:dependencies] = [] if !meta[:dependencies]
if data.length < 2 # No version given, just push name of plugin dependency if data.length < 2 # No version given, just push name of plugin dependency
@@ -694,6 +699,9 @@ module PluginManager
for plugin in scripts for plugin in scripts
# get the required data # get the required data
name, meta, script = plugin 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 # register plugin
self.register(meta) self.register(meta)
# go through each script and interpret # go through each script and interpret