/// <summary> /// UnRegister this event /// </summary> /// <param name="plugin">The plugin object that has this event registered</param> 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)); }
/// <summary> /// Register this event /// </summary> /// <param name="method">This is the delegate that will get called when this event occurs</param> /// <param name="priority">The priority (imporantce) of this call</param> /// <param name="plugin">The plugin object that is registering the event</param> /// <param name="bypass">Register more than one of the same event</param> public static void Register(Player.OnPlayerChat method, Priority priority, Plugin plugin, bool bypass = false) { if (Find(plugin) != null) if (!bypass) throw new Exception("The user tried to register 2 of the same event!"); events.Add(new OnPlayerChatEvent(method, priority, plugin)); Organize(); }
/// <summary> /// Find a event /// </summary> /// <param name="plugin">The plugin that registered this event</param> /// <returns>The event</returns> public static OnServerErrorEvent Find(Plugin plugin) { foreach (OnServerErrorEvent p in events.ToArray()) { if (p.plugin == plugin) return p; } return null; }
/// <summary> /// Find a event /// </summary> /// <param name="plugin">The plugin that registered this event</param> /// <returns>The event</returns> public static OnGroupLoadEvent Find(Plugin plugin) { foreach (OnGroupLoadEvent p in events.ToArray()) { if (p.plugin == plugin) return p; } return null; }
public static OnBlockChangeEvent Find(Plugin plugin) { foreach (OnBlockChangeEvent p in events.ToArray()) { if (p.plugin == plugin) return p; } return null; }
/// <summary> /// Find a event /// </summary> /// <param name="plugin">The plugin that registered this event</param> /// <returns>The event</returns> public static OnConsoleCommandEvent Find(Plugin plugin) { foreach (OnConsoleCommandEvent p in events.ToArray()) { if (p.plugin == plugin) return p; } return null; }
/// <summary> /// Find a event /// </summary> /// <param name="plugin">The plugin that registered this event</param> /// <returns>The event</returns> public static OnPhysicsUpdateEvent Find(Plugin plugin) { foreach (OnPhysicsUpdateEvent p in events.ToArray()) { if (p.plugin == plugin) return p; } return null; }
public static OnPlayerChatEvent Find(Plugin plugin) { foreach (OnPlayerChatEvent p in events.ToArray()) { if (p.plugin == plugin) return p; } return null; }
internal OnPlayerChatEvent(Player.OnPlayerChat method, Priority priority, Plugin plugin) { this.plugin = plugin; this.priority = priority; this.method = method; }
internal OnBlockChangeEvent(Player.BlockchangeEventHandler method, Priority priority, Plugin plugin) { this.plugin = plugin; this.priority = priority; this.method = method; }
internal OnLevelSaveEvent(Level.OnLevelSave method, Priority priority, Plugin plugin) { this.plugin = plugin; this.priority = priority; this.method = method; }
/// <summary> /// Unload a plugin /// </summary> /// <param name="p">The plugin to unload</param> /// <param name="shutdown">Is this shutdown?</param> public static void Unload(Plugin p, bool shutdown) { try { p.Unload(shutdown); all.Remove(p); Server.s.Log(p.name + " was unloaded."); } catch { Server.s.Log("An error occurred while unloading a plugin."); } }
internal OnGroupSaveEvent(Group.GroupSave method, Priority priority, Plugin plugin) { this.plugin = plugin; this.priority = priority; this.method = method; }
internal OnPlayerRankSetEvent(Group.RankSet method, Priority priority, Plugin plugin) { this.plugin = plugin; this.priority = priority; this.method = method; }
internal OnServerErrorEvent(Server.OnServerError method, Priority priority, Plugin plugin) { this.plugin = plugin; this.priority = priority; this.method = method; }
internal PlayerMoveEvent(Player.OnPlayerMove method, Priority priority, Plugin plugin) { this.plugin = plugin; this.priority = priority; this.method = method; }
internal OnPhysicsUpdateEvent(Level.OnPhysicsUpdate method, Priority priority, Plugin plugin) { this.plugin = plugin; this.priority = priority; this.method = method; }
/// <summary> /// Find a event /// </summary> /// <param name="plugin">The plugin that registered this event</param> /// <returns>The event</returns> public static OnGroupLoadedEvent Find(Plugin plugin) { return events.ToArray().FirstOrDefault(p => p.plugin == plugin); }
internal OnConsoleCommandEvent(Server.OnConsoleCommand method, Priority priority, Plugin plugin) { this.plugin = plugin; this.priority = priority; this.method = method; }
static void ShutdownThread(bool restarting, string msg) { try { Logger.Log(LogType.SystemActivity, "Server shutting down ({0})", msg); } catch { } // Stop accepting new connections and disconnect existing sessions try { if (Listener != null) { Listener.Close(); } } catch (Exception ex) { Logger.LogError(ex); } try { Player[] players = PlayerInfo.Online.Items; foreach (Player p in players) { p.Leave(msg); } } catch (Exception ex) { Logger.LogError(ex); } byte[] kick = Packet.Kick(msg, false); try { INetSocket[] pending = INetSocket.pending.Items; foreach (INetSocket p in pending) { p.Send(kick, false); } } catch (Exception ex) { Logger.LogError(ex); } Plugin.UnloadAll(); OnShuttingDownEvent.Call(restarting, msg); try { string autoload = null; Level[] loaded = LevelInfo.Loaded.Items; foreach (Level lvl in loaded) { if (!lvl.SaveChanges) { continue; } autoload = autoload + lvl.name + "=" + lvl.physics + Environment.NewLine; lvl.Save(false, true); lvl.SaveBlockDBChanges(); } if (Server.SetupFinished && !Server.Config.AutoLoadMaps) { File.WriteAllText("text/autoload.txt", autoload); } } catch (Exception ex) { Logger.LogError(ex); } try { Logger.Log(LogType.SystemActivity, "Server shutdown completed"); } catch { } try { FileLogger.Flush(null); } catch { } if (restarting) { Process.Start(RestartPath); } Environment.Exit(0); }
/// <summary> /// Find a event /// </summary> /// <param name="plugin">The plugin that registered this event</param> /// <returns>The event</returns> public static OnServerLogEvent Find(Plugin plugin) { return events.ToArray().FirstOrDefault(p => p.plugin == plugin); }