コード例 #1
0
        public PlayerInventoryManager(Player player)
        {
            _player = player;
            for (var i = 0; i <= 45; i++)
            {
                _slots[i] = (new ItemStack(-1, 0, 0));
            }

            SetSlot(5, 310, 0, 1); //Diamond helmet
            SetSlot(6, 311, 0, 1); //Diamond chestplate
            SetSlot(7, 312, 0, 1); //Diamond leggings
            SetSlot(8, 313, 0, 1); //Diamond boots

            SetSlot(36, 276, 0, 1); //Diamond sword
            SetSlot(37, 277, 0, 1); //Diamond shovel
            SetSlot(38, 278, 0, 1); //Diamond pickaxe
            SetSlot(39, 279, 0, 1); //Diamond axe

            SetSlot(43, 5, 0, 64);
            SetSlot(44, 332, 0, 64);

            SetSlot(41, 327, 0, 1);
            SetSlot(42, 326, 0, 1);
            SetSlot(40, 325, 0, 1);

            UpdateHandItems();
        }
コード例 #2
0
ファイル: BlockLever.cs プロジェクト: LiveMC/SharpMC
        public override bool PlaceBlock(Level world, Player player, Vector3 blockCoordinates, BlockFace face, Vector3 mouseLocation)
        {
            var rawbits = new BitArray(new byte[] { 0x00 });

            byte direction = player.GetDirection();
            if (face == BlockFace.PositiveY)
            {
                switch (direction)
                {
                    case 0:
                        //South
                        rawbits[1] = true;
                        rawbits[2] = true;
                        break;
                    case 1:
                        //West
                        rawbits[0] = true;
                        rawbits[2] = true;
                        break;
                    case 2:
                        //North
                        rawbits[1] = true;
                        rawbits[2] = true;
                        break;
                    case 3:
                        //East
                        rawbits[0] = true;
                        rawbits[2] = true;
                        break;
                }
            }
            else if (face == BlockFace.NegativeY)
            {
                rawbits[0] = true;
                rawbits[1] = true;
                rawbits[2] = true;
            }
            else if (face == BlockFace.PositiveZ)
            {
                rawbits[0] = true;
                rawbits[1] = true;
            }
            else if (face == BlockFace.NegativeZ)
            {
                rawbits[2] = true;
            }
            else if (face == BlockFace.PositiveX)
            {
                rawbits[0] = true;
            }
            else if (face == BlockFace.NegativeX)
            {
                rawbits[1] = true;
            }

            Metadata = ConvertToByte(rawbits);

            world.SetBlock(this);
            return true;
        }
コード例 #3
0
ファイル: ItemBucket.cs プロジェクト: LiveMC/SharpMC
        public override void UseItem(Level world, Player player, Vector3 blockCoordinates, BlockFace face)
        {
            blockCoordinates = GetNewCoordinatesFromFace(blockCoordinates, face);
            var bl = world.GetBlock(blockCoordinates);

            var slot = 0;
            var hand0 = player.Inventory.GetItemInHand(0);
            var hand1 = player.Inventory.GetItemInHand(1);
            if (hand0.Id == Id)
            {
                slot = player.Inventory.CurrentSlot + 36;
            }
            else if (hand1.Id == Id)
            {
                slot = 45;
            }

            //player.SendChat("Block: " + bl.Id, ChatColor.Bold);
            if (bl.Id == 65535) return;

            if (bl.Id == 8)
            {
                //Water
                player.Inventory.SetSlot(slot, 326, 0, 1);
                world.SetBlock(new BlockAir() {Coordinates = blockCoordinates}, true, true);
            }

            if (bl.Id == 10)
            {
                //lava
                player.Inventory.SetSlot(slot, 327, 0, 1);
                world.SetBlock(new BlockAir() { Coordinates = blockCoordinates }, true, true);
            }
        }
