Skip to content

Commit

Permalink
Streamlining plugin load.
Browse files Browse the repository at this point in the history
  • Loading branch information
lynnfaraday committed Jan 26, 2018
1 parent a610654 commit 32e7c2f
Show file tree
Hide file tree
Showing 48 changed files with 31 additions and 340 deletions.
6 changes: 2 additions & 4 deletions copy_help.rb
Expand Up @@ -8,25 +8,23 @@
filename_friendly_help_version = help_version.gsub(".", "-")

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), *%w[engine]))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), *%w[lib]))

require 'fileutils'
require 'ansi'
require 'aresmush'
require 'engine'
require 'erubis'
require 'rspec'
require 'rspec/core/rake_task'
require 'tempfile'
#require 'mongoid'
require_relative 'install/init_db.rb'
require_relative 'install/configure_game.rb'
require_relative 'plugins/help/lib/helpers.rb'
require_relative 'plugins/help/helpers.rb'

def minimal_boot
bootstrapper = AresMUSH::Bootstrapper.new
AresMUSH::Global.plugin_manager.load_all
bootstrapper.config_reader.load_game_config
AresMUSH::Global.plugin_manager.load_all
bootstrapper.help_reader.load_game_help
bootstrapper.db.load_config
end
Expand Down
2 changes: 2 additions & 0 deletions engine/aresmush/commands/dispatcher.rb
Expand Up @@ -73,6 +73,7 @@ def on_command(client, cmd)

CommandAliasParser.substitute_aliases(enactor, cmd, Global.plugin_manager.shortcuts)
Global.plugin_manager.plugins.each do |p|
next if !p.respond_to?(:get_cmd_handler)
AresMUSH.with_error_handling(client, cmd) do
handler_class = p.get_cmd_handler(client, cmd, enactor)
if (handler_class)
Expand All @@ -95,6 +96,7 @@ def on_event(event)
begin
event_name = event.class.to_s.gsub("AresMUSH::", "")
Global.plugin_manager.plugins.each do |p|
next if !p.respond_to?(:get_event_handler)
AresMUSH.with_error_handling(nil, "Handling #{event_name}.") do
handler_class = p.get_event_handler(event_name)
if (handler_class)
Expand Down
4 changes: 1 addition & 3 deletions engine/aresmush/config/help_reader.rb
Expand Up @@ -22,9 +22,7 @@ def load_game_help
end
end

def load_help_file(file, plugin)
Global.logger.debug "Loading help from #{file}."

def load_help_file(file, plugin)
plugin_title = plugin ? plugin.downcase : ""

md = MarkdownFile.new(file)
Expand Down
5 changes: 4 additions & 1 deletion engine/aresmush/plugin/plugin_manager.rb
Expand Up @@ -59,7 +59,10 @@ def load_plugin(name)
load_plugin_locale plugin_module
load_plugin_help plugin_module

@plugins << plugin_module.send(:load_plugin)
if (plugin_module.respond_to?(:init_plugin))
plugin_module.send(:init_plugin)
end
@plugins << plugin_module
end

def load_plugin_locale(plugin_module)
Expand Down
4 changes: 0 additions & 4 deletions engine/aresmush/web/engine_api_server.rb
Expand Up @@ -74,10 +74,6 @@ class EngineApiServer < Sinatra::Base
end
return { error: "Sorry, something went wrong with the web request." }.to_json
end

post '/upload/?' do
puts params.inspect
end

end
end
7 changes: 0 additions & 7 deletions plugins/arescentral/arescentral.rb
Expand Up @@ -12,13 +12,6 @@ def self.shortcuts
Global.read_config("arescentral", "shortcuts")
end

def self.load_plugin
self
end

def self.unload_plugin
end

def self.get_cmd_handler(client, cmd, enactor)
case cmd.root
when "handle"
Expand Down
7 changes: 0 additions & 7 deletions plugins/bbs/bbs.rb
Expand Up @@ -11,13 +11,6 @@ def self.shortcuts
Global.read_config("bbs", "shortcuts")
end

