public static void UnRegister(Plugin plugin)
 {
     if (Find(plugin) == null)
         throw new Exception("This plugin doesnt have this event registered!");
     else
         events.Remove(Find(plugin));
 }
 public static void Register(Plugin.PluginUnload method, Priority priority, Plugin plugin)
 {
     if (Find(plugin) != null)
         throw new Exception("The user tried to register 2 of the same event!");
     events.Add(new PluginUnloadEvent(method, priority, plugin));
     Organize();
 }
 public static void Register(Player.OnCrouchChange method, Priority priority, Plugin plugin)
 {
     if (Find(plugin) != null)
         throw new Exception("The user tried to register 2 of the same event!");
     events.Add(new OnCrouchChangeEvent(method, priority, plugin));
     Organize();
 }
 public static OnMessageRecieveEvent Find(Plugin plugin)
 {
     foreach (OnMessageRecieveEvent p in events.ToArray())
     {
         if (p.plugin == plugin)
             return p;
     }
     return null;
 }
 public static PluginLoadEvent Find(Plugin plugin)
 {
     foreach (PluginLoadEvent p in events.ToArray())
     {
         if (p.plugin == plugin)
             return p;
     }
     return null;
 }
 public static OnCrouchChangeEvent Find(Plugin plugin)
 {
     foreach (OnCrouchChangeEvent p in events.ToArray())
     {
         if (p.plugin == plugin)
             return p;
     }
     return null;
 }
 public static OnPlayerSprintEvent Find(Plugin plugin)
 {
     foreach (OnPlayerSprintEvent p in events.ToArray())
     {
         if (p.plugin == plugin)
             return p;
     }
     return null;
 }
 public static PlayerDisconnectEvent Find(Plugin plugin)
 {
     foreach (PlayerDisconnectEvent p in events.ToArray())
     {
         if (p.plugin == plugin)
             return p;
     }
     return null;
 }
 internal static void Call(Plugin p)
 {
     events.ForEach(delegate(PluginLoadEvent p1)
     {
         try
         {
             p1.method(p);
         }
         catch (Exception e) { Logger.Log("The plugin " + p1.plugin.name + " errored when calling the PluginLoad Event!"); Logger.LogErrorToFile(e); }
     });
 }
 internal OnCrouchChangeEvent(Player.OnCrouchChange method, Priority priority, Plugin plugin)
 {
     this.plugin = plugin; this.priority = priority; this.method = method;
 }
 internal static void Load(Plugin plugin, bool startup)
 {
     if (plugin == null) throw new ArgumentNullException();
     if (plugin.ForgeCraft_Version > Server.version)
     {
         Logger.LogFormat("Plugin \"{0}\" isn't compatible with this version of ForgeCraft!", plugin.name);
         if (Server.unsafe_plugin) Logger.Log("Will attempt to load anyways.");
         else return;
     }
     Plugin.all.Add(plugin);
     plugin.Load(startup);
     PluginLoadEvent.Call(plugin);
     if (cancelload)
     {
         Unload(plugin, false);
         cancelload = false;
         return;
     }
     Logger.LogFormat("Loaded plugin: {0} v{1}", plugin.name, plugin.version);
     Logger.Log(plugin.welcome);
 }
 /// <summary>
 /// Unload the specified p and shutdown.
 /// </summary>
 /// <param name='p'>
 /// P. The plugin object you want to unload
 /// </param>
 /// <param name='shutdown'>
 /// Shutdown. Is the server shutting down?
 /// </param>
 public static void Unload(Plugin p, bool shutdown)
 {
     p.Unload(shutdown);
     all.Remove(p);
     PluginUnloadEvent.Call(p);
     if (cancelunload)
     {
         Load(p, false);
         cancelunload = false;
         return;
     }
     Logger.Log(p.name + " was unloaded.");
 }
 internal OnPlayerSprintEvent(Player.OnSpritChange method, Priority priority, Plugin plugin)
 {
     this.plugin = plugin; this.priority = priority; this.method = method;
 }
 internal PlayerDisconnectEvent(Player.OnPlayerDisconnect method, Priority priority, Plugin plugin)
 {
     this.plugin = plugin; this.priority = priority; this.method = method;
 }
 internal OnMessageRecieveEvent(Player.OnPlayerChat method, Priority priority, Plugin plugin)
 {
     this.plugin = plugin; this.priority = priority; this.method = method;
 }
 internal OnPlayerCommandEvent(Player.OnPlayerCommand method, Priority priority, Plugin plugin)
 {
     this.plugin = plugin; this.priority = priority; this.method = method;
 }
 internal PluginLoadEvent(Plugin.PluginLoad method, Priority priority, Plugin plugin)
 {
     this.plugin = plugin; this.priority = priority; this.method = method;
 }