Example #1
0
        private void OnLocalPlayerIsInitialized(object o, PlayerEventArgs eventArgs)
        {
            Thread.Sleep(1000);
            Player player = eventArgs.Player;
            Level  level  = eventArgs.Level;

            level.BroadcastMessage($"{ChatColors.Gold}[{ChatColors.Green}+{ChatColors.Gold}]{ChatFormatting.Reset} {player.Username} joined the server");

            var joinSound = new AnvilUseSound(level.SpawnPoint.ToVector3());

            joinSound.Spawn(level);

            //player.SendTitle(null, TitleType.Clear);
            player.SendTitle(null, TitleType.AnimationTimes, 6, 6, 20 * 7);             // 7 seconds
            if (Context.Server.IsEdu)
            {
                player.SendTitle($"{ChatColors.White}This is a MiNET Education Edition server", TitleType.SubTitle);
                player.SendTitle($"{ChatColors.Gold}Welcome!", TitleType.Title);
            }
            else
            {
                player.SendTitle($"{ChatColors.White}This is gurun's MiNET test server", TitleType.SubTitle);
                player.SendTitle($"{ChatColors.Gold}Welcome {player.Username}!", TitleType.Title);
            }
        }
Example #2
0
        private void OnPlayerJoin(object o, PlayerEventArgs eventArgs)
        {
            Level level = eventArgs.Level;

            if (level == null)
            {
                throw new ArgumentNullException(nameof(eventArgs.Level));
            }

            Player player = eventArgs.Player;

            if (player == null)
            {
                throw new ArgumentNullException(nameof(eventArgs.Player));
            }


            int idx = 0;

            player.Inventory.Slots[idx++] = new ItemStick()
            {
                Count = 1
            };
            player.Inventory.Slots[idx++] = new ItemWheat()
            {
                Count = 1
            };
            player.Inventory.Slots[idx++] = new ItemCarrot()
            {
                Count = 1
            };
            player.Inventory.Slots[idx++] = new ItemWheatSeeds()
            {
                Count = 1
            };
            player.Inventory.Chest = new ItemElytra()
            {
                Count = 1
            };

            player.SendPlayerInventory();

            _players.TryAdd(player.Username, player);

            ThreadPool.QueueUserWorkItem(state =>
            {
                Thread.Sleep(2000);
                level.BroadcastMessage($"{ChatColors.Gold}[{ChatColors.Green}+{ChatColors.Gold}]{ChatFormatting.Reset} {player.Username}");
                var joinSound = new AnvilUseSound(level.SpawnPoint.ToVector3());
                joinSound.Spawn(level);

                player.SendTitle(null, TitleType.Clear);
                player.SendTitle(null, TitleType.AnimationTimes, 6, 6, 20 * 10);
                player.SendTitle($"{ChatColors.White}This is gurun's MiNET test server", TitleType.SubTitle);
                player.SendTitle($"{ChatColors.Gold}Welcome {player.Username}!", TitleType.Title);
            });
        }
        private void OnPlayerJoin(object o, PlayerEventArgs eventArgs)
        {
            Level level = eventArgs.Level;

            if (level == null)
            {
                throw new ArgumentNullException(nameof(eventArgs.Level));
            }

            Player player = eventArgs.Player;

            if (player == null)
            {
                throw new ArgumentNullException(nameof(eventArgs.Player));
            }


            int idx = 1;

            //player.Inventory.Slots[idx++] = new ItemBlock(new Block(212), 0) {Count = 64};
            //player.Inventory.Slots[idx++] = new ItemBlock(new Block(210), 0) {Count = 64};
            //player.Inventory.Slots[idx++] = new ItemBlock(new Block(211), 0) {Count = 64};
            //player.Inventory.Slots[idx++] = new ItemBlock(new Block(242), 0) {Count = 64};
            player.Inventory.Slots[idx++] = new ItemDiamondAxe()
            {
                Count = 1
            };
            player.Inventory.Slots[idx++] = new ItemDiamondShovel()
            {
                Count = 1
            };
            player.Inventory.Slots[idx++] = new ItemDiamondPickaxe()
            {
                Count = 1
            };
            player.Inventory.Slots[idx++] = new ItemStick()
            {
                Count = 64
            };
            player.Inventory.Slots[idx++] = new ItemBlock(new Planks(), 0)
            {
                Count = 64
            };
            player.Inventory.Slots[idx++] = new ItemCoal()
            {
                Count = 64
            };
            player.Inventory.Slots[idx++] = new ItemBread()
            {
                Count = 64
            };
            player.Inventory.Slots[idx++] = new ItemSnowball()
            {
                Count = 16
            };
            player.Inventory.Slots[idx++] = new ItemBow()
            {
                Count = 1
            };
            player.Inventory.Slots[idx++] = new ItemArrow()
            {
                Count = 64
            };
            player.Inventory.Slots[idx++] = new ItemBlock(new WoodenButton(), 0)
            {
                Count = 64
            };
            player.Inventory.Slots[idx++] = new ItemChest()
            {
                Count = 64
            };
            //player.Inventory.Slots[idx++] = new ItemFlintAndSteel() {Count = 1};
            player.Inventory.Slots[idx++] = new ItemBlock(new Torch(), 0)
            {
                Count = 64
            };
            player.Inventory.Slots[idx++] = new ItemStick()
            {
                Count = 1
            };
            player.Inventory.Slots[idx++] = new ItemBlock(new Stone(), 0)
            {
                Count = 64
            };
            player.Inventory.Slots[idx++] = new ItemWheat()
            {
                Count = 1
            };
            player.Inventory.Slots[idx++] = new ItemCarrot()
            {
                Count = 1
            };
            player.Inventory.Slots[idx++] = new ItemWheatSeeds()
            {
                Count = 1
            };
            player.Inventory.Slots[idx++] = new ItemBone()
            {
                Count = 64
            };
            player.Inventory.Chest = new ItemElytra()
            {
                Count = 1
            };

            player.SendPlayerInventory();

            _players.TryAdd(player.Username, player);

            ThreadPool.QueueUserWorkItem(state =>
            {
                Thread.Sleep(2000);
                level.BroadcastMessage($"{ChatColors.Gold}[{ChatColors.Green}+{ChatColors.Gold}]{ChatFormatting.Reset} {player.Username}");
                var joinSound = new AnvilUseSound(level.SpawnPoint.ToVector3());
                joinSound.Spawn(level);

                player.SendTitle(null, TitleType.Clear);
                player.SendTitle(null, TitleType.AnimationTimes, 6, 6, 20 * 10);
                player.SendTitle($"{ChatColors.White}This is gurun's MiNET test server", TitleType.SubTitle);
                player.SendTitle($"{ChatColors.Gold}Welcome {player.Username}!", TitleType.Title);
            });
        }