コード例 #4
0
ファイル: Slab.cs プロジェクト: LiveMC/SharpMC
 public override bool PlaceBlock(Level world, Player player, Vector3 blockCoordinates, BlockFace face, Vector3 mouseLocation)
 {
     var prevblock = world.GetBlock(Coordinates);
     if (prevblock.Id == Id && prevblock.Metadata == Metadata)
     {
         DoubleSlab ds = new DoubleSlab(Metadata) {Coordinates = Coordinates};
         world.SetBlock(ds);
     }
     else if (prevblock.Id == Id && prevblock.Metadata != Metadata)
     {
         if (player.Gamemode != Gamemode.Creative)
         {
             player.Inventory.AddItem((short)Id, Metadata, 1);
         }
         return true;
     }
     else
     {
         bool upper = ((mouseLocation.Y >= 8 && face != BlockFace.PositiveY) || face == BlockFace.NegativeY);
         BitArray b = new BitArray(new byte[] {Metadata});
         b[3] = upper;
         Metadata = ConvertToByte(b);
         world.SetBlock(this);
     }
     return true;
 }
コード例 #5
0
ファイル: PermissionManager.cs プロジェクト: LiveMC/SharpMC
        public static bool RemovePermission(Player player, string permission)
        {
            if (Permissions.Contains(new Tuple<string, string>(player.Username, permission)))
                return Permissions.Remove(new Tuple<string, string>(player.Username, permission));

            return false;
        }
コード例 #6
0
ファイル: ItemRedstone.cs プロジェクト: LiveMC/SharpMC
 public override void UseItem(Level world, Player player, Vector3 blockCoordinates, BlockFace face)
 {
     blockCoordinates = GetNewCoordinatesFromFace(blockCoordinates, face);
     var d = new BlockRedstoneDust {Coordinates = blockCoordinates};
     //d.SetPowerLevel(new Random().Next(0,15));
     world.SetBlock(d, true, true);
 }
コード例 #7
0
ファイル: Globals.cs プロジェクト: LiveMC/SharpMC
 public static void BroadcastChat(McChatMessage message, ChatMessageType chattype, Player sender)
 {
     foreach (var lvl in LevelManager.GetLevels())
     {
         lvl.BroadcastChat(message, chattype, sender);
     }
     LevelManager.MainLevel.BroadcastChat(message, chattype, sender);
 }
コード例 #8
0
ファイル: BlockTNT.cs プロジェクト: LiveMC/SharpMC
 public override void UseItem(Level world, Player player, Vector3 blockCoordinates, BlockFace face)
 {
     if (player.Inventory.GetItemInHand(1).Id == 259 || player.Inventory.GetItemInHand(0).Id == 259)
     {
         this.BreakBlock(world);
         new PrimedTNTEntity(world){KnownPosition = Coordinates.ToPlayerLocation()}.SpawnEntity();
     }
 }
コード例 #9
0
ファイル: PermissionManager.cs プロジェクト: LiveMC/SharpMC
 public static string[] GetPermissions(Player player)
 {
     var list = new List<string>();
     foreach (var val in Permissions)
     {
         if (val.Item1 == player.Username) list.Add(val.Item2);
     }
     return list.ToArray();
 }
コード例 #10
0
ファイル: Projectile.cs プロジェクト: LiveMC/SharpMC
 protected Projectile(Player shooter, int entityTypeId, Level level)
     : base(entityTypeId, level)
 {
     Shooter = shooter;
     Ttl = 0;
     DespawnOnImpact = true;
     Collided = false;
     KnownPosition = new PlayerLocation(shooter.KnownPosition.X, shooter.KnownPosition.Y, shooter.KnownPosition.Z) {Yaw = shooter.KnownPosition.Yaw, Pitch = shooter.KnownPosition.Pitch};
 }