def self.load_plugin
self
end

def self.unload_plugin
end

def self.get_cmd_handler(client, cmd, enactor)
return nil if !cmd.root_is?("bbs")

Expand Down
7 changes: 0 additions & 7 deletions plugins/channels/channels.rb
Expand Up @@ -11,13 +11,6 @@ def self.shortcuts
Global.read_config("channels", "shortcuts")
end

def self.load_plugin
self
end

def self.unload_plugin
end

def self.get_cmd_handler(client, cmd, enactor)
case cmd.root
when "channel"
Expand Down
11 changes: 0 additions & 11 deletions plugins/chargen/chargen.rb
Expand Up @@ -11,13 +11,6 @@ def self.shortcuts
Global.read_config("chargen", "shortcuts")
end

def self.load_plugin
self
end

def self.unload_plugin
end

def self.get_cmd_handler(client, cmd, enactor)
case cmd.root
when "app"
Expand Down Expand Up @@ -64,10 +57,6 @@ def self.get_cmd_handler(client, cmd, enactor)

return nil
end

def self.get_event_handler(event_name)
nil
end

def self.get_web_request_handler(request)
case request.cmd
Expand Down
3 changes: 1 addition & 2 deletions plugins/chargen/helpers.rb
Expand Up @@ -44,8 +44,7 @@ def self.unsubmit_app(char)
end

def self.read_tutorial(name)
dir = File.dirname(__FILE__) + "/../engine/templates/"
filename = File.join(dir, name)
filename = File.join(File.dirname(__FILE__), 'templates', name)
File.read(filename, :encoding => "UTF-8")
end

Expand Down
7 changes: 0 additions & 7 deletions plugins/cookies/cookies.rb
Expand Up @@ -10,13 +10,6 @@ def self.shortcuts
Global.read_config("cookies", "shortcuts")
end

def self.load_plugin
self
end

def self.unload_plugin
end

def self.get_cmd_handler(client, cmd, enactor)
return nil if !cmd.root_is?("cookie")

Expand Down
11 changes: 0 additions & 11 deletions plugins/custom/custom.rb
Expand Up @@ -10,19 +10,8 @@ def self.shortcuts
Global.read_config("custom", "shortcuts")
end

def self.load_plugin
self
end

def self.unload_plugin
end

def self.get_cmd_handler(client, cmd, enactor)
nil
end

def self.get_event_handler(event_name)
nil
end
end
end
11 changes: 0 additions & 11 deletions plugins/demographics/demographics.rb
Expand Up @@ -10,13 +10,6 @@ def self.shortcuts
Global.read_config("demographics", "shortcuts")
end

def self.load_plugin
self
end

def self.unload_plugin
end

def self.get_cmd_handler(client, cmd, enactor)

case cmd.root
Expand Down Expand Up @@ -61,10 +54,6 @@ def self.get_cmd_handler(client, cmd, enactor)

nil
end

def self.get_event_handler(event_name)
nil
end

def self.get_web_request_handler(request)
case request.cmd
Expand Down
11 changes: 0 additions & 11 deletions plugins/describe/describe.rb
Expand Up @@ -10,13 +10,6 @@ def self.shortcuts
Global.read_config("describe", "shortcuts")
end

def self.load_plugin
self
end

def self.unload_plugin
end

def self.get_cmd_handler(client, cmd, enactor)
case cmd.root
when "describe", "shortdesc"
Expand Down Expand Up @@ -64,9 +57,5 @@ def self.get_cmd_handler(client, cmd, enactor)

nil
end

def self.get_event_handler(event_name)
nil
end
end
end
7 changes: 0 additions & 7 deletions plugins/events/events.rb
Expand Up @@ -10,13 +10,6 @@ def self.shortcuts
Global.read_config("events", "shortcuts")
end

def self.load_plugin
self
end

def self.unload_plugin
end

