Exemplo n.º 1
0
        public static void ReloadAll(Level lvl, Player src, bool announce)
        {
            Player[] players = PlayerInfo.Online.Items;
            foreach (Player p in players)
            {
                if (p.level != lvl)
                {
                    continue;
                }
                PlayerActions.ReloadMap(p);
                if (!announce)
                {
                    continue;
                }

                if (src == null || !p.CanSee(src))
                {
                    p.Message("&bMap reloaded");
                }
                else
                {
                    p.Message("&bMap reloaded by " + p.FormatNick(src));
                }
                if (src.CanSee(p))
                {
                    src.Message("&4Finished reloading for " + src.FormatNick(p));
                }
            }
        }
Exemplo n.º 2
0
        public static void Replace(Level old, Level lvl)
        {
            LevelDB.SaveBlockDB(old);
            LevelInfo.Remove(old);
            LevelInfo.Add(lvl);

            old.SetPhysics(0);
            old.ClearPhysics();
            lvl.StartPhysics();

            Player[] players = PlayerInfo.Online.Items;
            foreach (Player pl in players)
            {
                if (pl.level != old)
                {
                    continue;
                }
                pl.level = lvl;
                PlayerActions.ReloadMap(pl);
            }

            old.Unload(true, false);
            if (old == Server.mainLevel)
            {
                Server.mainLevel = lvl;
            }
        }
Exemplo n.º 3
0
        static void SetMotd(Player p, Level lvl, string value)
        {
            lvl.Config.MOTD = value.Length == 0 ? "ignore" : value;
            lvl.Message("Map's MOTD was changed to: &b" + lvl.Config.MOTD);

            Player[] players = PlayerInfo.Online.Items;
            foreach (Player pl in players)
            {
                // Some clients will freeze or crash if we send a MOTD packet, but don't follow it up by a new map.
                // Hnece only send MOTD for clients supporting InstantMOTD CPE extension
                if (pl.Supports(CpeExt.InstantMOTD))
                {
                    pl.SendMapMotd();
                }
                else
                {
                    PlayerActions.ReloadMap(pl);
                }
            }
        }
Exemplo n.º 4
0
        static void SetMotd(Player p, Level lvl, string value)
        {
            lvl.Config.MOTD = value.Length == 0 ? "ignore" : value;
            lvl.Message("Map's MOTD was changed to: &b" + lvl.Config.MOTD);

            Player[] players = PlayerInfo.Online.Items;
            foreach (Player pl in players)
            {
                // Some clients will freeze or crash if we send a MOTD packet, but don't follow it up by a new map.
                // Although checking for CPE extension support is preferred, also send to whitelisted clients for maximum compatibility
                bool motdOnly = pl.Supports(CpeExt.InstantMOTD) || (pl.appName != null && pl.appName.CaselessStarts("classicalsharp"));
                if (motdOnly)
                {
                    pl.SendMapMotd();
                }
                else
                {
                    PlayerActions.ReloadMap(pl);
                }
            }
        }
Exemplo n.º 5
0
        public static void UpdateFallback(bool global, BlockID block, Level level)
        {
            Player[] players = PlayerInfo.Online.Items;
            foreach (Player pl in players)
            {
                if (!global && pl.level != level)
                {
                    continue;
                }
                if (pl.hasBlockDefs)
                {
                    continue;
                }

                // if custom block is replacing core block, need to always reload for fallback
                if (block >= Block.CpeCount && !pl.level.MightHaveCustomBlocks())
                {
                    continue;
                }
                PlayerActions.ReloadMap(pl);
            }
        }
Exemplo n.º 6
0
        public static void UpdateFallback(bool global, BlockID block, Level level)
        {
            Player[] players = PlayerInfo.Online.Items;
            foreach (Player pl in players)
            {
                if (!global && pl.level != level)
                {
                    continue;
                }
                if (pl.Session.hasBlockDefs)
                {
                    continue;
                }

                // If custom block is replacing core block, need to always reload for fallback
                // But if level doesn't use custom blocks, don't need to reload for the player
                if (block >= Block.CPE_COUNT && !pl.level.MightHaveCustomBlocks())
                {
                    continue;
                }
                PlayerActions.ReloadMap(pl);
            }
        }