コード例 #11
0
ファイル: WorldProvider.cs プロジェクト: LiveMC/SharpMC
        public IEnumerable<ChunkColumn> GenerateChunks(int viewDistance, List<Tuple<int, int>> chunksUsed, Player player)
        {
            lock (chunksUsed)
            {
                Dictionary<Tuple<int, int>, double> newOrders = new Dictionary<Tuple<int, int>, double>();
                double radiusSquared = viewDistance / Math.PI;
                double radius = Math.Ceiling(Math.Sqrt(radiusSquared));
                int centerX = (int)player.KnownPosition.X >> 4;
                int centerZ = (int)player.KnownPosition.Z >> 4;

                for (double x = -radius; x <= radius; ++x)
                {
                    for (double z = -radius; z <= radius; ++z)
                    {
                        var distance = (x * x) + (z * z);
                        if (distance > radiusSquared)
                        {
                            continue;
                        }
                        int chunkX = (int)(x + centerX);
                        int chunkZ = (int)(z + centerZ);
                        Tuple<int, int> index = new Tuple<int, int>(chunkX, chunkZ);
                        newOrders[index] = distance;
                    }
                }

                if (newOrders.Count > viewDistance)
                {
                    foreach (var pair in newOrders.OrderByDescending(pair => pair.Value))
                    {
                        if (newOrders.Count <= viewDistance) break;
                        newOrders.Remove(pair.Key);
                    }
                }

                foreach (var chunkKey in chunksUsed.ToArray())
                {
                    if (!newOrders.ContainsKey(chunkKey))
                    {
                        chunksUsed.Remove(chunkKey);
                        new Task(() => player.UnloadChunk(chunkKey.Item1, chunkKey.Item2)).Start();
                    }
                }

                foreach (var pair in newOrders.OrderBy(pair => pair.Value))
                {
                    if (chunksUsed.Contains(pair.Key)) continue;

                    var chunk = GenerateChunkColumn(new Vector2(pair.Key.Item1, pair.Key.Item2));
                    chunksUsed.Add(pair.Key);

                    yield return chunk;
                }
            }
        }
コード例 #12
0
ファイル: Door.cs プロジェクト: LiveMC/SharpMC
        public override bool PlaceBlock(Level world, Player player, Vector3 blockCoordinates, BlockFace face, Vector3 mouseLocation)
        {
            var direction = player.GetDirection();
            var coordinates = GetNewCoordinatesFromFace(blockCoordinates, face);

            Block block = new Door(Id);
            block.Coordinates = coordinates;
            block.Metadata = direction;

            var x = (int) blockCoordinates.X;
            var y = (int) blockCoordinates.Y;
            var z = (int) blockCoordinates.Z;

            var xd = 0;
            var zd = 0;

            if (direction == 0) zd = 1;
            if (direction == 1) xd = -1;
            if (direction == 2) zd = -1;
            if (direction == 3) xd = 1;

            var i1 = (world.GetBlock(new Vector3(x - xd, y, z - zd)).IsSolid ? 1 : 0) +
                     (world.GetBlock(new Vector3(x - xd, y + 1, z - zd)).IsSolid ? 1 : 0);
            var j1 = (world.GetBlock(new Vector3(x + xd, y, z + zd)).IsSolid ? 1 : 0) +
                     (world.GetBlock(new Vector3(x + xd, y + 1, z + zd)).IsSolid ? 1 : 0);
            var flag = world.GetBlock(new Vector3(x - xd, y, z - zd)).Id == block.Id ||
                       world.GetBlock(new Vector3(x - xd, y + 1, z - zd)).Id == block.Id;
            var flag1 = world.GetBlock(new Vector3(x + xd, y, z + zd)).Id == block.Id ||
                        world.GetBlock(new Vector3(x + xd, y + 1, z + zd)).Id == block.Id;
            var flag2 = false;

            if (flag && !flag1)
            {
                flag2 = true;
            }
            else if (j1 > i1)
            {
                flag2 = true;
            }

            var c2 = coordinates;
            c2.Y++;

            Block blockUpper = new Door(Id);
            blockUpper.Coordinates = c2;
            blockUpper.Metadata = (byte) (0x08 | (flag2 ? 1 : 0));

            world.SetBlock(block);
            world.SetBlock(blockUpper);

            return true;
        }
コード例 #13
0
ファイル: SnowballEntity.cs プロジェクト: LiveMC/SharpMC
        public SnowballEntity(Player shooter, Level level)
            : base(shooter, 61, level)
        {
            Width = 0.25;
            Length = 0.25;
            Height = 0.25;

            Gravity = 0.03;
            Drag = 0.01;

            Ttl = 9999999;
            ObjectType = ObjectType.Snowball;
        }
