NextBlock() private method

private NextBlock ( [ player, bool allowNoneBlock, Block &block ) : bool
player [
allowNoneBlock bool
block Block
return bool
Beispiel #1
0
        static void CutHandler( Player player, CommandReader cmd ) {
            Block fillBlock = Block.Air;
            if( cmd.HasNext ) {
                if( !cmd.NextBlock( player, false, out fillBlock ) ) return;
                if( cmd.HasNext ) {
                    CdCut.PrintUsage( player );
                    return;
                }
            }

            CutDrawOperation op = new CutDrawOperation( player ) {
                Brush = new NormalBrush( fillBlock )
            };

            player.SelectionStart( 2, DrawOperationCallback, op, Permission.Draw );
            player.Message( "{0}: Click 2 or &H/Mark&S 2 blocks.",
                            op.Description );
        }
        static void BindHandler([NotNull] Player player, [NotNull] CommandReader cmd)
        {
            if (!cmd.HasNext)
            {
                player.Message("All bindings have been reset.");
                player.ResetAllBinds();
                return;
            }

            Block originalBlock;

            if (!cmd.NextBlock(player, false, out originalBlock))
            {
                return;
            }

            if (!cmd.HasNext)
            {
                if (player.GetBind(originalBlock) != originalBlock)
                {
                    player.Message("{0} is no longer bound to {1}",
                                   originalBlock,
                                   player.GetBind(originalBlock));
                    player.ResetBind(originalBlock);
                }
                else
                {
                    player.Message("{0} is not bound to anything.",
                                   originalBlock);
                }
                return;
            }

            Block replacementBlock;

            if (!cmd.NextBlock(player, false, out replacementBlock))
            {
                return;
            }

            if (cmd.HasNext)
            {
                CdBind.PrintUsage(player);
                return;
            }

            Permission permission = Permission.Build;

            switch (replacementBlock)
            {
            case Block.Grass:
                permission = Permission.PlaceGrass;
                break;

            case Block.Admincrete:
                permission = Permission.PlaceAdmincrete;
                break;

            case Block.Water:
                permission = Permission.PlaceWater;
                break;

            case Block.Lava:
                permission = Permission.PlaceLava;
                break;
            }
            if (player.Can(permission))
            {
                player.Bind(originalBlock, replacementBlock);
                player.Message("{0} is now replaced with {1}", originalBlock, replacementBlock);
            }
            else
            {
                player.Message("&WYou do not have {0} permission.", permission);
            }
        }
Beispiel #3
0
        static void BindHandler( Player player, CommandReader cmd ) {
            if( !cmd.HasNext ) {
                player.Message( "All bindings have been reset." );
                player.ResetAllBinds();
                return;
            }

            Block originalBlock;
            if( !cmd.NextBlock( player, false, out originalBlock ) ) return;

            if( !cmd.HasNext ) {
                if( player.GetBind( originalBlock ) != originalBlock ) {
                    player.Message( "{0} is no longer bound to {1}",
                                    originalBlock,
                                    player.GetBind( originalBlock ) );
                    player.ResetBind( originalBlock );
                } else {
                    player.Message( "{0} is not bound to anything.",
                                    originalBlock );
                }
                return;
            }

            Block replacementBlock;
            if( !cmd.NextBlock( player, false, out replacementBlock ) ) return;

            if( cmd.HasNext ) {
                CdBind.PrintUsage( player );
                return;
            }

            Permission permission = Permission.Build;
            switch( replacementBlock ) {
                case Block.Grass:
                    permission = Permission.PlaceGrass;
                    break;
                case Block.Admincrete:
                    permission = Permission.PlaceAdmincrete;
                    break;
                case Block.Water:
                    permission = Permission.PlaceWater;
                    break;
                case Block.Lava:
                    permission = Permission.PlaceLava;
                    break;
            }
            if( player.Can( permission ) ) {
                player.Bind( originalBlock, replacementBlock );
                player.Message( "{0} is now replaced with {1}", originalBlock, replacementBlock );
            } else {
                player.Message( "&WYou do not have {0} permission.", permission );
            }
        }
Beispiel #4
0
        static void CutHandler( Player player, CommandReader cmd ) {
            Block fillBlock = Block.Air;
            if( cmd.HasNext ) {
                if( !cmd.NextBlock( player, false, out fillBlock ) ) return;
                if( cmd.HasNext ) {
                    CdCut.PrintUsage( player );
                    return;
                }
            }

            CutDrawOperation op = new CutDrawOperation( player ) {
                Brush = new NormalBrush( fillBlock )
            };

            player.SelectionStart( 2, DrawOperationCallback, op, CdCut.Permissions );
            if( fillBlock != Block.Air ) {
                player.Message( "Cut/{0}: Click 2 blocks or use &H/Mark&S to make a selection.",
                                fillBlock );
            } else {
                player.Message( "Cut: Click 2 blocks or use &H/Mark&S to make a selection." );
            }
        }