Пример #1
0
        public xCoreSkyWars(xCoreGames core, PluginContext cont)
        {
            Core    = core;
            Context = cont;
            Context.PluginManager.LoadPacketHandlers(this);
            NameGame = "SkyWars";

            _basepath = Config.GetProperty("PluginDirectory", "Plugins") + "\\" + NameGame;
            if (!Directory.Exists(_basepath))
            {
                Directory.CreateDirectory(_basepath);
            }
            if (!File.Exists(_basepath + "\\config.json"))
            {
                Log.Error("[ERROR] конфиг отсутствует");
                OnDisable();
            }
            string cfg = File.ReadAllText(_basepath + "\\config.json");

            conf        = JObject.Parse(cfg);
            ArenaLoaded = (int)conf["ArenaLoaded"];
            Prefix      = (string)conf["Prefix"];
            MinPlayers  = (int)conf["MinPlayers"];
            Pool        = new LevelPoolGame(Core, this, false, true);;
            foreach (KeyValuePair <string, Lang> l in Core.Lang.getLangs())
            {
                l.Value.AddLines(Config.GetProperty("PluginDirectory", "Plugins") + "\\lang\\xCoreSkyWars\\" + l.Value.Name + ".ini");
            }
            SqlString = "kills, deaths, wins, games";
            Log.Info("[Cristalix] SkyWars Enabled");
        }
Пример #2
0
        //public List<Gadget> Gadgets = new List<Gadget>();

        //public ChestInfo Chest { get; set; }

        public xCoreLevelLobby(string levelId, IWorldProvider worldProvider, EntityManager entitymanager, xCoreGames core) : base(null, levelId, worldProvider, entitymanager)
        {
            Core               = core;
            AllowBreak         = false;
            AllowBuild         = false;
            CurrentWorldTime   = 6000;
            IsWorldTimeStarted = false;
        }
Пример #3
0
 public xPlayer(MiNetServer server, IPEndPoint endpoint, xCoreGames core) : base(server, endpoint)
 {
     xCore = core;
     //IsWorldImmutable = true;
 }
Пример #4
0
        public LevelPoolGame(xCoreGames core, xCoreInterface game, bool onlyread, bool parse)
        {
            Random rnd     = new Random();
            var    timings = new Stopwatch();

            timings.Start();
            string basepath = Config.GetProperty("PluginDirectory", "Plugins") + "\\" + game.NameGame;

            for (int id = 1; id <= game.ArenaLoaded; id++)
            {
                if (Maps.Count == 0)
                {
                    DirectoryInfo dirInfo = new DirectoryInfo(basepath);
                    foreach (var dir in dirInfo.GetDirectories())
                    {
                        var     provider = new AnvilWorldProvider(basepath + "\\" + dir.Name);
                        var     cfg      = File.ReadAllText(basepath + "\\" + dir.Name + "\\config.json");
                        JObject jobj     = JObject.Parse(cfg);
                        Maps.Add(dir.Name, new MapInfo(dir.Name, jobj));
                        Maps[dir.Name].ProviderCache = provider;
                        Maps[dir.Name].ProviderCache.Initialize();
                        Maps[dir.Name].ProviderCache.PruneAir();
                        Maps[dir.Name].ProviderCache.MakeAirChunksAroundWorldToCompensateForBadRendering();
                    }
                }

                string map = Maps.Keys.ElementAt(rnd.Next(0, Maps.Keys.Count - 1));

                Level levelkey = Levels.FirstOrDefault(l => l.LevelId.Equals(game.NameGame + id, StringComparison.InvariantCultureIgnoreCase));
                if (levelkey == null)
                {
                    AnvilWorldProvider provider;
                    //provider = Maps[map].ProviderCache;
                    //if (!Maps[map].ProviderBool)
                    //{
                    if (onlyread)
                    {
                        provider = Maps[map].ProviderCache;
                    }
                    else
                    {
                        provider = Maps[map].ProviderCache.Clone() as AnvilWorldProvider;
                    }
                    //}
                    var level = new xCoreLevel(provider, game.Context.Server.LevelManager.EntityManager, game, Maps[map], LevelCount);
                    LevelCount++;
                    level.Initialize();
                    SkyLightCalculations.Calculate(level);
                    while (provider.LightSources.Count > 0)
                    {
                        var block = provider.LightSources.Dequeue();
                        block = level.GetBlock(block.Coordinates);
                        BlockLightCalculations.Calculate(level, block);
                    }
                    if (parse)
                    {
                        int X = Maps[map].Center.X;
                        int Z = Maps[map].Center.Z;
                        List <BlockCoordinates> BE = new List <BlockCoordinates>();
                        if (Maps[map].CacheBlockEntites == null)
                        {
                            int startX = Math.Min(X - 256, X + 256);
                            int endX   = Math.Max(X - 256, X + 256);
                            int startY = Math.Min(11, 129);
                            int endY   = Math.Max(11, 129);
                            int startZ = Math.Min(Z - 256, Z + 256);
                            int endZ   = Math.Max(Z - 256, Z + 256);
                            for (int x = startX; x <= endX; ++x)
                            {
                                for (int y = startY; y <= endY; ++y)
                                {
                                    for (int z = startZ; z <= endZ; ++z)
                                    {
                                        var         bc = new BlockCoordinates(x, y, z);
                                        BlockEntity blockentity;
                                        if ((blockentity = level.GetBlockEntity(bc)) != null)
                                        {
                                            if (blockentity is ChestBlockEntity)
                                            {
                                                if (!BE.Contains(blockentity.Coordinates))
                                                {
                                                    BE.Add(blockentity.Coordinates);
                                                }
                                            }
                                            else if (blockentity is Sign)
                                            {
                                                CleanSignText(((Sign)blockentity).GetCompound(), "Text1");
                                                CleanSignText(((Sign)blockentity).GetCompound(), "Text2");
                                                CleanSignText(((Sign)blockentity).GetCompound(), "Text3");
                                                CleanSignText(((Sign)blockentity).GetCompound(), "Text4");
                                                BE.Add(bc);
                                            }
                                        }
                                    }
                                }
                            }
                            for (int x = startX; x <= endX; ++x)
                            {
                                for (int z = startZ; z <= endZ; ++z)
                                {
                                    var bc = new BlockCoordinates(x, 127, z);
                                    MiNET.Blocks.Block b = level.GetBlock(bc);
                                    if (b.Id == 95)
                                    {
                                        level.SetAir(bc, false);
                                    }
                                }
                            }
                        }
                        if (Maps[map].CacheBlockEntites == null)
                        {
                            Maps[map].CacheBlockEntites = BE;
                        }
                    }
                    game.Initialization(level);
                    Levels.Add(level);
                }
            }
            Core     = core;
            Game     = game;
            OnlyRead = onlyread;
            timings.Stop();
            Log.Info("Loaded " + Levels.Count + " arenas . Load time " + timings.ElapsedMilliseconds + " ms");
            _tickerHighPrecisionTimer = new Timer(QueueTimer, null, 0, 1000);
        }
Пример #5
0
 public LobbyManager(xCoreGames xc)
 {
     xCore         = xc;
     Levels        = new List <Level>();
     EntityManager = new EntityManager();
 }
Пример #6
0
 public xCoreHealthManager(Entity entity, xCoreGames core) : base(entity)
 {
     Core   = core;
     Entity = entity;
     ResetHealth();
 }