コード例 #14
0
ファイル: PermissionManager.cs プロジェクト: LiveMC/SharpMC
        public static bool HasPermission(Player player, string permission)
        {
            if (player.IsOperator) return true; //Operators (OP) have all permissions.
            if (permission == "") return true;

            foreach (var d in Permissions)
            {
                if (d.Item1 == player.Username)
                {
                    if (d.Item2 == permission) return true;
                }
            }

            return false;
        }
コード例 #15
0
ファイル: ItemSign.cs プロジェクト: LiveMC/SharpMC
        public override void UseItem(Level world, Player player, Vector3 blockCoordinates, BlockFace face)
        {
            blockCoordinates = GetNewCoordinatesFromFace(blockCoordinates, face);
            if (face == BlockFace.PositiveY)
            {
                var bss = new BlockStandingSign
                {
                    Coordinates = blockCoordinates,
                    Metadata = 0x00
                };

                var rawbytes = new BitArray(new byte[] {bss.Metadata});

                var direction = player.GetDirection();
                switch (direction)
                {
                    case 0:
                        //South
                        rawbytes[2] = true;
                        break;
                    case 1:
                        //West
                        rawbytes[3] = true;
                        break;
                    case 2:
                        //North DONE
                        rawbytes[2] = true;
                        rawbytes[3] = true;
                        break;
                    case 3:
                        //East

                        break;
                }
                bss.Metadata = ConvertToByte(rawbytes);
                world.SetBlock(bss);
                new SignEditorOpen(player.Wrapper)
                {
                    Coordinates = blockCoordinates
                }.Write();
            }
            else
            {
                //TODO: implement wall signs
            }
        }
コード例 #16
0
ファイル: InfoTool.cs プロジェクト: LiveMC/SharpMC
 public override void UseItem(Level world, Player player, Vector3 blockCoordinates, BlockFace face)
 {
     var blockatpos = world.GetBlock(blockCoordinates);
     if (!(blockatpos is BlockAir))
     {
         BitArray b = new BitArray(new byte[] {blockatpos.Metadata});
         ConsoleFunctions.WriteLine("\n\n");
         ConsoleFunctions.WriteInfoLine("------------------------------------");
         ConsoleFunctions.WriteInfoLine("Block: " + blockatpos);
         ConsoleFunctions.WriteInfoLine("------------------------------------");
         for (int i = 0; i < b.Count; i++)
         {
             ConsoleFunctions.WriteInfoLine("Bit " + i + ": " + b[i]);
         }
         ConsoleFunctions.WriteInfoLine("------------------------------------\n\n");
         player.SendChat("Info tool used, Metadata written to chat!", ChatColor.Gold);
     }
 }
コード例 #17
0
ファイル: ItemWaterBucket.cs プロジェクト: LiveMC/SharpMC
 public override void UseItem(Level world, Player player, Vector3 blockCoordinates, BlockFace face)
 {
     blockCoordinates = GetNewCoordinatesFromFace(blockCoordinates, face);
     //var slot = player.Inventory.CurrentSlot + 36;
     //player.Inventory.SetSlot(slot, 325, 0, 1); //'Empty' the bucket.
     var hand0 = player.Inventory.GetItemInHand(0);
     var hand1 = player.Inventory.GetItemInHand(1);
     if (hand0.Id == Id)
     {
         var slot = player.Inventory.CurrentSlot + 36;
         player.Inventory.SetSlot(slot, 325, 0, 1);
     }
     else if (hand1.Id == Id)
     {
         var slot = 45;
         player.Inventory.SetSlot(slot, 325, 0, 1);
     }
     world.SetBlock(new BlockFlowingWater {Coordinates = blockCoordinates}, true, true); //Place the water
     //	world.GetBlock(blockCoordinates).OnTick(world); //Update the water
 }