def self.get_cmd_handler(client, cmd, enactor)
case cmd.root
when "event"
Expand Down
11 changes: 0 additions & 11 deletions plugins/friends/friends.rb
Expand Up @@ -10,13 +10,6 @@ def self.shortcuts
Global.read_config("friends", "shortcuts")
end

def self.load_plugin
self
end

def self.unload_plugin
end

def self.get_cmd_handler(client, cmd, enactor)
return nil if !cmd.root_is?("friend")

Expand All @@ -33,9 +26,5 @@ def self.get_cmd_handler(client, cmd, enactor)

nil
end

def self.get_event_handler(event_name)
nil
end
end
end
7 changes: 0 additions & 7 deletions plugins/fs3combat/fs3combat.rb
Expand Up @@ -10,13 +10,6 @@ def self.shortcuts
Global.read_config("fs3combat", "shortcuts")
end

def self.load_plugin
self
end

def self.unload_plugin
end

def self.get_cmd_handler(client, cmd, enactor)
case cmd.root
when"damage"
Expand Down
24 changes: 6 additions & 18 deletions plugins/fs3combat/helpers/general_helper.rb
Expand Up @@ -47,15 +47,9 @@ def self.emit_to_combat(combat, message, npcmaster = nil, add_to_scene = false)
def self.emit_to_organizer(combat, message, npcmaster = nil)
message = message + " (#{npcmaster})" if npcmaster

if (defined? Engine)
client = Login.find_client(combat.organizer)
if (client)
client.emit t('fs3combat.organizer_emit', :message => message)
end
else
Global.notifier.notify(:combat, t('fs3combat.organizer_emit', :message => message)) do |char|
char == combat.organizer
end
client = Login.find_client(combat.organizer)
if (client)
client.emit t('fs3combat.organizer_emit', :message => message)
end
end

Expand All @@ -64,15 +58,9 @@ def self.emit_to_combatant(combatant, message)
return if !char

client_message = message.gsub(/#{combatant.name}/, "%xh%xc#{combatant.name}%xn")
if (defined? Engine)
client = Login.find_client(char)
if (client)
client.emit t('fs3combat.combat_emit', :message => client_message)
end
else
Global.notifier.notify(:combat, t('fs3combat.combat_emit', :message => client_message)) do |char|
char == combatant.character
end
client = Login.find_client(char)
if (client)
client.emit t('fs3combat.combat_emit', :message => client_message)
end
end

Expand Down
7 changes: 0 additions & 7 deletions plugins/fs3skills/fs3skills.rb
Expand Up @@ -10,13 +10,6 @@ def self.shortcuts
Global.read_config("fs3skills", "shortcuts")
end

def self.load_plugin
self
end

def self.unload_plugin
end

def self.get_cmd_handler(client, cmd, enactor)
case cmd.root
when "abilities"
Expand Down
10 changes: 1 addition & 9 deletions plugins/help/help.rb
Expand Up @@ -10,12 +10,8 @@ def self.shortcuts
Global.read_config("help", "shortcuts")
end

def self.load_plugin
def self.init_plugin
Help.reload_help
self
end

def self.unload_plugin
end

def self.get_cmd_handler(client, cmd, enactor)
Expand All @@ -29,10 +25,6 @@ def self.get_cmd_handler(client, cmd, enactor)

nil
end

def self.get_event_handler(event_name)
nil
end

def self.get_web_request_handler(request)
case request.cmd
Expand Down
11 changes: 0 additions & 11 deletions plugins/ictime/ictime.rb
Expand Up @@ -11,13 +11,6 @@ def self.shortcuts
Global.read_config("ictime", "shortcuts")
end

def self.load_plugin
self
end

def self.unload_plugin
end

def self.get_cmd_handler(client, cmd, enactor)
case cmd.root
when "ictime"
Expand All @@ -26,9 +19,5 @@ def self.get_cmd_handler(client, cmd, enactor)

nil
end

def self.get_event_handler(event_name)
nil
end
end
end

0 comments on commit 32e7c2f

Please sign in to comment.