Example #4
0
        private void OnPlayerJoin(object o, PlayerEventArgs eventArgs)
        {
            Level level = eventArgs.Level;

            if (level == null)
            {
                throw new ArgumentNullException(nameof(eventArgs.Level));
            }

            Player player = eventArgs.Player;

            if (player == null)
            {
                throw new ArgumentNullException(nameof(eventArgs.Player));
            }

            if (player.CertificateData.ExtraData.Xuid != null && player.Username.Equals("gurunx"))
            {
                player.ActionPermissions = ActionPermissions.Operator;
                player.CommandPermission = 4;
                player.PermissionLevel   = PermissionLevel.Operator;
                player.SendAdventureSettings();
            }


            int idx = 0;

            //player.Inventory.Slots[idx++] = new ItemDiamondAxe() {Count = 1};
            //player.Inventory.Slots[idx++] = new ItemDiamondShovel() {Count = 1};
            //player.Inventory.Slots[idx++] = new ItemDiamondPickaxe() {Count = 1};
            //player.Inventory.Slots[idx++] = new ItemBlock(new Sapling(), 0) { Count = 64 };
            //player.Inventory.Slots[idx++] = new ItemBlock(new Sapling(), 2) { Count = 64 };
            //player.Inventory.Slots[idx++] = new ItemBlock(new Vine(), 0) { Count = 64 };
            //player.Inventory.Slots[idx++] = new ItemBlock(new Dirt(), 0) { Count = 64 };
            //player.Inventory.Slots[idx++] = new ItemBlock(new WoodenButton(), 0) { Count = 64 };
            idx = 8;
            player.Inventory.Slots[idx++] = new ItemStick()
            {
                Count = 64
            };

            var fireworks = new ItemFireworks()
            {
                Count = 64
            };

            fireworks.ExtraData = ItemFireworks.ToNbt(new ItemFireworks.FireworksData()

            {
                Explosions = new List <ItemFireworks.FireworksExplosion>()
                {
                    new ItemFireworks.FireworksExplosion()
                    {
                        FireworkColor   = new[] { (byte)0 },
                        FireworkFade    = new[] { (byte)1 },
                        FireworkFlicker = true,
                        FireworkTrail   = false,
                        FireworkType    = 0,
                    },
                    new ItemFireworks.FireworksExplosion()
                    {
                        FireworkColor   = new[] { (byte)1 },
                        FireworkFade    = new[] { (byte)2 },
                        FireworkFlicker = true,
                        FireworkTrail   = false,
                        FireworkType    = 1,
                    },
                    new ItemFireworks.FireworksExplosion()
                    {
                        FireworkColor   = new[] { (byte)2 },
                        FireworkFade    = new[] { (byte)3 },
                        FireworkFlicker = true,
                        FireworkTrail   = false,
                        FireworkType    = 2,
                    },
                    new ItemFireworks.FireworksExplosion()
                    {
                        FireworkColor   = new[] { (byte)3 },
                        FireworkFade    = new[] { (byte)4 },
                        FireworkFlicker = true,
                        FireworkTrail   = false,
                        FireworkType    = 3,
                    },
                    new ItemFireworks.FireworksExplosion()
                    {
                        FireworkColor   = new[] { (byte)4 },
                        FireworkFade    = new[] { (byte)5 },
                        FireworkFlicker = true,
                        FireworkTrail   = false,
                        FireworkType    = 4,
                    }
                },
                Flight = 2
            });

            player.Inventory.Slots[idx++] = fireworks;
            //player.Inventory.Slots[idx++] = new ItemBread() {Count = 64};
            //player.Inventory.Slots[idx++] = new ItemSnowball() {Count = 16};
            //player.Inventory.Slots[idx++] = new ItemBow() {Count = 1};
            //player.Inventory.Slots[idx++] = new ItemArrow() {Count = 64};
            //player.Inventory.Slots[idx++] = new ItemBlock(new Torch(), 0) {Count = 64};
            //player.Inventory.Slots[idx++] = new ItemBlock(new Stone(), 0) {Count = 64};
            //player.Inventory.Slots[idx++] = new ItemWheat() {Count = 1};
            //player.Inventory.Slots[idx++] = new ItemCarrot() {Count = 1};
            //player.Inventory.Slots[idx++] = new ItemWheatSeeds() {Count = 1};
            //player.Inventory.Slots[idx++] = new ItemBone() {Count = 64};

            //player.Inventory.Helmet = new ItemDiamondHelmet();
            player.Inventory.Chest = new ItemElytra();
            //player.Inventory.Leggings = new ItemDiamondLeggings();
            //player.Inventory.Boots = new ItemDiamondBoots();
            //while (player.Inventory.SetFirstEmptySlot(new ItemIronAxe(), false)) { }

            player.SendPlayerInventory();

            player.SendArmorForPlayer();
            player.SendEquipmentForPlayer();

            _players.TryAdd(player.Username, player);

            ThreadPool.QueueUserWorkItem(state =>
            {
                Thread.Sleep(2000);
                level.BroadcastMessage($"{ChatColors.Gold}[{ChatColors.Green}+{ChatColors.Gold}]{ChatFormatting.Reset} {player.Username} joined the server");
                var joinSound = new AnvilUseSound(level.SpawnPoint.ToVector3());
                joinSound.Spawn(level);

                player.SendTitle(null, TitleType.Clear);
                player.SendTitle(null, TitleType.AnimationTimes, 6, 6, 20 * 10);
                player.SendTitle($"{ChatColors.White}This is gurun's MiNET\n.NET core test server", TitleType.SubTitle);
                player.SendTitle($"{ChatColors.Gold}Welcome {player.Username}!", TitleType.Title);
            });
        }