コード例 #18
0
ファイル: Class1.cs プロジェクト: LiveMC/SharpMC
        public void MyInfo(Player player, bool console = false)
        {
            player.SendChat("====Start Debug Info====", ChatColor.Yellow);
            player.SendChat("Operator Status: " + player.IsOperator, ChatColor.Yellow);
            player.SendChat("Username: "******"UUID: " + player.Uuid, ChatColor.Yellow);
            player.SendChat("Gamemode: " + player.Gamemode, ChatColor.Yellow);
            player.SendChat("====End of Debug Info====", ChatColor.Yellow);

            if (console)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("====Start Debug Info====");
                Console.WriteLine("Operator Status: " + player.IsOperator);
                Console.WriteLine("Username: "******"UUID: " + player.Uuid);
                Console.WriteLine("Gamemode: " + player.Gamemode);
                Console.WriteLine("====End of Debug Info====");
                Console.ResetColor();
            }
        }
コード例 #19
0
ファイル: StairsBlock.cs プロジェクト: LiveMC/SharpMC
 public override bool PlaceBlock(Level world, Player player, Vector3 blockCoordinates, BlockFace face, Vector3 mouseLocation)
 {
     byte direction = player.GetDirection();
     byte upper = (byte)((mouseLocation.Y >= 8 && face != BlockFace.PositiveY) || face == BlockFace.NegativeY ? 0x04 : 0x00);
     switch (direction)
     {
         case 0:
             Metadata = (byte)(0 | upper);
             break;
         case 1:
             Metadata = (byte)(2 | upper);
             break;
         case 2:
             Metadata = (byte)(1 | upper);
             break;
         case 3:
             Metadata = (byte)(3 | upper);
             break;
     }
     world.SetBlock(this);
     return true;
 }
コード例 #20
0
ファイル: ItemFlintAndSteel.cs プロジェクト: LiveMC/SharpMC
 public override void UseItem(Level world, Player player, Vector3 blockCoordinates, BlockFace face)
 {
     blockCoordinates = GetNewCoordinatesFromFace(blockCoordinates, face);
     var block = world.GetBlock(blockCoordinates);
     ConsoleFunctions.WriteInfoLine("Block: " + block.Id);
     if (block.Id != 46)
     {
         var affectedBlock = world.GetBlock(blockCoordinates);
         if (affectedBlock.Id == 0)
         {
             var fire = new BlockFire
             {
                 Coordinates = affectedBlock.Coordinates
             };
             world.SetBlock(fire);
         }
     }
     else
     {
         new PrimedTNTEntity(world) {KnownPosition = blockCoordinates.ToPlayerLocation()}.SpawnEntity();
     }
 }
コード例 #21
0
ファイル: PluginManager.cs プロジェクト: LiveMC/SharpMC
        public void HandleCommand(string message, Player player)
        {
            try
            {
                var commandText = message.Split(' ')[0];
                message = message.Replace(commandText, "").Trim();
                commandText = commandText.Replace("/", "").Replace(".", "");

                var arguments = message.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);

                foreach (var handlerEntry in _pluginCommands)
                {
                    var commandAttribute = handlerEntry.Value;
                    if (!commandText.Equals(commandAttribute.Command, StringComparison.InvariantCultureIgnoreCase)) continue;

                    var method = handlerEntry.Key;
                    if (method == null) return;

                    var authorizationAttributes = method.GetCustomAttributes<PermissionAttribute>(true);
                    foreach (var authorizationAttribute in authorizationAttributes)
                    {
                        if (!PermissionManager.HasPermission(player, authorizationAttribute.Permission))
                        {
                            player.SendChat("You are not permitted to use this command!", ChatColor.Red);
                            return;
                        }
                    }
                    if (ExecuteCommand(method, player, arguments, commandAttribute)) return;
                }
            }
            catch (Exception ex)
            {
                ConsoleFunctions.WriteWarningLine(ex.ToString());
            }
            player.SendChat("Unknown command.", ChatColor.Red);
        }
