コード例 #1
0
 /// <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));
 }
コード例 #2
0
 /// <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();
 }
コード例 #3
0
 /// <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;
 }
コード例 #4
0
 /// <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;
 }
コード例 #5
0
 public static OnBlockChangeEvent Find(Plugin plugin)
 {
     foreach (OnBlockChangeEvent p in events.ToArray())
     {
         if (p.plugin == plugin)
             return p;
     }
     return null;
 }
コード例 #6
0
 /// <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;
 }
コード例 #7
0
 /// <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;
 }
コード例 #8
0
 public static OnPlayerChatEvent Find(Plugin plugin)
 {
     foreach (OnPlayerChatEvent p in events.ToArray())
     {
         if (p.plugin == plugin)
             return p;
     }
     return null;
 }
コード例 #9
0
 internal OnPlayerChatEvent(Player.OnPlayerChat method, Priority priority, Plugin plugin)
 {
     this.plugin = plugin; this.priority = priority; this.method = method;
 }
コード例 #10
0
 internal OnBlockChangeEvent(Player.BlockchangeEventHandler method, Priority priority, Plugin plugin)
 {
     this.plugin = plugin; this.priority = priority; this.method = method;
 }
コード例 #11
0
 internal OnLevelSaveEvent(Level.OnLevelSave method, Priority priority, Plugin plugin)
 {
     this.plugin = plugin; this.priority = priority; this.method = method;
 }
コード例 #12
0
ファイル: Plugin_Manager.cs プロジェクト: tommyz56/MCGalaxy
        /// <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."); }
        }
コード例 #13
0
 internal OnGroupSaveEvent(Group.GroupSave method, Priority priority, Plugin plugin)
 {
     this.plugin = plugin; this.priority = priority; this.method = method;
 }
コード例 #14
0
 internal OnPlayerRankSetEvent(Group.RankSet method, Priority priority, Plugin plugin)
 {
     this.plugin = plugin; this.priority = priority; this.method = method;
 }
コード例 #15
0
 internal OnServerErrorEvent(Server.OnServerError method, Priority priority, Plugin plugin)
 {
     this.plugin = plugin; this.priority = priority; this.method = method;
 }
コード例 #16
0
 internal PlayerMoveEvent(Player.OnPlayerMove method, Priority priority, Plugin plugin)
 {
     this.plugin = plugin; this.priority = priority; this.method = method;
 }
コード例 #17
0
 internal OnPhysicsUpdateEvent(Level.OnPhysicsUpdate method, Priority priority, Plugin plugin)
 {
     this.plugin = plugin; this.priority = priority; this.method = method;
 }
コード例 #18
0
 /// <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);
 }
コード例 #19
0
 internal OnConsoleCommandEvent(Server.OnConsoleCommand method, Priority priority, Plugin plugin)
 {
     this.plugin = plugin; this.priority = priority; this.method = method;
 }
コード例 #20
0
        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);
        }
コード例 #21
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);
 }