コード例 #22
0
ファイル: Flowing.cs プロジェクト: LiveMC/SharpMC
 public override bool PlaceBlock(Level world, Player player, Vector3 blockCoordinates, BlockFace face, Vector3 mouseLocation)
 {
     CheckForHarden(world, (int) blockCoordinates.X, (int) blockCoordinates.Y, (int) blockCoordinates.Z);
     world.ScheduleBlockTick(this, TickRate());
     return false;
 }
コード例 #23
0
ファイル: PluginManager.cs プロジェクト: LiveMC/SharpMC
        private bool ExecuteCommand(MethodInfo method, Player player, string[] args, CommandAttribute commandAttribute)
        {
            var parameters = method.GetParameters();

            var addLenght = 0;
            int requiredParameters = 0;
            if (parameters.Length > 0 && parameters[0].ParameterType == typeof (Player))
            {
                addLenght = 1;
                requiredParameters = -1;
            }

            bool hasRequiredParameters = true;
            bool hasStringArray = false;

            foreach (var param in parameters)
            {
                if (!param.IsOptional) requiredParameters++;
                if (param.ParameterType == typeof (string[])) hasStringArray = true;
            }

            if (args.Length < requiredParameters && !hasStringArray) hasRequiredParameters = false;

            if (!hasRequiredParameters || args.Length > (parameters.Length - addLenght) && !hasStringArray)
            {
                player.SendChat("Invalid command usage!", ChatColor.Red);
                player.SendChat(commandAttribute.Usage, ChatColor.Red);
                return true;
            }

            var objectArgs = new object[parameters.Length];

            bool stringarrayfound = false;
            int stringarrayposition = 0;
            List<string> stringarrayvalues = new List<string>();

            int length = args.Length + addLenght;
            for (var k = 0; k < length; k++)
            {
                var parameter = parameters[k];
                var i = k - addLenght;
                if (k == 0 && addLenght == 1)
                {
                    if (parameter.ParameterType == typeof (Player))
                    {
                        objectArgs[k] = player;
                        continue;
                    }
                    ConsoleFunctions.WriteWarningLine("Command method " + method.Name + " missing Player as first argument.");
                    return false;
                }

                if (parameter.ParameterType == typeof (string[]))
                {
                    stringarrayfound = true;
                    stringarrayposition = k;
                    stringarrayvalues.Add(args[i]);

                    objectArgs[stringarrayposition] = stringarrayvalues.ToArray();
                    break;
                }

                if (parameter.ParameterType == typeof (string))
                {
                    objectArgs[k] = args[i];
                    continue;
                }

                if (parameter.ParameterType == typeof (byte))
                {
                    byte value;
                    if (!byte.TryParse(args[i], out value)) return false;
                    objectArgs[k] = value;
                    continue;
                }

                if (parameter.ParameterType == typeof (short))
                {
                    short value;
                    if (!short.TryParse(args[i], out value)) return false;
                    objectArgs[k] = value;
                    continue;
                }

                if (parameter.ParameterType == typeof (int))
                {
                    int value;
                    if (!int.TryParse(args[i], out value)) return false;
                    objectArgs[k] = value;
                    continue;
                }

                if (parameter.ParameterType == typeof (bool))
                {
                    bool value;
                    if (!bool.TryParse(args[i], out value)) return false;
                    objectArgs[k] = value;
                    continue;
                }

                if (parameter.ParameterType == typeof (float))
                {
                    float value;
                    if (!float.TryParse(args[i], out value)) return false;
                    objectArgs[k] = value;
                    continue;
                }

                if (parameter.ParameterType == typeof (double))
                {
                    double value;
                    if (!double.TryParse(args[i], out value)) return false;
                    objectArgs[k] = value;
                    continue;
                }

                if (parameter.ParameterType == typeof(Player))
                {
                    Player value = Globals.LevelManager.GetAllPlayers().FirstOrDefault(p => p.Username.ToLower().Equals(args[i].ToLower()));
                    if (value == null)
                    {
                        player.SendChat(String.Format("Player \"{0}\" is not found!", args[i]), ChatColor.Red);
                        return true;
                    }
                    objectArgs[k] = value;
                    continue;
                }

                return false;
            }

            if (stringarrayfound)
            {
                for (int k = stringarrayposition + 1; k <= args.Length; k++)
                {
                    var i = k - addLenght;
                    stringarrayvalues.Add(args[i]);
                    objectArgs[stringarrayposition] = stringarrayvalues.ToArray();
                }
            }

            var pluginInstance = _plugins.FirstOrDefault(plugin => plugin.GetType() == method.DeclaringType);
            if (pluginInstance == null)
            {
                ConsoleFunctions.WriteDebugLine("Plugin instance is null!");
                return false;
            }

            if (method.IsStatic)
            {
                method.Invoke(null, objectArgs);
            }
            else
            {
                if (method.DeclaringType == null) return false;

                method.Invoke(pluginInstance, objectArgs);
            }

            return true;
        }
コード例 #24
0
ファイル: PluginManager.cs プロジェクト: LiveMC/SharpMC
        internal void HandlePlayerJoin(Player player)
        {
            try
            {
                foreach (var handler in _pluginPlayerJoinEvents)
                {
                    var atrib = handler.Value;

                    var method = handler.Key;
                    if (method == null) continue;
                    if (method.IsStatic)
                    {
                        method.Invoke(null, new object[] {player});
                    }
                    else
                    {
                        var pluginInstance = _plugins.FirstOrDefault(plugin => plugin.GetType() == method.DeclaringType);
                        if (pluginInstance == null) continue;

                        if (method.ReturnType == typeof (void))
                        {
                            var parameters = method.GetParameters();
                            if (parameters.Length == 1)
                            {
                                method.Invoke(pluginInstance, new object[] {player});
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //For now we will just ignore this, not to big of a deal.
                //Will have to think a bit more about this later on.
                ConsoleFunctions.WriteWarningLine("Plugin error: " + ex);
            }
        }
コード例 #25
0
ファイル: Level.cs プロジェクト: LiveMC/SharpMC
 public void RemovePlayer(Player player)
 {
     RemovePlayer(player.EntityId);
 }
コード例 #26
0
ファイル: Level.cs プロジェクト: LiveMC/SharpMC
        public int CalculateTps(Player player = null)
        {
            var average = _lastCalc;

            var d = 1000 - _lastCalc;
            d = d/50;
            var exact = d;

            var color = "a";
            if (exact <= 10) color = "c";
            if (exact <= 15 && exact > 10) color = "e";

            if (player != null)
            {
                player.SendChat("TPS: §" + color + exact);
                player.SendChat("Miliseconds in Tick: " + average + "ms");
            }

            return (int) exact;
        }
コード例 #27
0
ファイル: Level.cs プロジェクト: LiveMC/SharpMC
 public void BroadcastChat(McChatMessage message, ChatMessageType messagetype, Player sender)
 {
     foreach (var i in OnlinePlayers.Values)
     {
         if (i == sender)
         {
             continue;
         }
         new ChatMessage(i.Wrapper) { Message = @message }.Write();
     }
 }
コード例 #28
0
ファイル: Level.cs プロジェクト: LiveMC/SharpMC
 public void BroadcastChat(McChatMessage message, Player sender)
 {
     /*foreach (var i in OnlinePlayers)
     {
         if (i == sender)
         {
             continue;
         }
         new ChatMessage(i.Wrapper) { Message = @message }.Write();
     }*/
     BroadcastChat(message, ChatMessageType.ChatBox, sender);
 }
コード例 #29
0
ファイル: Level.cs プロジェクト: LiveMC/SharpMC
        public void AddPlayer(Player player)
        {
            OnlinePlayers.Add(player.EntityId, player);

            new PlayerListItem(player.Wrapper)
            {
                Action = 0,
                Gamemode = player.Gamemode,
                Username = player.Username,
                Uuid = player.Uuid
            }.Broadcast(this); //Send playerlist item to old players & player him self

            IntroduceNewPlayer(player.Wrapper);
        }
コード例 #30
0
ファイル: Globals.cs プロジェクト: LiveMC/SharpMC
 public static void BroadcastChat(string message, Player sender)
 {
     BroadcastChat(new McChatMessage(message), ChatMessageType.ChatBox, sender);
 }